/* =============================================================================
   CSS CUSTOM PROPERTIES - THEME SYSTEM
   ============================================================================= */

:root {
    /* Light Theme (Default) */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --bg-card: #ffffff;
    --bg-input: #ffffff;
    --bg-hover: #f8f9fa;
    
    --text-primary: #333333;
    --text-secondary: #666666;
    --text-muted: #555555;
    --text-light: #999999;
    
    --border-primary: #e1e5e9;
    --border-secondary: #e9ecef;
    --border-focus: #667eea;
    
    --accent-primary: #667eea;
    --accent-primary-hover: #5a6fd8;
    --accent-secondary: #764ba2;
    --accent-danger: #dc3545;
    --accent-success: #28a745;
    --accent-warning: #ffc107;
    --accent-info: #17a2b8;
    
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-medium: rgba(0, 0, 0, 0.2);
    --shadow-heavy: rgba(0, 0, 0, 0.3);
    
    /* Message colors */
    --msg-success-bg: #d4edda;
    --msg-success-text: #155724;
    --msg-success-border: #c3e6cb;
    --msg-warning-bg: #fff3cd;
    --msg-warning-text: #856404;
    --msg-warning-border: #ffeaa7;
    --msg-error-bg: #f8d7da;
    --msg-error-text: #721c24;
    --msg-error-border: #f5c6cb;
    --msg-info-bg: #d1ecf1;
    --msg-info-text: #0c5460;
    --msg-info-border: #bee5eb;
    
    /* Food suggestion colors */
    --suggestion-bg: #ffffff;
    --suggestion-hover: #f8f9fa;
    --suggestion-selected: #e3f2fd;
    --suggestion-border: #e9ecef;
    
    /* Modal colors */
    --modal-overlay: rgba(0, 0, 0, 0.7);
    --modal-bg: #ffffff;
    --modal-header-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --modal-calorie-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-primary: #1a1a1a;
    --bg-secondary: #2d2d2d;
    --bg-gradient: linear-gradient(135deg, #2c1810 0%, #1a1a2e 100%);
    --bg-card: #2d2d2d;
    --bg-input: #3a3a3a;
    --bg-hover: #3a3a3a;
    
    --text-primary: #e0e0e0;
    --text-secondary: #b0b0b0;
    --text-muted: #888888;
    --text-light: #666666;
    
    --border-primary: #404040;
    --border-secondary: #505050;
    --border-focus: #667eea;
    
    --accent-primary: #7c8bf0;
    --accent-primary-hover: #6c7ce6;
    --accent-secondary: #8b5ba6;
    --accent-danger: #e85d75;
    --accent-success: #4caf50;
    --accent-warning: #ffb74d;
    --accent-info: #29b6f6;
    
    --shadow-light: rgba(0, 0, 0, 0.3);
    --shadow-medium: rgba(0, 0, 0, 0.5);
    --shadow-heavy: rgba(0, 0, 0, 0.7);
    
    /* Message colors - Dark theme */
    --msg-success-bg: #1b5e20;
    --msg-success-text: #c8e6c9;
    --msg-success-border: #2e7d32;
    --msg-warning-bg: #e65100;
    --msg-warning-text: #ffe0b2;
    --msg-warning-border: #f57c00;
    --msg-error-bg: #c62828;
    --msg-error-text: #ffcdd2;
    --msg-error-border: #d32f2f;
    --msg-info-bg: #01579b;
    --msg-info-text: #b3e5fc;
    --msg-info-border: #0277bd;
    
    /* Food suggestion colors - Dark theme */
    --suggestion-bg: #3a3a3a;
    --suggestion-hover: #4a4a4a;
    --suggestion-selected: #2c5aa0;
    --suggestion-border: #505050;
    
    /* Modal colors - Dark theme */
    --modal-overlay: rgba(0, 0, 0, 0.8);
    --modal-bg: #2d2d2d;
    --modal-header-gradient: linear-gradient(135deg, #5a6fd8 0%, #6a4c93 100%);
    --modal-calorie-gradient: linear-gradient(135deg, #e91e63 0%, #f44336 100%);
}

/* Smooth theme transitions */
* {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* =============================================================================
   MAIN STYLES - NOW USING CSS VARIABLES
   ============================================================================= */

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

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

/* Section Management */
.section {
    display: none !important;
}

.section.active {
    display: block !important;
}

/* Login Section */
#loginSection.active {
    display: flex !important;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-card {
    background: var(--bg-card);
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 10px 30px var(--shadow-medium);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.login-card h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    color: var(--text-primary);
}

.login-card p {
    color: var(--text-secondary);
    margin-bottom: 30px;
}

.input-group {
    margin-bottom: 12px;
    text-align: left;
    position: relative; /* Required for absolute positioning of suggestions */
}

.input-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.input-group input,
.input-group select {
    width: 100%;
    padding: 12px;
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
    background: var(--bg-input);
    color: var(--text-primary);
}

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

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--accent-primary);
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: var(--accent-primary-hover);
    transform: translateY(-2px);
}

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

.btn-secondary:hover {
    background: var(--text-muted);
}

.demo-credentials {
    margin-top: 20px;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border-left: 4px solid var(--accent-primary);
}

/* Dashboard Section */
#dashboardSection {
    background: var(--bg-secondary);
    min-height: 100vh;
}

.header {
    background: var(--bg-card);
    box-shadow: 0 2px 10px var(--shadow-light);
    padding: 15px 0;
}

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

.header h1 {
    color: var(--text-primary);
    font-size: 1.8rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.user-info span {
    font-weight: 500;
    color: var(--text-muted);
}

/* Theme Toggle Button */
.theme-toggle {
    background: none;
    border: 2px solid var(--border-secondary);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: var(--bg-card);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    transform: scale(1.1);
}

.theme-toggle:active {
    transform: scale(0.95);
}

/* Login page theme toggle positioning */
.login-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.login-header h1 {
    margin: 0;
    flex: 1;
}

.login-header .theme-toggle {
    margin-left: 20px;
}

/* Sync Status Indicator */
.sync-indicator {
    font-size: 12px;
    padding: 4px 8px;
    border-radius: 12px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.sync-indicator.sync-success {
    background: var(--msg-success-bg);
    color: var(--msg-success-text);
    border: 1px solid var(--msg-success-border);
}

.sync-indicator.sync-progress {
    background: var(--msg-warning-bg);
    color: var(--msg-warning-text);
    border: 1px solid var(--msg-warning-border);
    animation: pulse 1.5s infinite;
}

.sync-indicator.sync-pending {
    background: var(--msg-info-bg);
    color: var(--msg-info-text);
    border: 1px solid var(--msg-info-border);
}

.sync-indicator.sync-error {
    background: var(--msg-error-bg);
    color: var(--msg-error-text);
    border: 1px solid var(--msg-error-border);
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.main {
    padding: 30px 0;
}

/* Cards */
.summary-card,
.add-food-card,
.food-log-card,
.weight-tracking-card,
.history-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px var(--shadow-light);
}

.summary-card h2,
.add-food-card h3,
.food-log-card h3,
.weight-tracking-card h3,
.history-card h3 {
    margin-bottom: 15px;
    color: var(--text-primary);
    font-size: 1.3rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.stat {
    text-align: center;
    padding: 15px 10px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: bold;
    color: var(--accent-primary);
}

.editable-goal {
    cursor: pointer;
    border-radius: 4px;
    padding: 2px 4px;
    transition: background-color 0.2s ease;
}

.editable-goal:hover {
    background-color: var(--bg-secondary);
}

.goal-input {
    font-size: 1.75rem;
    font-weight: bold;
    color: var(--accent-primary);
    background: var(--bg-card);
    border: 2px solid var(--accent-primary);
    border-radius: 8px;
    padding: 8px 12px;
    text-align: center;
    width: 140px;
    margin: 0 auto;
    display: block;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
    transition: all 0.2s ease;
}

.goal-input:focus {
    outline: none;
    border-color: var(--accent-secondary);
    background: var(--bg-primary);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    transform: scale(1.02);
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 5px;
}

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 12px;
    background: var(--border-secondary);
    border-radius: 6px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--bg-gradient);
    border-radius: 6px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Form Styles */
.form-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 10px;
    margin-bottom: 12px;
}

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--suggestion-bg);
    border: 1px solid var(--suggestion-border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    max-height: 400px; /* Increased for more food results */
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: 0 4px 20px var(--shadow-medium);
    /* Smooth scrolling */
    scroll-behavior: smooth;
}

.suggestion-item {
    padding: 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--suggestion-border);
    transition: background-color 0.2s ease;
    color: var(--text-primary);
}

.suggestion-item:hover {
    background: var(--suggestion-hover);
}

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

