/* CSS Variables */
:root {
    --primary: #4CAF50;
    --primary-dark: #388E3C;
    --primary-light: #C8E6C9;
    --accent: #FF9800;
    --text-primary: #212121;
    --text-secondary: #757575;
    --divider: #BDBDBD;
    --background: #FAFAFA;
    --surface: #FFFFFF;
    --error: #F44336;
    --success: #4CAF50;
    --warning: #FF9800;
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --radius: 12px;
    --radius-sm: 8px;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--background);
    overflow-x: hidden;
}

/* Screen Management */
.screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.screen.hidden {
    display: none;
}

/* Login Screen */
.login-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 24px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.logo {
    text-align: center;
    margin-bottom: 48px;
}

.logo-icon {
    width: 100px;
    height: 100px;
    margin-bottom: 16px;
}

.logo h1 {
    color: white;
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.logo p {
    color: rgba(255,255,255,0.8);
    font-size: 1rem;
}

.login-form {
    width: 100%;
    max-width: 320px;
}

.input-group {
    margin-bottom: 16px;
}

.input-group label {
    display: block;
    color: rgba(255,255,255,0.9);
    font-size: 0.875rem;
    margin-bottom: 8px;
}

.input-group input {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    background: white;
    outline: none;
}

.btn-primary {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    background: white;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:active {
    transform: scale(0.98);
}

.login-hint {
    margin-top: 24px;
    color: rgba(255,255,255,0.7);
    font-size: 0.875rem;
    text-align: center;
}

/* App Layout */
#app-screen {
    background: var(--background);
}

.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--primary);
    color: white;
    z-index: 100;
    box-shadow: var(--shadow);
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 64px;
    display: flex;
    background: var(--surface);
    box-shadow: 0 -2px 8px rgba(0,0,0,0.05);
    z-index: 100;
}

.nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--text-secondary);
    transition: color 0.2s;
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 1.5rem;
    margin-bottom: 2px;
}

.nav-label {
    font-size: 0.75rem;
}

/* Content Area */
.content {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 64px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Tabs */
.tab-content {
    display: none;
    padding: 16px;
    padding-bottom: 80px;
}

.tab-content.active {
    display: block;
}

.tab-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.tab-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

.btn-add {
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.btn-secondary {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-secondary span:first-child {
    font-size: 1.25rem;
}

/* Item Lists */
.item-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.item-list.compact .item-card {
    padding: 12px;
}

.item-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.item-info {
    flex: 1;
}

.item-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.item-meta {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.item-cost {
    font-size: 0.875rem;
    color: var(--success);
    font-weight: 500;
}

.item-actions {
    display: flex;
    gap: 8px;
}

.btn-small {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 0.875rem;
    cursor: pointer;
}

.btn-delete {
    padding: 6px 12px;
    border: none;
    border-radius: var(--radius-sm);
    background: #FFEBEE;
    color: var(--error);
    font-size: 0.875rem;
    cursor: pointer;
}

.section-header {
    margin: 20px 0 12px;
}

.section-header h3 {
    font-size: 1rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.section-desc {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

/* Meals Tab */
.chat-container {
    min-height: 200px;
    max-height: 50vh;
    overflow-y: auto;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

.chat-message {
    margin-bottom: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    max-width: 80%;
}

.chat-message.user {
    background: var(--primary-light);
    color: var(--text-primary);
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.chat-message.ai {
    background: #F5F5F5;
    color: var(--text-primary);
    margin-right: auto;
    border-bottom-left-radius: 4px;
}

.chat-message.menu-suggestion {
    background: #E3F2FD;
    border: 1px solid #BBDEFB;
}

.quick-actions {
    margin-bottom: 16px;
}

.quick-actions p {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.quick-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn-chip {
    padding: 8px 16px;
    border: 1px solid var(--primary);
    border-radius: 20px;
    background: white;
    color: var(--primary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

.chat-input-container {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.chat-input-container input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    outline: none;
}

.btn-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 200;
    padding: 0;
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    width: 100%;
    max-height: 90vh;
    background: var(--surface);
    border-radius: var(--radius) var(--radius) 0 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal.hidden {
    display: none;
}

.modal-large {
    max-height: 95vh;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #E0E0E0;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.btn-close {
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-form {
    padding: 20px;
}

.modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--divider);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    outline: none;
}

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

.form-row {
    display: flex;
    gap: 12px;
}

.form-row .form-group {
    flex: 1;
}

.form-actions {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    border-top: 1px solid #E0E0E0;
}

.form-actions button {
    flex: 1;
    padding: 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
}

.btn-cancel {
    background: #F5F5F5;
    color: var(--text-primary);
}

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

/* Camera Modal */
.camera-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: black;
    display: flex;
    flex-direction: column;
}

#camera-preview {
    flex: 1;
    width: 100%;
    object-fit: cover;
}

.camera-controls {
    display: flex;
    align-items: center;
    justify-content: space-around;
    padding: 20px;
    background: rgba(0,0,0,0.5);
}

.btn-capture {
    width: 64px;
    height: 64px;
    border: 4px solid white;
    border-radius: 50%;
    background: white;
    font-size: 1.5rem;
    cursor: pointer;
}

/* Recipe Steps */
.recipe-step {
    display: flex;
    gap: 12px;
    padding: 16px;
    margin-bottom: 8px;
    background: #F5F5F5;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
}

.recipe-step:hover {
    background: #EEEEEE;
}

.recipe-step.completed {
    background: var(--primary-light);
    opacity: 0.7;
}

.recipe-step.completed .step-text {
    text-decoration: line-through;
}

.step-checkbox {
    width: 24px;
    height: 24px;
    border: 2px solid var(--divider);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.recipe-step.completed .step-checkbox {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.step-number {
    font-weight: 600;
    color: var(--primary);
    min-width: 24px;
}

.step-text {
    flex: 1;
}

.step-duration {
    font-size: 0.75rem;
    color: var(--text-secondary);
    background: white;
    padding: 2px 8px;
    border-radius: 12px;
}

.recipe-info {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: #E3F2FD;
    border-radius: var(--radius-sm);
    margin-top: 16px;
}

/* Meal Plan View */
.meal-day {
    margin-bottom: 20px;
    padding: 16px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
}

.meal-day h4 {
    font-size: 1.125rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.meal-item {
    padding: 12px;
    margin-bottom: 8px;
    background: #F5F5F5;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.meal-item h5 {
    font-weight: 500;
    margin-bottom: 4px;
}

.meal-item p {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.missing-ingredients {
    margin-top: 16px;
    padding: 12px;
    background: #FFEBEE;
    border-radius: var(--radius-sm);
}

.missing-ingredients h5 {
    color: var(--error);
    margin-bottom: 8px;
}

.cost-estimate {
    margin-top: 16px;
    padding: 16px;
    background: var(--primary-light);
    border-radius: var(--radius-sm);
    text-align: center;
    font-weight: 500;
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    padding: 12px 24px;
    border-radius: var(--radius-sm);
    color: white;
    font-size: 0.875rem;
    animation: slideDown 0.3s ease;
    box-shadow: var(--shadow-lg);
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

.toast.warning {
    background: var(--warning);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Offline Indicator */
#offline-indicator {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    padding: 8px;
    background: var(--warning);
    color: white;
    text-align: center;
    font-size: 0.875rem;
    z-index: 90;
}

#offline-indicator.hidden {
    display: none;
}

/* Loading Spinner */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1rem;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.mb-16 {
    margin-bottom: 16px;
}

.mt-16 {
    margin-top: 16px;
}

/* Animations */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}
