/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #2c5f5d;
    --secondary-color: #5a9b96;
    --accent-color: #7fb8b5;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --success-color: #28a745;
    --light-bg: #f8f9fa;
    --dark-text: #2c3e50;
    --border-color: #dee2e6;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--dark-text);
    background-color: var(--light-bg);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navigation */
.navbar {
    background-color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand a {
    text-decoration: none;
    color: var(--primary-color);
}

.nav-brand h1 {
    font-size: 1.8rem;
    margin-bottom: 0;
}

.nav-brand .tagline {
    font-size: 0.85rem;
    color: var(--secondary-color);
}

.nav-menu {
    list-style: none;
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-menu a {
    text-decoration: none;
    color: var(--dark-text);
    font-weight: 500;
    transition: color 0.3s;
}

.nav-menu a:hover {
    color: var(--primary-color);
}

/* Main Content */
main {
    min-height: calc(100vh - 200px);
    padding: 2rem 0;
}

/* Flash Messages */
.flash-messages {
    margin-bottom: 2rem;
}

.alert {
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #234948;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #4a8480;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 3rem 0;
}

.hero-content h1 {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.hero-subtitle {
    font-size: 1.5rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.hero-description {
    font-size: 1.1rem;
    color: var(--dark-text);
    margin-bottom: 2rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

.hero-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
    margin: 3rem 0;
}

.feature {
    padding: 1.5rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.feature-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.feature h3 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.cta-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 2rem;
}

/* Info Section */
.info-section {
    margin: 4rem 0;
    text-align: center;
}

.info-section h2 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.steps {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 2rem;
}

.step {
    padding: 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.step-number {
    display: inline-block;
    width: 50px;
    height: 50px;
    line-height: 50px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
}

/* Auth Pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 400px;
}

.auth-card h2 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: var(--secondary-color);
    margin-bottom: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--dark-text);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.form-row input,
.form-row textarea,
.form-row select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
}

.form-row textarea {
    min-height: 90px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    padding-top: 1.8rem;
}

.meta-line {
    font-size: 0.9rem;
    color: #555;
    margin-top: 0.2rem;
}

.chip {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    background: #eef2f7;
    border-radius: 999px;
    font-size: 0.85rem;
}

.chip-muted {
    background: #f3f3f3;
    color: #555;
}

.help-text {
    font-size: 0.9rem;
    color: #555;
    margin-top: 0.5rem;
}

.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    color: var(--dark-text);
}

.auth-footer a {
    color: var(--primary-color);
    text-decoration: none;
}

/* Dashboard */
.dashboard h1 {
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.dashboard-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.dashboard-card h2 {
    color: var(--primary-color);
    font-size: 1.3rem;
    margin-bottom: 1rem;
}

.action-buttons {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.allergen-list,
.product-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.allergen-item,
.product-item {
    padding: 0.75rem;
    background: var(--light-bg);
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.allergen-name {
    font-weight: 500;
}

.severity-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.severity-mild {
    background-color: #d4edda;
    color: #155724;
}

.severity-moderate {
    background-color: #fff3cd;
    color: #856404;
}

.severity-severe {
    background-color: #f8d7da;
    color: #721c24;
}

.severity-unknown {
    background-color: #e2e3e5;
    color: #383d41;
}

.empty-state {
    color: #6c757d;
    text-align: center;
    padding: 2rem 0;
}

.info-card {
    background: #e7f3f2;
    padding: 1.5rem;
    border-radius: 12px;
    border-left: 4px solid var(--primary-color);
    margin-top: 2rem;
}

/* Allergens Page */
.allergens-page h1 {
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.allergens-container {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 2rem;
}

.add-allergen-card,
.allergen-list-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.add-allergen-card h2,
.allergen-list-card h2 {
    color: var(--primary-color);
    margin-bottom: 1.5rem;
}

.allergen-table {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.allergen-row {
    padding: 1rem;
    background: var(--light-bg);
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.allergen-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Scan Page */
.scan-page {
    max-width: 900px;
    margin: 0 auto;
}

.scan-page h1 {
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--secondary-color);
    margin-bottom: 2rem;
}

.scan-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 2rem;
}

.scan-card {
    background: white;
    padding: 2rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.upload-area {
    border: 3px dashed var(--border-color);
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: #f0f8f8;
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: #e0f0f0;
}

.upload-area input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    cursor: pointer;
}

.upload-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.upload-hint {
    font-size: 0.9rem;
    color: #6c757d;
}

.image-preview {
    margin: 1rem 0;
    text-align: center;
}

.image-preview img {
    max-width: 100%;
    max-height: 400px;
    border-radius: 8px;
}

.tips-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    height: fit-content;
}

.tips-card h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.tips-list {
    list-style-position: inside;
    color: var(--dark-text);
}

.tips-list li {
    margin-bottom: 0.5rem;
}

/* Results Page */
.results-page {
    max-width: 1000px;
    margin: 0 auto;
}

.results-page h1 {
    color: var(--primary-color);
    margin-bottom: 2rem;
}

.results-summary {
    margin-bottom: 2rem;
}

.summary-card {
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    margin-bottom: 1.5rem;
}

.summary-card h2 {
    margin-bottom: 0.5rem;
}

.alert-danger {
    background-color: #f8d7da;
    color: #721c24;
    border: 2px solid var(--danger-color);
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 2px solid var(--success-color);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.stat-danger .stat-number {
    color: var(--danger-color);
}

.btn-danger .stat-number {
    color: var(--danger-color);
}

.btn-demo {
    background-color: #6c757d;
    color: white;
}

.btn-demo:hover {
    background-color: #5a6268;
}

.save-product-section {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.save-buttons {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.category-badge {
    padding: 0.25rem 0.5rem;
    background: #e2e3e5;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.category-badge.clickable {
    cursor: pointer;
    transition: background-color 0.2s;
}

.category-badge.clickable:hover {
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
}

.view-more {
    text-align: center;
    margin-top: 1rem;
}

.view-more a {
    color: var(--primary-color);
    text-decoration: none;
}

.view-more a:hover {
    text-decoration: underline;
}

.stat-warning .stat-number {
    color: var(--warning-color);
}

.stat-success .stat-number {
    color: var(--success-color);
}

.results-section {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.results-section h2 {
    margin-bottom: 1rem;
}

.results-section.danger {
    border-left: 4px solid var(--danger-color);
}

.results-section.warning {
    border-left: 4px solid var(--warning-color);
}

.results-section.success {
    border-left: 4px solid var(--success-color);
}

.ingredient-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ingredient-item {
    padding: 1rem;
    background: var(--light-bg);
    border-radius: 6px;
}

.ingredient-description {
    font-size: 0.9rem;
    color: #6c757d;
    margin-top: 0.5rem;
}

.category-badge {
    padding: 0.25rem 0.5rem;
    background: #e2e3e5;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.ingredient-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}

.ingredient-chip {
    padding: 0.75rem;
    background: var(--light-bg);
    border-radius: 6px;
    text-align: center;
}

.detected-ingredients {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.detected-ingredients h3 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: center;
}

.inline-input {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-right: 0.5rem;
}

/* Footer */
footer {
    background: white;
    padding: 2rem 0;
    margin-top: 4rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

/* Responsive */
@media (max-width: 768px) {
    .nav-menu {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .hero-content h1 {
        font-size: 2rem;
    }
    
    .hero-features {
        grid-template-columns: 1fr;
    }
    
    .cta-buttons {
        flex-direction: column;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .allergens-container {
        grid-template-columns: 1fr;
    }
    
    .scan-container {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
}