/* Enhanced Food Suggestions */
.suggestion-item.enhanced {
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.suggestion-item.enhanced:hover {
    background: var(--bg-hover);
    border-left: 3px solid var(--accent-primary);
}

.food-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.food-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
}

.food-source {
    font-size: 11px;
    color: var(--text-secondary);
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 12px;
    font-weight: 500;
}

.food-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.food-calories {
    color: var(--accent-primary);
    font-weight: 600;
}

.food-nutrition {
    color: var(--text-secondary);
    font-size: 11px;
}

.suggestion-item.loading {
    padding: 16px 12px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

.suggestion-item.no-results {
    padding: 16px 12px;
    text-align: center;
    color: var(--text-light);
    font-style: italic;
}

/* Nutrition Preview */
.nutrition-preview-container {
    margin-top: 8px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.nutrition-preview {
    padding: 12px;
    font-size: 13px;
}

.nutrition-preview strong {
    color: var(--text-primary);
    display: block;
    margin-bottom: 8px;
}

.nutrition-preview .macros {
    color: var(--text-secondary);
    margin: 4px 0;
    font-size: 12px;
}

.nutrition-preview .source {
    color: var(--text-light);
    font-size: 11px;
    margin-top: 6px;
    font-style: italic;
}

/* Food Log */
.food-log {
    max-height: 400px;
    overflow-y: auto;
}

.food-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--border-secondary);
    border-radius: 8px;
    margin-bottom: 8px;
    background: var(--bg-secondary);
}

.food-info {
    flex: 1;
}

.food-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.food-details {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-top: 2px;
}

.food-calories {
    font-weight: bold;
    color: var(--accent-primary);
    font-size: 1.05rem;
}

.delete-btn {
    background: var(--accent-danger);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    margin-left: 10px;
}

.delete-btn:hover {
    background: var(--accent-danger);
    opacity: 0.8;
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 40px 20px;
}

/* Success/Error Messages */
.message {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-weight: 500;
    max-width: 100%;
    word-wrap: break-word;
    white-space: pre-wrap; /* Preserve line breaks */
}

.message div {
    margin: 4px 0;
}

.message div:first-child {
    margin-top: 0;
}

.message div:last-child {
    margin-bottom: 0;
}

.message.success {
    background: var(--msg-success-bg);
    color: var(--msg-success-text);
    border: 1px solid var(--msg-success-border);
}

.message.error {
    background: var(--msg-error-bg);
    color: var(--msg-error-text);
    border: 1px solid var(--msg-error-border);
}

.message.warning {
    background: var(--msg-warning-bg);
    color: var(--msg-warning-text);
    border: 1px solid var(--msg-warning-border);
}

.message.info {
    background: var(--msg-info-bg);
    color: var(--msg-info-text);
    border: 1px solid var(--msg-info-border);
}

/* Food Log History Styles */
.history-card {
    animation: fadeIn 0.3s ease;
}

.card-header-with-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.card-header-with-action h3 {
    margin: 0;
}

.history-content {
    animation: slideDown 0.3s ease;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-day-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    overflow: hidden;
    transition: all 0.2s ease;
}

.history-day-card:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 2px 8px rgba(124, 139, 240, 0.15);
}

.history-day-card.expanded {
    border-color: var(--accent-primary);
}

.day-summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    cursor: pointer;
}

.day-info h4 {
    margin: 0 0 6px 0;
    font-size: 15px;
    color: var(--text-primary);
    font-weight: 600;
}

.day-stats {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary);
}

.day-stats .calories {
    color: var(--accent-primary);
    font-weight: 600;
}

.day-stats .separator {
    color: var(--border-secondary);
}

.btn-view-details {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-view-details:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 139, 240, 0.3);
}

.expand-icon {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.history-day-card.expanded .expand-icon {
    transform: rotate(90deg);
}

.day-details {
    border-top: 1px solid var(--border-primary);
    animation: slideDown 0.3s ease;
}

.day-details-content {
    padding: 16px;
}

.details-header {
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-primary);
}

.details-total {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent-primary);
}

.food-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.food-item-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    transition: all 0.2s ease;
}

.food-item-row:hover {
    background: var(--bg-hover);
}

.food-item-name {
    flex: 1;
    font-weight: 600;
    color: var(--text-primary);
    margin-right: 12px;
}

.food-item-details {
    color: var(--text-secondary);
    font-size: 14px;
    margin-right: 12px;
}

.food-item-calories {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 14px;
    min-width: 80px;
    text-align: right;
}

.load-more-btn {
    width: 100%;
    margin-top: 16px;
    padding: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.load-more-btn:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        max-height: 500px;
        transform: translateY(0);
    }
}

/* ===================================================================
   FOOD LOG CRUD CONTROLS
   =================================================================== */

/* Details Header with Add Button */
.details-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border-color);
}

.details-total {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.btn-add-item {
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-add-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.4);
}

.btn-add-item:active {
    transform: translateY(0);
}

/* Editable Food Item Row */
.food-item-row.editable {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 8px;
    transition: all 0.2s ease;
}

.food-item-row.editable:hover {
    background: var(--hover-bg);
    border-color: var(--accent-primary);
    transform: translateX(4px);
}

.food-item-content {
    display: flex;
    gap: 16px;
    align-items: center;
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.food-item-name {
    font-weight: 600;
    color: var(--accent-primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.food-item-details {
    color: var(--text-secondary);
    font-size: 0.9rem;
    min-width: 80px;
}

.food-item-calories {
    color: var(--accent-secondary);
    font-weight: 600;
    min-width: 70px;
    text-align: right;
}

.food-item-actions {
    display: flex;
    gap: 6px;
    margin-left: 12px;
}

.btn-icon {
    background: transparent;
    border: none;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.btn-icon.btn-edit {
    color: var(--accent-primary);
}

.btn-icon.btn-edit:hover {
    background: rgba(108, 99, 255, 0.1);
    transform: scale(1.1);
}

.btn-icon.btn-delete {
    color: var(--accent-danger);
}

.btn-icon.btn-delete:hover {
    background: rgba(220, 53, 69, 0.1);
    transform: scale(1.1);
}

/* Edit/Add Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--modal-overlay);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
}

.modal-content,
.modal-content-edit,
.modal-content-confirm {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 28px;
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: modalSlideIn 0.3s ease;
    border: 1px solid var(--border-color);
}

.modal-content-confirm {
    max-width: 400px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.4rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 28px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.btn-close:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
    transform: rotate(90deg);
}

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

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 600;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 14px;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    transition: all 0.2s ease;
    font-family: inherit;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 4px rgba(108, 99, 255, 0.15);
    background: var(--bg-card);
}

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

.form-group input::placeholder {
    color: var(--text-tertiary);
    opacity: 0.7;
}

.form-hint {
    display: block;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.4;
}

/* Modal Actions */
.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.modal-actions .btn {
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.modal-actions .btn-primary {
    background: linear-gradient(135deg, var(--accent-primary) 0%, #8b82ff 100%);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(108, 99, 255, 0.3);
}

.modal-actions .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(108, 99, 255, 0.4);
}

.modal-actions .btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-color);
}

.modal-actions .btn-secondary:hover {
    background: var(--hover-bg);
    border-color: var(--accent-primary-light);
}

.btn-danger {
    background: var(--accent-danger);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: #c82333;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.btn-danger:active {
    transform: translateY(0);
}

/* Delete Confirmation Modal */
.modal-body {
    padding: 20px 0;
}

.modal-body p {
    margin: 0 0 12px 0;
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1.5;
}

.warning-text {
    color: var(--accent-warning);
    font-weight: 600;
    font-size: 0.9rem;
    font-style: italic;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    top: 10px;
    right: 10px;
    background: var(--accent-warning);
    color: var(--text-primary);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    z-index: 9999;
    display: none;
}

.offline-indicator.show {
    display: block;
}

/* Loading state for forms */
.form-loading {
    opacity: 0.6;
    pointer-events: none;
}

.form-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #667eea;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* Sync status */
.sync-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 8px;
}

.sync-status.synced {
    background: var(--msg-success-bg);
    color: var(--msg-success-text);
}

.sync-status.offline {
    background: var(--msg-warning-bg);
    color: var(--msg-warning-text);
}

.sync-status.syncing {
    background: var(--msg-info-bg);
    color: var(--msg-info-text);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.food-item {
    animation: fadeIn 0.3s ease;
}

/* ===============================================================================

   ADMIN PANEL STYLES

   =============================================================================== */

.admin-panel {
    margin-top: 30px;
    padding: 20px 0;
    border-top: 2px solid var(--border-secondary);
}

.admin-card {
    background: var(--bg-card);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--shadow-light);
    border-left: 4px solid var(--accent-danger);
}

.admin-card h2 {
    color: var(--accent-danger);
    margin-bottom: 20px;
    font-size: 24px;
    font-weight: 700;
}

/* Admin Navigation */
.admin-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.btn-admin {
    background: var(--accent-danger);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-admin:hover {
    background: var(--accent-primary);
    transform: translateY(-1px);
}

.btn-admin.active {
    background: var(--accent-primary);
}

/* Admin Sections */
.admin-section {
    display: none;
}

.admin-section.active {
    display: block;
}

.admin-section h3 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
}

/* Admin Statistics Grid */
.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.admin-stat {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border-primary);
}

.admin-stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-danger);
    margin-bottom: 5px;
}

