/* Performance optimizations */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    /* Mobile optimizations */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Critical CSS - Load first */
.hidden {
    display: none !important;
}

/* Mobile performance optimizations */
@media (max-width: 768px) {
    * {
        /* Reduce repaints on mobile */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Auth Container Styles */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}

.auth-card {
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    animation: slideUp 0.5s ease-out;
}

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

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

.auth-header i {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 15px;
}

.auth-header h1 {
    font-size: 2rem;
    color: #333;
    margin-bottom: 5px;
}

.auth-header p {
    color: #666;
    font-size: 1rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 10px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

/* Button Styles */
.btn-primary {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    padding: 8px 15px;
    background: #f8f9fa;
    color: #333;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.btn-secondary:hover {
    background: #e9ecef;
}

.auth-switch {
    text-align: center;
    margin-top: 20px;
    color: #666;
}

.auth-switch a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.auth-switch a:hover {
    text-decoration: underline;
}

/* Chat Interface Styles */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: #f8f9fa;
}

.chat-header {
    background: white;
    padding: 15px 20px;
    border-bottom: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header-left i {
    font-size: 1.5rem;
    color: #667eea;
}

.chat-header-left h2 {
    color: #333;
    font-size: 1.5rem;
}

.chat-header-right {
    display: flex;
    gap: 10px;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    display: flex;
    margin-bottom: 15px;
}

.user-message {
    justify-content: flex-end;
}

.bot-message {
    justify-content: flex-start;
}

.message-content {
    max-width: 70%;
    padding: 15px 20px;
    border-radius: 20px;
    position: relative;
    animation: messageSlide 0.3s ease-out;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.user-message .message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 5px;
}

.bot-message .message-content {
    background: white;
    color: #333;
    border: 1px solid #e1e5e9;
    border-bottom-left-radius: 5px;
}

.bot-message .message-content i {
    color: #667eea;
    margin-right: 8px;
}

.message-content p {
    line-height: 1.5;
    white-space: pre-line;
}

.chat-input {
    background: white;
    padding: 20px;
    border-top: 1px solid #e1e5e9;
    display: flex;
    gap: 10px;
    align-items: center;
}

.chat-input input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid #e1e5e9;
    border-radius: 25px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

.chat-input input:focus {
    outline: none;
    border-color: #667eea;
}

.chat-input button {
    padding: 12px 15px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.chat-input button:hover {
    transform: scale(1.1);
}

/* Modal Styles */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 15px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.modal-header h3 {
    color: #333;
    font-size: 1.3rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-btn:hover {
    color: #333;
}

.modal-body {
    padding: 20px;
}

/* Profile Info Styles */
.profile-info {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.profile-info h4 {
    color: #333;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.profile-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid #e1e5e9;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 0.9rem;
    color: #666;
}

/* Responsive Design */
@media (max-width: 768px) {
    .auth-card {
        padding: 30px 20px;
        margin: 10px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .chat-header {
        padding: 10px 15px;
    }
    
    .chat-header-left h2 {
        font-size: 1.2rem;
    }
    
    .chat-messages {
        padding: 15px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .chat-input {
        padding: 15px;
    }
    
    .modal-content {
        width: 95%;
        margin: 10px;
    }
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Food Interface Styles */
.food-search-container {
    margin-top: 20px;
}

.search-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.search-input-group input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.search-input-group input:focus {
    outline: none;
    border-color: #4CAF50;
}

.search-input-group .btn-primary {
    padding: 10px 20px;
    white-space: nowrap;
}

.food-results {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    background: #f9f9f9;
}

.food-item {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    cursor: pointer;
    transition: background-color 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.food-item:hover {
    background-color: #e8f5e8;
}

.food-item:last-child {
    border-bottom: none;
}

.food-info h4 {
    margin: 0 0 5px 0;
    color: #333;
    font-size: 16px;
}

.food-info p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

.food-nutrition {
    text-align: right;
    font-size: 12px;
    color: #888;
}

.nutrition-preview {
    background: #f0f8ff;
    padding: 15px;
    border-radius: 8px;
    margin: 15px 0;
    border-left: 4px solid #4CAF50;
}

.nutrition-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.nutrition-item {
    text-align: center;
    padding: 8px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}

.nutrition-value {
    font-weight: bold;
    color: #4CAF50;
    font-size: 16px;
}

.nutrition-label {
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
}

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

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

.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    color: #4CAF50;
}

.no-results {
    text-align: center;
    padding: 40px 20px;
    color: #666;
}

.selected-food-card {
    background: #f0f8ff;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 2px solid #4CAF50;
}

.selected-food-card h4 {
    margin: 0 0 5px 0;
    color: #333;
}

.selected-food-card p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* Nutrition Dashboard Styles */
.nutrition-dashboard {
    max-width: 900px;
    width: 95vw;
}

.dashboard-header-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dashboard-header-buttons .btn-secondary {
    font-size: 14px;
    padding: 8px 12px;
}

.dashboard-date-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    margin-bottom: 30px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
}

.dashboard-date-selector span {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    min-width: 150px;
    text-align: center;
}

.nutrition-summary {
    margin-bottom: 30px;
}

.nutrition-overview {
    margin-bottom: 20px;
}

.calories-card {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.3);
}

.calories-card h4 {
    margin: 0 0 15px 0;
    font-size: 24px;
    font-weight: 300;
}

.progress-circle {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 15px;
}

.macros-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-top: 20px;
}

.macro-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #ddd;
}

.macro-card.protein-card {
    border-left-color: #ff6b6b;
}

.macro-card.carbs-card {
    border-left-color: #4ecdc4;
}

.macro-card.fat-card {
    border-left-color: #ffe66d;
}

.macro-card.fiber-card {
    border-left-color: #a8e6cf;
}

.macro-card h5 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
}

.macro-info {
    font-size: 14px;
    color: #666;
    margin-bottom: 10px;
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #4CAF50;
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-fill.protein {
    background: #ff6b6b;
}

.progress-fill.carbs {
    background: #4ecdc4;
}

.progress-fill.fat {
    background: #ffe66d;
}

.progress-fill.fiber {
    background: #a8e6cf;
}

.meals-breakdown {
    margin-bottom: 30px;
}

.meals-breakdown h4 {
    margin-bottom: 20px;
    color: #333;
    font-size: 20px;
}

.meals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.meal-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.meal-card h5 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.meal-foods {
    min-height: 60px;
    margin-bottom: 10px;
}

.meal-foods .no-foods {
    color: #999;
    font-style: italic;
    font-size: 14px;
}

.food-item {
    background: #f8f9fa;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 5px;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.food-item-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex: 1;
}

.food-item-name {
    font-weight: 500;
    color: #333;
}

.food-item-calories {
    color: #666;
    font-size: 12px;
    margin-right: 10px;
}

.food-item-delete {
    background: #ff4757;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.food-item-delete:hover {
    background: #ff3838;
}

.form-help {
    color: #666;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.food-source {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    margin-top: 5px;
}

.food-source.local-source {
    background: #4CAF50;
    color: white;
}

.food-source.international-source {
    background: #2196F3;
    color: white;
}

.meal-calories {
    font-weight: 600;
    color: #4CAF50;
    text-align: right;
    font-size: 16px;
}

.nutrition-tips {
    background: #f8f9fa;
    padding: 25px;
    border-radius: 12px;
    border-left: 4px solid #4CAF50;
}

.nutrition-tips h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 18px;
}

.tips-content {
    color: #666;
    line-height: 1.6;
}

.tip-item {
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border-left: 3px solid #4CAF50;
}

.tip-item:last-child {
    margin-bottom: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nutrition-dashboard {
        width: 98vw;
        max-width: none;
    }
    
    .macros-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    
    .meals-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
    
    .dashboard-date-selector {
        gap: 15px;
    }
    
    .dashboard-date-selector span {
        font-size: 16px;
        min-width: 120px;
    }
} 