.admin-stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Admin Tables */
.admin-table-container {
    overflow-x: auto;
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-light);
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
}

.admin-table th {
    background: var(--accent-danger);
    color: white;
    padding: 12px 15px;
    text-align: left;
    font-weight: 600;
    font-size: 14px;
}

.admin-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--border-secondary);
    font-size: 14px;
    color: var(--text-primary);
}

.admin-table tr:hover {
    background: var(--bg-hover);
}

.admin-table .loading {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 20px;
}

/* Inline Editing for Admin Table */
.editable-cell {
    position: relative;
    transition: all 0.2s ease;
    border-radius: 4px;
    padding: 12px 15px !important;
}

/* Only show edit cursor and hover when in edit mode */
.editable-cell[contenteditable="true"] {
    cursor: text;
}

.editable-cell[contenteditable="true"]:hover {
    background: var(--bg-secondary);
    outline: 1px solid var(--border-color);
}

.editable-cell[contenteditable="true"]:focus {
    outline: 2px solid var(--accent-primary);
    background: var(--bg-card);
    cursor: text;
}

.editable-cell.editing {
    background: #fffbf0;
    outline: 2px solid var(--accent-warning);
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.1);
}

.editable-cell.saving {
    background: #f0f8ff;
    outline: 2px solid var(--accent-info);
    opacity: 0.7;
    pointer-events: none;
}

.editable-cell.saved {
    background: #f0fff4;
    outline: 2px solid var(--accent-success);
    animation: savedPulse 1.5s ease;
}

@keyframes savedPulse {
    0%, 100% {
        background: var(--bg-card);
        outline-color: transparent;
    }
    50% {
        background: #f0fff4;
        outline-color: var(--accent-success);
    }
}

/* Action buttons styling */
.action-buttons {
    white-space: nowrap;
}

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

.btn-edit:hover {
    background: #8b82ff;
}

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

.btn-success:hover {
    background: #27ae60;
}

/* Remove the edit hint since we have explicit Edit button */
.editable-cell::after {
    display: none;
}

/* Admin Forms */
.admin-add-food {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid var(--border-primary);
}

.admin-add-food h4 {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 16px;
    font-weight: 600;
}

.admin-form-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.admin-form-row input,
.admin-form-row select {
    flex: 1;
    min-width: 150px;
    padding: 8px 12px;
    border: 1px solid var(--border-primary);
    border-radius: 4px;
    font-size: 14px;
    background: var(--bg-input);
    color: var(--text-primary);
}

.admin-form-row input:focus,
.admin-form-row select:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
}

/* Small Buttons */
.btn-small {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: 4px;
    margin-right: 5px;
}

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

.btn-danger:hover {
    background: #c82333;
}

/* ============================================================================
   MEAL CATEGORY & TIME STYLES
   ========================================================================== */

/* Food entry grid - clean and space-efficient */
.food-entry-grid {
    display: grid;
    grid-template-columns: 2fr 100px 120px 1.5fr 100px;
    gap: 10px;
    align-items: end;
    margin-bottom: 15px;
}

.food-entry-grid .input-group {
    margin-bottom: 0;
}

.food-entry-grid label {
    font-size: 0.85rem;
    margin-bottom: 4px;
    font-weight: 500;
}

.food-entry-grid input,
.food-entry-grid select {
    padding: 8px 10px;
    font-size: 14px;
}

/* Optional details collapsible */
.optional-details {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    padding: 0;
    margin-bottom: 15px;
}

.optional-details summary {
    padding: 10px 15px;
    cursor: pointer;
    font-weight: 600;
    color: var(--accent-primary);
    user-select: none;
    list-style: none;
    font-size: 14px;
}

.optional-details summary::-webkit-details-marker {
    display: none;
}

.optional-details[open] summary {
    border-bottom: 1px solid var(--border-primary);
}

.optional-details[open] summary::before {
    content: '− ';
}

.optional-details:not([open]) summary::before {
    content: '+ ';
}

.optional-details .form-row {
    padding: 15px;
    margin-bottom: 0;
}

/* Compact search controls */
.search-controls-compact {
    padding: 10px 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    border-top: 1px solid var(--border-primary);
}

.search-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 600;
}

.toggle-compact {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 13px;
    color: var(--text-primary);
}

.toggle-compact input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

/* Prominent add button */
.btn-add-food {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: 600;
}

.meal-info-row {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    border: 2px solid var(--border-primary);
}

.meal-info-row .input-group label {
    font-weight: 600;
    color: var(--text-primary);
}

/* Meal category badges */
.meal-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

.meal-badge.breakfast {
    background: #fff3cd;
    color: #856404;
}

.meal-badge.lunch {
    background: #cfe2ff;
    color: #084298;
}

.meal-badge.dinner {
    background: #ffe5d0;
    color: #bd5a00;
}

.meal-badge.snack {
    background: #d1e7dd;
    color: #0a3622;
}

.meal-badge.other {
    background: #e2e3e5;
    color: #41464b;
}

.meal-time {
    font-size: 13px;
    color: var(--text-secondary);
    margin-left: 8px;
}

/* ============================================================================
   WEIGHT TRACKING STYLES
   ========================================================================== */

.weight-content {
    margin-top: 20px;
}

.weight-log-form {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.weight-log-form h4 {
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 1.05rem;
}

/* Compact weight entry grid - matches food entry style */
.weight-entry-grid {
    display: grid;
    grid-template-columns: 140px 140px 1fr;
    gap: 10px;
    align-items: end;
    margin-bottom: 12px;
}

.weight-entry-grid .input-group {
    margin-bottom: 0;
}

.weight-entry-grid label {
    font-size: 0.85rem;
    margin-bottom: 4px;
    font-weight: 500;
}

.weight-entry-grid input {
    padding: 8px 10px;
    font-size: 14px;
}

.btn-log-weight {
    width: 100%;
    padding: 12px;
    font-size: 16px;
    font-weight: 600;
}

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

.stat-card {
    background: var(--bg-secondary);
    padding: 12px 10px;
    border-radius: 8px;
    text-align: center;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.stat-card .stat-value {
    font-size: 20px;
    font-weight: bold;
    color: var(--accent-primary);
}

.stat-card .stat-value.positive {
    color: var(--accent-danger);
}

.stat-card .stat-value.negative {
    color: var(--accent-success);
}

.stat-card .stat-value.neutral {
    color: var(--text-secondary);
}

.weight-chart-container {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
}

.weight-chart-container canvas {
    max-height: 280px;
}

.weight-history {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
}

.weight-history h4 {
    color: var(--text-primary);
    margin-bottom: 12px;
    font-size: 1.05rem;
}

.weight-history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.weight-entry {
    background: var(--bg-card);
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.weight-entry-main {
    flex: 1;
}

.weight-date {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.weight-value {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
}

.weight-change {
    font-size: 14px;
    font-weight: 600;
    margin-left: 10px;
}

.weight-change.positive {
    color: var(--accent-danger);
}

.weight-change.negative {
    color: var(--accent-success);
}

.weight-change.neutral {
    color: var(--text-secondary);
}

.weight-notes {
    width: 100%;
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 5px;
}

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

.btn-icon {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease, transform 0.2s ease;
    padding: 4px;
}

.btn-icon:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* Responsive Design */

/* Tablet breakpoint - optimize grid for medium screens */
@media (max-width: 1024px) {
    .food-entry-grid {
        grid-template-columns: 2fr 100px 120px;
        gap: 10px;
    }
    
    .food-entry-grid .input-group:nth-child(4),
    .food-entry-grid .input-group:nth-child(5) {
        grid-column: span 1;
    }
    
    .weight-entry-grid {
        grid-template-columns: 140px 140px 1fr;
        gap: 10px;
    }
}

/* Mobile breakpoint */
@media (max-width: 768px) {
    .header .container {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    /* Food entry grid responsive */
    .food-entry-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    /* Food name takes full width */
    .food-entry-grid .input-group:nth-child(1) {
        grid-column: span 2;
    }
    
    /* Grams and date share a row */
    .food-entry-grid .input-group:nth-child(2),
    .food-entry-grid .input-group:nth-child(3) {
        grid-column: span 1;
    }
    
    /* Meal and time share a row */
    .food-entry-grid .input-group:nth-child(4),
    .food-entry-grid .input-group:nth-child(5) {
        grid-column: span 1;
    }
    
    .food-entry-grid label {
        font-size: 0.8rem;
        margin-bottom: 3px;
    }
    
    .food-entry-grid input,
    .food-entry-grid select {
        padding: 8px;
        font-size: 14px;
    }
    
    /* Weight entry grid responsive - stack on mobile */
    .weight-entry-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }
    
    /* Notes field takes full width on mobile */
    .weight-entry-grid .input-group:nth-child(3) {
        grid-column: span 2;
    }
    
    .weight-entry-grid label {
        font-size: 0.8rem;
        margin-bottom: 3px;
    }
    
    .weight-entry-grid input {
        padding: 8px;
        font-size: 14px;
    }
    
    .optional-details .form-row {
        padding: 10px;
    }
    
    .search-controls-compact {
        padding: 10px;
        gap: 10px;
    }
    
    .meal-info-row {
        padding: 12px;
    }
    
    .stats-grid,
    .weight-stats {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 10px;
    }
    
    .weight-chart-container {
        padding: 12px;
    }
    
    .weight-chart-container canvas {
        max-height: 250px;
    }
    
    .weight-history {
        padding: 12px;
    }
    
    .weight-entry {
        flex-direction: column;
        align-items: flex-start;
        padding: 10px;
    }
    
    .food-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .food-calories {
        align-self: flex-end;
    }

    /* Responsive Admin Panel */
    .admin-nav {
        flex-direction: column;
    }
    
    .btn-admin {
        width: 100%;
    }
    
    .admin-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .admin-form-row {
        flex-direction: column;
    }
    
    .admin-form-row input,
    .admin-form-row select,
    .admin-form-row button {
        width: 100%;
    }
    
    .admin-table-container {
        font-size: 12px;
    }
    
    .admin-table th,
    .admin-table td {
        padding: 8px 6px;
    }
}

/* Footer Styles */
.app-footer {
    background: var(--bg-secondary);
    margin-top: 40px;
    padding: 30px 0;
    border-top: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
}

.footer-content {
    text-align: center;
    max-width: 800px;
    margin: 0 auto;
}

.data-sources {
    margin-bottom: 20px;
}

.data-sources h4 {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

.data-sources p {
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.6;
}

.data-sources a {
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.data-sources a:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

.footer-links {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
    color: var(--text-secondary);
    font-size: 14px;
}

.footer-links a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-links a:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

.footer-version {
    background: var(--bg-tertiary);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* Enhanced Food Suggestions Styles */
.suggestion-item.enhanced {
    padding: 16px 12px;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    position: relative;
    cursor: pointer;
}

.suggestion-item.enhanced:hover {
    border-left-color: var(--accent-primary);
    background: #f8f9ff;
    transform: translateX(2px);
}

.suggestion-item.enhanced.keyboard-selected {
    border-left-color: var(--accent-primary);
    background: #f0f8ff;
    transform: translateX(2px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.15);
}

.food-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.food-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    flex: 1;
    margin-right: 8px;
}

.food-name mark {
    background: var(--msg-warning-bg);
    color: var(--msg-warning-text);
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 700;
}

.food-source {
    font-size: 12px;
    color: var(--accent-primary);
    background: #e3f2fd;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.food-source[title*="Open Food Facts"] {
    background: #e8f5e8;
    color: #2e7d32;
}

.food-source[title*="Favorite"] {
    background: #fff9c4;
    color: #f57f17;
}

.food-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
    color: var(--text-secondary);
}

.food-calories {
    font-weight: 600;
    color: var(--accent-success);
}

.food-nutrition {
    font-family: monospace;
    font-size: 11px;
    color: var(--text-secondary);
}

.suggestion-item.loading {
    text-align: center;
    color: #667eea;
    font-style: italic;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.suggestion-item.no-results {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 20px;
}

.suggestion-item.error {
    text-align: center;
    color: #dc3545;
    background: #f8d7da;
    border-left-color: #dc3545;
    padding: 16px;
}

.suggestions-info {
    padding: 8px 12px;
    text-align: center;
    background: #f1f3f4;
    color: #6c757d;
    font-size: 11px;
    border-top: 1px solid #e9ecef;
}

/* Nutrition Preview Styles */
.nutrition-preview-container {
    margin-top: 10px;
    animation: slideDown 0.3s ease;
}

.nutrition-preview {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    border-radius: 8px;
    font-size: 14px;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.nutrition-preview strong {
    display: block;
    margin-bottom: 8px;
    font-size: 16px;
}

.nutrition-preview .macros {
    margin: 8px 0;
    font-family: monospace;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.1);
    padding: 6px 10px;
    border-radius: 4px;
}

.nutrition-preview .source {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 8px;
}

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

/* Mobile Responsiveness for Footer */
@media (max-width: 768px) {
    .app-footer {
        padding: 20px 0;
        margin-top: 20px;
    }
    
    .footer-content {
        padding: 0 20px;
    }
    
    .data-sources h4 {
        font-size: 16px;
    }
    
    .footer-links {
        gap: 10px;
        font-size: 13px;
    }
}

/* Card Header with Info Button */
.card-header-with-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-header-with-info h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 600;
}

.info-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.info-button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.info-icon {
    font-size: 14px;
}

.info-text {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Data Sources Modal Styles */
.data-sources-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: auto;
}

.data-sources-modal .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1;
    pointer-events: auto;
}

.data-sources-modal .modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    z-index: 2;
    pointer-events: auto;
}

.data-sources-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.data-sources-modal .modal-header h3 {
    margin: 0;
    font-size: 20px;
}

.data-sources-modal .modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s ease;
}

.data-sources-modal .modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.data-sources-modal .modal-body {
    padding: 25px;
}

.data-sources-modal .data-source {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #f1f3f4;
}

.data-sources-modal .data-source:last-of-type {
    border-bottom: none;
}

.data-sources-modal .data-source h4 {
    color: #495057;
    margin-bottom: 10px;
    font-size: 16px;
}

.data-sources-modal .data-source p {
    color: #6c757d;
    margin-bottom: 12px;
    line-height: 1.6;
}

.data-sources-modal .data-source ul {
    margin: 15px 0;
    padding-left: 0;
    list-style: none;
}

.data-sources-modal .data-source li {
    margin: 8px 0;
    padding-left: 20px;
    position: relative;
    color: #495057;
    line-height: 1.5;
}

.data-sources-modal .external-link {
    display: inline-block;
    margin-top: 10px;
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.data-sources-modal .external-link:hover {
    color: #764ba2;
}

.data-sources-modal .attribution-note {
    background: #f8f9fa;
    padding: 20px;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.data-sources-modal .attribution-note h4 {
    color: #495057;
    margin-bottom: 12px;
}

.data-sources-modal .attribution-note p {
    margin-bottom: 10px;
    line-height: 1.6;
}

.data-sources-modal .attribution-note a {
    color: #667eea;
}

/* Calorie Input Modal Styles */
.calorie-input-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    pointer-events: auto;
}

.calorie-input-modal .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 1;
    pointer-events: auto;
}

.calorie-input-modal .modal-content {
    background: white;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    z-index: 2;
    pointer-events: auto;
}

.calorie-input-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    border-radius: 12px 12px 0 0;
    color: white;
}

.calorie-input-modal .modal-header h3 {
    margin: 0;
    font-size: 1.25rem;
}

.calorie-input-modal .modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s ease;
}

.calorie-input-modal .modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.calorie-input-modal .modal-body {
    padding: 25px;
}

.calorie-input-modal .food-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #f5576c;
}

.calorie-input-modal .food-info .food-name {
    font-weight: 600;
    color: #495057;
    margin-bottom: 5px;
}

.calorie-input-modal .food-info .food-unit {
    color: #6c757d;
    font-size: 0.9rem;
}

.calorie-input-modal .input-group {
    margin-bottom: 20px;
}

.calorie-input-modal .input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #495057;
}

.calorie-input-modal .input-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.calorie-input-modal .input-group input:focus {
    outline: none;
    border-color: #f5576c;
    box-shadow: 0 0 0 3px rgba(245, 87, 108, 0.1);
}

.calorie-input-modal .input-group input.error {
    border-color: #dc3545;
}

.calorie-input-modal .error-message {
    color: #dc3545;
    font-size: 0.85rem;
    margin-top: 5px;
    display: none;
}

.calorie-input-modal .error-message.show {
    display: block;
}

.calorie-input-modal .modal-actions {
    display: flex;
    justify-content: space-between;
    gap: 15px;
}

.calorie-input-modal .btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.calorie-input-modal .btn-cancel {
    background: #6c757d;
    color: white;
}

.calorie-input-modal .btn-cancel:hover {
    background: #5a6268;
}

.calorie-input-modal .btn-confirm {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
}

.calorie-input-modal .btn-confirm:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(245, 87, 108, 0.3);
}

.calorie-input-modal .btn-confirm:disabled {
    background: #e9ecef;
    color: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ===============================================================================
   DATABASE SEARCH TOGGLES
   =============================================================================== */

.search-controls {
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    padding: 16px;
    margin: 20px 0;
    transition: all 0.3s ease;
}

.search-controls-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
}

.search-controls-title {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.info-button-small {
    background: var(--accent-primary);
    border: none;
    color: white;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 11px;
    font-weight: bold;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.info-button-small:hover {
    background: var(--accent-primary-hover);
    transform: scale(1.1);
}

.info-icon-small {
    font-size: 10px;
}

.toggle-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.toggle-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 6px;
    background: var(--bg-card);
    border: 2px solid var(--border-secondary);
    transition: all 0.2s ease;
    user-select: none;
}

.toggle-item:hover {
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px var(--shadow-light);
}

.toggle-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    accent-color: var(--accent-primary);
    cursor: pointer;
}

.toggle-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    flex: 1;
}

.toggle-icon {
    font-size: 16px;
    line-height: 1;
}

.toggle-text {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
}

/* Active/checked state */
.toggle-item:has(input:checked) {
    border-color: var(--accent-primary);
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

.toggle-item:has(input:checked) .toggle-text {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Disabled state */
.toggle-item:has(input:disabled) {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--bg-secondary);
}

.toggle-item:has(input:disabled):hover {
    transform: none;
    box-shadow: none;
    border-color: var(--border-secondary);
}

/* Dark theme adjustments */
[data-theme="dark"] .search-controls {
    background: var(--bg-input);
    border-color: var(--border-secondary);
}

[data-theme="dark"] .toggle-item {
    background: var(--bg-secondary);
    border-color: var(--border-primary);
}

[data-theme="dark"] .toggle-item:hover {
    border-color: var(--accent-primary);
    background: var(--bg-hover);
}

[data-theme="dark"] .toggle-item:has(input:checked) {
    background: linear-gradient(135deg, rgba(124, 139, 240, 0.1) 0%, rgba(139, 91, 166, 0.1) 100%);
}

/* Dark mode - Food Suggestions Dropdown */
[data-theme="dark"] .food-name {
    color: var(--accent-primary); /* Use the blue accent color */
}

[data-theme="dark"] .food-name mark {
    background: rgba(124, 139, 240, 0.2);
    color: var(--accent-primary);
}

[data-theme="dark"] .food-source {
    background: rgba(124, 139, 240, 0.15);
    color: var(--accent-primary);
}

[data-theme="dark"] .food-source[title*="Open Food Facts"] {
    background: rgba(76, 175, 80, 0.15);
    color: #81c784;
}

[data-theme="dark"] .food-source[title*="Favorite"] {
    background: rgba(255, 193, 7, 0.15);
    color: #ffd54f;
}

[data-theme="dark"] .food-details {
    color: var(--text-secondary);
}

[data-theme="dark"] .food-calories {
    color: #81c784;
}

[data-theme="dark"] .suggestion-item.enhanced:hover {
    background: rgba(124, 139, 240, 0.1);
    border-left-color: var(--accent-primary);
}

[data-theme="dark"] .suggestion-item.enhanced.keyboard-selected {
    background: rgba(124, 139, 240, 0.15);
    border-left-color: var(--accent-primary);
    box-shadow: 0 2px 8px rgba(124, 139, 240, 0.3);
}

[data-theme="dark"] .suggestions-info {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-top-color: var(--border-primary);
}

/* Dark mode: Editable cells */
[data-theme="dark"] .editable-cell.editing {
    background: #2a2a2a;
    outline: 2px solid var(--accent-warning);
    box-shadow: 0 0 0 3px rgba(255, 193, 7, 0.1);
}

[data-theme="dark"] .editable-cell.saving {
    background: #1a2332;
    outline: 2px solid var(--accent-info);
}

[data-theme="dark"] .editable-cell.saved {
    background: #1a2e1f;
    outline: 2px solid var(--accent-success);
}

/* Mobile responsiveness */
@media (max-width: 768px) {
    .toggle-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .toggle-item {
        padding: 6px 10px;
    }
    
    .toggle-text {
        font-size: 12px;
    }
    
    .toggle-icon {
        font-size: 14px;
    }
}

@media (max-width: 480px) {
    .toggle-grid {
        grid-template-columns: 1fr;
    }
    
    .search-controls {
        padding: 12px;
    }
}

/* =============================================================================
   DATABASE MANAGEMENT STYLES
   ============================================================================= */

.database-stats {
    margin-bottom: 30px;
}

.sql-query-section {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
}

.query-input-container {
    margin-bottom: 15px;
}

#sqlQuery {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    resize: vertical;
    background: var(--bg-input);
    color: var(--text-primary);
}

.query-buttons {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.query-results {
    margin-top: 20px;
}

.query-meta {
    background: var(--bg-secondary);
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}

.results-table-container {
    max-height: 400px;
    overflow: auto;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.results-table th {
    background: var(--bg-secondary);
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-primary);
    position: sticky;
    top: 0;
    font-weight: 600;
}

.results-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-secondary);
    max-width: 200px;
    word-wrap: break-word;
}

.results-table tr:hover {
    background: var(--bg-hover);
}

.database-tables-section {
    margin-top: 30px;
}

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

#tableBrowserModal .modal-content {
    background: var(--bg-card);
    border-radius: 12px;
    width: 90%;
    max-width: 1000px;
    max-height: 90%;
    overflow: auto;
    box-shadow: 0 10px 30px var(--shadow-heavy);
}

#tableBrowserModal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-primary);
}

#tableBrowserModal .modal-body {
    padding: 30px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    color: var(--text-primary);
}

.table-structure {
    margin-bottom: 30px;
}

.structure-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

.structure-table th,
.structure-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-secondary);
}

.structure-table th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.structure-table code {
    background: var(--bg-secondary);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
}

.data-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    gap: 15px;
}

#tableSearchInput {
    flex: 1;
    max-width: 300px;
    padding: 8px 12px;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    font-size: 14px;
}

#tablePagination {
    font-size: 14px;
    color: var(--text-secondary);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    overflow: hidden;
}

.data-table th {
    background: var(--bg-secondary);
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    border-bottom: 1px solid var(--border-primary);
}

.data-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-secondary);
    max-width: 150px;
    word-wrap: break-word;
    font-size: 13px;
}

.data-table tr:hover {
    background: var(--bg-hover);
}

.data-table em {
    color: var(--text-light);
    font-style: italic;
}

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

.structure-modal {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 30px;
    max-width: 800px;
    width: 90%;
    max-height: 80%;
    overflow: auto;
    box-shadow: 0 10px 30px var(--shadow-heavy);
}

.structure-modal h4 {
    margin: 0 0 20px 0;
    color: var(--text-primary);
}

.structure-modal .btn {
    margin-top: 20px;
}

/* Loading and error states */
.loading {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    font-style: italic;
}

.error {
    background: var(--msg-error-bg);
    color: var(--msg-error-text);
    border: 1px solid var(--msg-error-border);
    padding: 12px;
    border-radius: 6px;
    margin: 10px 0;
}

.no-data {
    text-align: center;
    padding: 20px;
    color: var(--text-light);
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    #tableBrowserModal .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    #tableBrowserModal .modal-body {
        padding: 20px;
    }
    
    .data-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    #tableSearchInput {
        max-width: none;
        margin-bottom: 10px;
    }
    
    .results-table,
    .data-table,
    .structure-table {
        font-size: 12px;
    }
    
    .results-table td,
    .data-table td,
    .structure-table td {
        max-width: 100px;
        padding: 6px 8px;
    }
}

/* =============================================================================
   CONFIRMATION MODAL
   ============================================================================= */

.confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
    pointer-events: auto;
}

.confirmation-modal .modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1;
    pointer-events: auto;
}

.confirmation-modal-content {
    position: relative;
    background: var(--bg-primary);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    width: 90%;
    animation: slideIn 0.3s ease;
    z-index: 2;
    pointer-events: auto;
}

.confirmation-modal-header {
    padding: 24px 24px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-primary);
}

.confirmation-icon {
    font-size: 32px;
    line-height: 1;
}

.confirmation-modal-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.confirmation-modal-body {
    padding: 24px;
}

.confirmation-modal-body p {
    margin: 0;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.6;
}

.confirmation-modal-footer {
    padding: 16px 24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid var(--border-primary);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* =============================================================================
   BULK ACTIONS TOOLBAR
   ============================================================================= */

.bulk-actions-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    animation: slideDown 0.3s ease;
}

.selected-count {
    font-weight: 600;
    font-size: 15px;
}

.bulk-actions-toolbar .btn {
    margin: 0;
}

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

/* =============================================================================
   SORTABLE TABLE COLUMNS
   ============================================================================= */

.admin-table th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background 0.2s ease;
}

.admin-table th.sortable:hover {
    background: var(--bg-hover);
}

.admin-table th.sortable:active {
    transform: scale(0.98);
}

.sort-indicator {
    display: inline-block;
    margin-left: 4px;
    font-weight: bold;
    color: var(--accent-primary);
    min-width: 12px;
}

/* =============================================================================
   CHECKBOX COLUMN
   ============================================================================= */

.admin-table .checkbox-column {
    width: 40px;
    text-align: center;
    padding: 8px !important;
}

.admin-table input[type="checkbox"] {
    cursor: pointer;
    width: 18px;
    height: 18px;
    accent-color: var(--accent-primary);
}

.admin-table input[type="checkbox"]:hover {
    transform: scale(1.1);
}

.admin-table .empty {
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
    padding: 40px 20px;
    font-size: 15px;
}

/* =============================================================================
   RESPONSIVE BULK ACTIONS
   ============================================================================= */

@media (max-width: 768px) {
    .bulk-actions-toolbar {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .bulk-actions-toolbar .btn {
        width: 100%;
    }
    
    .confirmation-modal-content {
        width: 95%;
        margin: 0 10px;
    }
    
    .confirmation-modal-footer {
        flex-direction: column-reverse;
    }
    
    .confirmation-modal-footer .btn {
        width: 100%;
    }
    
    /* CRUD Controls Mobile Responsive */
    .food-item-content {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .food-item-name {
        flex-basis: 100%;
    }
    
    .food-item-actions {
        width: 100%;
        justify-content: flex-end;
        margin-left: 0;
        margin-top: 4px;
    }
    
    .btn-icon {
        padding: 8px 12px;
        font-size: 1.1rem;
    }
    
    .modal-content-edit,
    .modal-content-confirm {
        width: 95%;
        padding: 20px;
        margin: 10px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .modal-actions {
        flex-direction: column-reverse;
        gap: 8px;
    }
    
    .modal-actions .btn {
        width: 100%;
    }
    
    .details-header {
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
    }
    
    .btn-add-item {
        width: 100%;
        justify-content: center;
    }
}

/* =============================================================================
   TOAST NOTIFICATION SYSTEM
   ============================================================================= */

/* Toast Container - Fixed position top-right */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    max-width: 400px;
    width: 100%;
    pointer-events: none;
}

/* Individual Toast */
.toast {
    background: var(--bg-card);
    border-radius: 8px;
    box-shadow: 0 4px 12px var(--shadow-medium);
    margin-bottom: 12px;
    padding: 16px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    pointer-events: all;
    transform: translateX(100%);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-left: 4px solid;
    position: relative;
    overflow: hidden;
}

/* Toast Animations */
.toast.show {
    transform: translateX(0);
    opacity: 1;
}

.toast.hide {
    transform: translateX(100%);
    opacity: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    max-height: 0;
}

/* Toast Types */
.toast.success {
    border-left-color: var(--accent-success);
}

.toast.error {
    border-left-color: var(--accent-danger);
}

.toast.warning {
    border-left-color: var(--accent-warning);
}

.toast.info {
    border-left-color: var(--accent-info);
}

/* Toast Icon */
.toast-icon {
    font-size: 20px;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast.success .toast-icon {
    color: var(--accent-success);
}

.toast.error .toast-icon {
    color: var(--accent-danger);
}

.toast.warning .toast-icon {
    color: var(--accent-warning);
}

.toast.info .toast-icon {
    color: var(--accent-info);
}

/* Toast Content */
.toast-content {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.4;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.toast-message {
    font-size: 13px;
    line-height: 1.4;
    color: var(--text-secondary);
    word-wrap: break-word;
}

/* Toast Close Button */
.toast-close {
    background: none;
    border: none;
    font-size: 18px;
    line-height: 1;
    color: var(--text-light);
    cursor: pointer;
    padding: 2px;
    margin: -2px;
    flex-shrink: 0;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.toast-close:hover {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

/* Progress Bar for Auto-dismiss */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--border-primary);
    border-radius: 0 0 8px 8px;
    transform-origin: left;
    animation: toast-progress var(--duration, 4s) linear forwards;
}

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

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

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

.toast.info .toast-progress {
    background: var(--accent-info);
}

@keyframes toast-progress {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}

/* Pause progress on hover */
.toast:hover .toast-progress {
    animation-play-state: paused;
}

/* =============================================================================
   LOADING STATES
   ============================================================================= */

/* Button Loading State */
.btn.loading {
    position: relative;
    color: transparent !important;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: btn-spin 1s linear infinite;
    color: inherit;
}

@keyframes btn-spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Form Loading Overlay */
.form-loading {
    position: relative;
}

.form-loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
    z-index: 10;
}

/* =============================================================================
   FORM VALIDATION FEEDBACK
   ============================================================================= */

/* Invalid Field Styling */
.form-field.invalid input,
.form-field.invalid select,
.form-field.invalid textarea {
    border-color: var(--accent-danger);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.form-field.invalid input:focus,
.form-field.invalid select:focus,
.form-field.invalid textarea:focus {
    border-color: var(--accent-danger);
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.2);
}

/* Field Error Message */
.field-error {
    display: block;
    color: var(--accent-danger);
    font-size: 12px;
    margin-top: 4px;
    line-height: 1.3;
    font-weight: 500;
}

/* Hide error when field is valid */
.form-field:not(.invalid) .field-error {
    display: none;
}

/* Mobile Responsive Toast */
@media (max-width: 768px) {
    .toast-container {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
    }
    
    .toast {
        margin-bottom: 8px;
        padding: 12px;
    }
    
    .toast-title {
        font-size: 13px;
    }
    
    .toast-message {
        font-size: 12px;
    }
}

/* =============================================================================
   USER CONTRIBUTIONS DASHBOARD STYLES
   ============================================================================= */

.contributions-stats {
    margin-bottom: 30px;
}

.contributions-stats h4 {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

.top-contributors {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
}

.top-contributors h4 {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 18px;
    font-weight: 600;
}

.contributors-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.contributor-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    transition: all 0.2s ease;
}

.contributor-item:hover {
    background: var(--bg-tertiary);
    transform: translateX(4px);
}

.contributor-rank {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-secondary);
    min-width: 30px;
}

.contributor-info {
    flex: 1;
    margin-left: 15px;
}

.contributor-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 15px;
}

.contributor-stats {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* ============================================================================
   SEARCH AND FILTER CONTROLS
   ========================================================================== */

.search-filter-controls {
    margin-bottom: 20px;
}

.search-box {
    position: relative;
    width: 100%;
    max-width: 600px;
    margin-bottom: 15px;
}

.search-box input[type="text"] {
    width: 100%;
    padding: 12px 40px 12px 16px;
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.3s ease;
}

.search-box input[type="text"]:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-box input[type="text"]::placeholder {
    color: var(--text-light);
}

.btn-clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-secondary);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 16px;
    transition: all 0.2s ease;
    padding: 0;
}

.btn-clear-search:hover {
    background: var(--accent-danger);
    color: white;
    transform: translateY(-50%) scale(1.1);
}

.contributions-controls {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
}

.contributions-controls .search-box {
    max-width: 100%;
    margin-bottom: 15px;
}

.filter-controls-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.contributions-controls {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

.filter-group select,
.filter-group input[type="number"] {
    padding: 8px 12px;
    border: 1px solid var(--border-primary);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
}

.filter-group input[type="number"] {
    width: 80px;
}

.user-foods-container {
    background: var(--bg-card);
    border: 1px solid var(--border-primary);
    border-radius: 12px;
    padding: 20px;
}

.user-foods-container h4 {
    color: var(--text-primary);
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 600;
}

.user-foods-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.user-food-item {
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 12px;
    padding: 18px;
    transition: all 0.3s ease;
}

.user-food-item:hover {
    border-color: var(--accent-primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.user-food-item.popular {
    border-color: var(--accent-warning);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(255, 193, 7, 0.05) 100%);
}

.user-food-item.very-popular {
    border-color: var(--accent-success);
    background: linear-gradient(135deg, var(--bg-secondary) 0%, rgba(76, 175, 80, 0.05) 100%);
}

.user-food-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.user-food-title {
    flex: 1;
}

.user-food-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.user-food-meta {
    font-size: 14px;
    color: var(--text-secondary);
}

.user-food-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-new {
    background: var(--accent-info-bg);
    color: var(--accent-info);
}

.badge-used {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge-popular {
    background: rgba(255, 193, 7, 0.15);
    color: #f57c00;
}

.badge-very-popular {
    background: var(--accent-success-bg);
    color: var(--accent-success);
}

.user-food-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 15px;
}

.detail-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.detail-label {
    font-size: 13px;
    color: var(--text-secondary);
}

.detail-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-food-stats {
    display: flex;
    gap: 20px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: 8px;
    margin-bottom: 15px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--text-secondary);
}

.stat-item strong {
    color: var(--text-primary);
    font-size: 16px;
}

.user-food-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.user-food-actions .btn {
    font-size: 13px;
    padding: 6px 14px;
}

.pagination-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--border-primary);
}

.pagination-info {
    font-size: 14px;
    color: var(--text-secondary);
}

.pagination-controls .btn {
    min-width: 120px;
}

/* Promotion Modal Styles */
.promote-modal {
    max-width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

.promote-modal .modal-body {
    padding: 25px;
}

.form-section {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-primary);
}

.form-section:last-of-type {
    border-bottom: none;
}

.form-section h4 {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
}

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

.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    transition: border-color 0.2s ease;
}

.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.contribution-info {
    background: var(--bg-secondary);
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.contribution-info p {
    margin: 8px 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.contribution-info strong {
    color: var(--text-primary);
}

/* Mobile Responsiveness for Contributions */
@media (max-width: 768px) {
    .search-box {
        max-width: 100%;
    }
    
    .search-box input[type="text"] {
        font-size: 14px;
        padding: 10px 36px 10px 12px;
    }
    
    .contributions-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-controls-row {
        flex-direction: column;
    }
    
    .filter-group {
        flex-direction: column;
        align-items: stretch;
    }
    
    .filter-group select,
    .filter-group input {
        width: 100%;
    }
    
    .user-food-details {
        grid-template-columns: 1fr;
    }
    
    .user-food-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .user-food-stats {
        flex-direction: column;
        gap: 10px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .pagination-controls {
        flex-direction: column;
        gap: 15px;
    }
    
    .pagination-controls .btn {
        width: 100%;
    }
}

/* ============================================================================
   REWARDS & GAMIFICATION SYSTEM STYLES
   ========================================================================== */

/* Header Rewards Display */
.rewards-display {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-right: 15px;
}

.points-badge,
.milestone-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    transition: all 0.3s ease;
}

.points-badge:hover,
.milestone-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow-light);
}

.points-badge {
    background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
    color: #000;
    border-color: #ffa500;
}

.milestone-badge.food-milestone {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.milestone-badge.weight-milestone {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.multiplier {
    font-size: 0.75rem;
    opacity: 0.8;
    margin-left: 2px;
}

/* Rewards Card */
.rewards-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 15px var(--shadow-light);
}

.rewards-summary {
    margin-bottom: 15px;
}

.rewards-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-bottom: 15px;
}

.reward-stat {
    text-align: center;
    padding: 15px 10px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.reward-stat-value {
    font-size: 1.75rem;
    font-weight: bold;
    color: var(--accent-primary);
}

.reward-stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.btn-reward {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    font-weight: 600;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-reward:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.btn-reward:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Rewards Details */
.rewards-details {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--border-primary);
    animation: slideDown 0.3s ease;
}

.milestone-progress-section {
    margin-bottom: 20px;
}

.milestone-progress-section h4 {
    color: var(--text-primary);
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.milestone-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 15px;
    border: 2px solid var(--border-primary);
}

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

.milestone-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.milestone-icon {
    font-size: 1.3rem;
}

.milestone-multiplier {
    font-size: 0.9rem;
    color: var(--accent-primary);
    font-weight: 600;
}

.milestone-info {
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.milestone-progress-bar {
    height: 12px;
    background: var(--bg-primary);
    border-radius: 6px;
    overflow: hidden;
    margin-bottom: 8px;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    transition: width 0.3s ease;
    border-radius: 6px;
}

.milestone-next {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}

/* Rewards Quick Links */
.rewards-quick-links {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 15px;
}

.btn-outline {
    padding: 10px;
    background: transparent;
    border: 2px solid var(--border-primary);
    color: var(--text-primary);
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.btn-outline:hover {
    background: var(--bg-secondary);
    border-color: var(--accent-primary);
    color: var(--accent-primary);
    transform: translateY(-2px);
}

/* Coming Soon Badge */
.coming-soon-badge {
    position: absolute;
    top: -8px;
    right: -8px;
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    color: #333;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
    animation: pulse-badge 2s ease-in-out infinite;
}

@keyframes pulse-badge {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(255, 215, 0, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 4px 12px rgba(255, 215, 0, 0.6);
    }
}

.coming-soon-btn {
    position: relative;
    overflow: visible;
}

.coming-soon-btn:hover .coming-soon-badge {
    animation: none;
    transform: scale(1.1);
}

/* Rewards Shop */
.modal-content-large {
    background: var(--bg-card);
    border-radius: 12px;
    max-width: 900px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px var(--shadow-heavy);
}

.shop-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 20px;
}

.shop-balance {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.shop-filters {
    display: flex;
    gap: 8px;
}

.filter-btn {
    padding: 6px 12px;
    border: 2px solid var(--border-primary);
    background: transparent;
    color: var(--text-primary);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.filter-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.filter-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

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

.shop-item {
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    padding: 15px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.shop-item:hover {
    border-color: var(--accent-primary);
    transform: translateY(-4px);
    box-shadow: 0 6px 20px var(--shadow-medium);
}

.shop-item.owned {
    border-color: var(--accent-success);
    opacity: 0.7;
}

.shop-item.locked {
    opacity: 0.5;
    cursor: not-allowed;
}

.shop-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.shop-item-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 5px;
}

.shop-item-category {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.shop-item-cost {
    background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
    color: #000;
    padding: 4px 10px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
}

.shop-item-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.4;
}

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

.shop-item-level {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.shop-item-status {
    font-size: 0.85rem;
    font-weight: 600;
}

.shop-item-status.owned {
    color: var(--accent-success);
}

.shop-item-status.locked {
    color: var(--accent-danger);
}

.shop-item-status.available {
    color: var(--accent-primary);
}

/* Leaderboard */
.leaderboard-table {
    width: 100%;
}

.leaderboard-table table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-primary);
}

.leaderboard-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

.leaderboard-table tr:hover {
    background: var(--bg-hover);
}

.leaderboard-table tr.my-rank {
    background: var(--accent-primary);
    color: white;
    font-weight: 600;
}

.leaderboard-table tr.my-rank td {
    color: white;
}

.leaderboard-rank {
    font-weight: 700;
    font-size: 1.1rem;
}

.leaderboard-rank.rank-1 {
    color: #ffd700;
}

.leaderboard-rank.rank-2 {
    color: #c0c0c0;
}

.leaderboard-rank.rank-3 {
    color: #cd7f32;
}

/* Achievements */
.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.achievement-item {
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    transition: all 0.3s ease;
}

.achievement-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px var(--shadow-medium);
}

.achievement-item.locked {
    opacity: 0.4;
    filter: grayscale(100%);
}

.achievement-icon {
    font-size: 3rem;
    margin-bottom: 10px;
}

.achievement-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 5px;
}

.achievement-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.achievement-points {
    color: var(--accent-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.achievement-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 5px;
}

/* Points Earned Toast Notification */
.points-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    min-width: 200px;
    transform: translateX(400px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.points-toast.show {
    transform: translateX(0);
    opacity: 1;
}

.points-toast-header {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 5px;
}

.points-toast-details {
    font-size: 0.9rem;
    opacity: 0.9;
}

.points-toast-breakdown {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
}

.points-toast-item {
    font-size: 0.85rem;
    margin: 3px 0;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

/* Milestone Level-Up Animation */
.level-up-celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    z-index: 10001;
    text-align: center;
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}

.level-up-celebration.show {
    transform: translate(-50%, -50%) scale(1);
    opacity: 1;
}

.level-up-icon {
    font-size: 4rem;
    margin-bottom: 15px;
    animation: bounce 0.5s ease infinite alternate;
}

.level-up-title {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.level-up-message {
    font-size: 1.2rem;
    margin-bottom: 15px;
}

.level-up-bonus {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffd700;
    margin-bottom: 10px;
}

.level-up-multiplier {
    font-size: 1.1rem;
    font-weight: 600;
    color: #90EE90;
    margin-top: 5px;
}

@keyframes celebrationPop {
    0% {
        transform: translate(-50%, -50%) scale(0);
        opacity: 0;
    }
    100% {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

@keyframes bounce {
    from {
        transform: translateY(0);
    }
    to {
        transform: translateY(-10px);
    }
}

/* Responsive Rewards */
@media (max-width: 768px) {
    .rewards-display {
        display: none; /* Show simplified version on mobile */
    }
    
    .rewards-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .rewards-quick-links {
        grid-template-columns: 1fr;
    }
    
    .shop-header {
        flex-direction: column;
        gap: 10px;
    }
    
    .shop-filters {
        flex-wrap: wrap;
    }
    
    .shop-items-grid {
        grid-template-columns: 1fr;
    }
    
    .achievements-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .points-toast {
        top: 60px;
        right: 10px;
        left: 10px;
        min-width: auto;
    }
}

/* ============================================================================
   SHOP ENHANCEMENTS
   ============================================================================ */

.shop-item-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

.shop-item-info {
    flex: 1;
}

.shop-item-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.status-badge {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-block;
}

.status-badge.owned {
    background: var(--accent-success);
    color: white;
}

.status-badge.locked {
    background: var(--accent-danger);
    color: white;
}

.status-badge.insufficient {
    background: var(--accent-warning);
    color: var(--text-primary);
}

.level-req {
    padding: 2px 8px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.shop-item.insufficient-points {
    opacity: 0.6;
}

.shop-item.insufficient-points:hover {
    transform: none;
    border-color: var(--border-primary);
}

.cost-amount {
    font-weight: 700;
    font-size: 1.1rem;
}

/* ============================================================================
   LEADERBOARD ENHANCEMENTS
   ============================================================================ */

.leaderboard-rank {
    font-weight: 700;
    text-align: center !important;
}

.leaderboard-rank.rank-1 {
    color: #FFD700;
    font-size: 1.2rem;
}

.leaderboard-rank.rank-2 {
    color: #C0C0C0;
    font-size: 1.1rem;
}

.leaderboard-rank.rank-3 {
    color: #CD7F32;
    font-size: 1.1rem;
}

.leaderboard-username {
    font-weight: 600;
}

.you-badge {
    background: var(--accent-primary);
    color: white;
    padding: 2px 6px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 6px;
}

.leaderboard-table tr.my-rank {
    background: var(--bg-hover);
    border-left: 3px solid var(--accent-primary);
}

.leaderboard-points,
.leaderboard-lifetime,
.leaderboard-level,
.leaderboard-streak {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* ============================================================================
   ACHIEVEMENTS ENHANCEMENTS
   ============================================================================ */

.achievements-summary {
    text-align: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
    border-radius: 12px;
    margin-bottom: 20px;
    color: white;
}

.achievements-summary h4 {
    margin: 0;
    font-size: 1.5rem;
}

.achievements-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.achievement-item {
    background: var(--bg-secondary);
    border: 2px solid var(--border-primary);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    gap: 15px;
    align-items: flex-start;
    transition: all 0.3s ease;
}

.achievement-item.unlocked {
    border-color: var(--accent-success);
}

.achievement-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 6px 20px var(--shadow-medium);
}

.achievement-icon {
    font-size: 3rem;
    min-width: 60px;
    text-align: center;
}

.achievement-details {
    flex: 1;
}

.achievement-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 8px 0;
}

.achievement-description {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0 0 12px 0;
    line-height: 1.4;
}

.achievement-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.achievement-points {
    background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
    color: #000;
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
}

.achievement-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================================================
   UTILITY CLASSES
   ============================================================================ */

.loading {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
    font-style: italic;
}

.error {
    text-align: center;
    padding: 40px 20px;
    color: var(--accent-danger);
    font-weight: 600;
}

.no-data,
.no-items {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-style: italic;
}

/* ============================================================================
   USER MANAGEMENT MODALS (Create User & Change Password)
   ============================================================================ */

/* Admin section header with button */
.admin-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.admin-section-header h3 {
    margin: 0;
}

/* Form groups for user management */
#createUserForm .form-group,
#changePasswordForm .form-group,
#adminChangePasswordForm .form-group,
#editUserForm .form-group {
    margin-bottom: 1.25rem;
}

#createUserForm label,
#changePasswordForm label,
#adminChangePasswordForm label,
#editUserForm label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.required {
    color: var(--accent-danger);
}

#createUserForm input,
#changePasswordForm input,
#adminChangePasswordForm input,
#editUserForm input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-primary);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.2s;
    background: var(--bg-input);
    color: var(--text-primary);
}

#createUserForm input:focus,
#changePasswordForm input:focus,
#adminChangePasswordForm input:focus,
#editUserForm input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

#createUserForm input.error,
#changePasswordForm input.error,
#adminChangePasswordForm input.error,
#editUserForm input.error {
    border-color: var(--accent-danger);
}

.error-message {
    display: block;
    color: var(--accent-danger);
    font-size: 0.875rem;
    font-weight: 500;
    margin-top: 0.25rem;
    min-height: 1rem;
}

.help-text {
    display: block;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Password input wrapper for toggle button */
.password-input-wrapper {
    position: relative;
}

.password-input-wrapper input {
    padding-right: 3rem;
}

.toggle-password {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.toggle-password:hover {
    opacity: 1;
}

/* Password requirements checklist */
.password-requirements {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border-primary);
    margin-top: 1rem;
}

.requirements-title {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
}

.password-requirements ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.password-requirements li {
    padding: 0.25rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.password-requirements li::before {
    content: '○';
    font-size: 1rem;
    color: var(--text-secondary);
}

.password-requirements li.met {
    color: var(--accent-success);
    font-weight: 500;
}

.password-requirements li.met::before {
    content: '✓';
    color: var(--accent-success);
    font-weight: 700;
}

/* Form actions */
.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border-primary);
}

.form-actions .btn {
    flex: 1;
    padding: 0.875rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.form-actions .btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border-primary);
}

.form-actions .btn-secondary:hover:not(:disabled) {
    background: var(--bg-hover);
}

.form-actions .btn-primary {
    background: var(--bg-gradient);
    color: white;
    border: none;
}

.form-actions .btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.form-actions .btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Modal description text */
.modal-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
}

/* Success message animation */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.success-message {
    padding: 1rem;
    background: #d1fae5;
    border: 2px solid var(--accent-success);
    border-radius: 8px;
    color: #065f46;
    font-weight: 600;
    margin-bottom: 1.5rem;
    animation: slideDown 0.3s ease-out;
}

/* Dark mode specific overrides */
[data-theme="dark"] #createUserForm input,
[data-theme="dark"] #changePasswordForm input,
[data-theme="dark"] #adminChangePasswordForm input,
[data-theme="dark"] #editUserForm input {
    background: var(--bg-input);
    color: var(--text-primary);
    border-color: var(--border-primary);
}

[data-theme="dark"] .coming-soon-badge {
    background: linear-gradient(135deg, #ffd700 0%, #ffaa00 100%);
    color: #1a1a1a;
    box-shadow: 0 2px 8px rgba(255, 215, 0, 0.5);
}

[data-theme="dark"] .goal-input {
    background: var(--bg-secondary);
    color: var(--accent-primary);
    border-color: var(--accent-primary);
}

[data-theme="dark"] .goal-input:focus {
    background: var(--bg-card);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

[data-theme="dark"] .password-requirements {
    background: var(--bg-secondary);
}

[data-theme="dark"] .success-message {
    background: rgba(16, 185, 129, 0.2);
    color: var(--accent-success);
    border-color: var(--accent-success);
}

/* =============================================================================
   CONTACT/SUPPORT BUTTON
   ============================================================================= */

.contact-button {
    position: fixed;
    bottom: 24px;
    left: 24px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--accent-info));
    color: white;
    text-decoration: none;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    font-size: 15px;
    font-weight: 600;
    transition: all 0.3s ease;
    z-index: 999;
    cursor: pointer;
}

.contact-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #5a7ae0, var(--primary-color));
}

.contact-button:active {
    transform: translateY(0);
}

.contact-icon {
    font-size: 20px;
    line-height: 1;
}

.contact-text {
    font-size: 14px;
    letter-spacing: 0.3px;
}

/* Responsive: Show only icon on mobile */
@media (max-width: 768px) {
    .contact-button {
        width: 56px;
        height: 56px;
        padding: 0;
        justify-content: center;
        border-radius: 50%;
        bottom: 20px;
        left: 20px;
    }
    
    .contact-text {
        display: none;
    }
    
    .contact-icon {
        font-size: 24px;
    }
}

/* Dark mode adjustments */
[data-theme="dark"] .contact-button {
    background: linear-gradient(135deg, #667eea, #764ba2);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.5);
}

[data-theme="dark"] .contact-button:hover {
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.6);
    background: linear-gradient(135deg, #7c8ff5, #667eea);
}


