:root {
    --bg-color: #f4f7f6;
    --card-bg: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --primary-color: #00897b; /* Emerald/Teal */
    --primary-hover: #00796b;
    --accent-light: #e0f2f1;
    --border-color: #e2e8f0;
    --success-text: #059669;
    --coach-bg: #e6f4ea;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 1rem;
    overflow-x: hidden;
}

/* Mobile Container */
.mobile-container {
    background: var(--card-bg);
    width: 100%;
    max-width: 480px; /* Mobile width */
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    min-height: 80vh;
}

/* Header */
.app-header {
    text-align: center;
}

.logo-text {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary-color);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Floating Model Selector Bubble */
.floating-model-selector {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 8px 16px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.floating-model-selector:hover {
    box-shadow: 0 12px 30px rgba(0,0,0,0.15);
    transform: translateX(-50%) translateY(-2px);
}

.floating-model-selector select {
    appearance: none;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    padding-right: 5px;
}

.dropdown-icon {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
}

/* Upload Section */
.upload-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Buttons */
.btn {
    width: 100%;
    border: none;
    border-radius: 8px;
    padding: 12px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

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

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

.btn-action {
    background-color: var(--text-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-action:hover {
    background-color: #0f172a;
}

.btn-secondary {
    background-color: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-secondary:hover {
    background-color: var(--accent-light);
}

/* Upload Buttons Layout */
.upload-buttons {
    display: flex;
    gap: 0.75rem;
    width: 100%;
}

.upload-buttons .btn {
    flex: 1;
}

/* Responsive: Desktop vs Mobile */
.desktop-only { display: flex; }
.mobile-only { display: none; }

@media (max-width: 768px) {
    .desktop-only { display: none !important; }
    .mobile-only { display: flex !important; }
}
/* Preview Card */
.preview-card {
    border: 1px solid var(--border-color);
    border-radius: 12px;
    height: 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow: hidden;
    background-color: #f8fafc;
}

.placeholder {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#image-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.btn-remove {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.5);
    color: white;
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

/* Result Section */
.result-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    animation: fadeIn 0.4s ease;
}

.section-title {
    font-size: 1.1rem;
    color: var(--primary-color);
    text-align: center;
    margin-bottom: 0.5rem;
}

.result-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

/* Cards */
.info-card {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 1rem;
}

.info-card:last-child {
    border-bottom: none;
}

.label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.food-name {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--primary-color);
}

.status {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.confidence-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.confidence-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-top: 4px;
}

/* Nutrition Box */
.nutrition-box {
    background-color: var(--accent-light);
    border-left: 4px solid var(--primary-color);
    padding: 12px 16px;
    border-radius: 4px 8px 8px 4px;
}

.nutrition-title {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-bottom: 6px;
}

.nutrition-values {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--success-text);
    line-height: 1.4;
}

/* Coach AI Section */
.coach-card {
    background-color: var(--coach-bg);
    border-radius: 12px;
    padding: 1.2rem;
    margin-top: 0.5rem;
}

.coach-title {
    font-size: 1rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.coach-section {
    margin-bottom: 1rem;
}

.coach-section h4 {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary-hover);
    margin-bottom: 4px;
}

.coach-section p {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.coach-list h5 {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    margin-top: 8px;
    margin-bottom: 4px;
}

.coach-list ul {
    list-style-type: disc;
    padding-left: 1.2rem;
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.coach-list li {
    margin-bottom: 4px;
}

.coach-list li span {
    font-weight: 600;
    color: var(--primary-hover);
}

.coach-footer {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 1rem;
    text-align: center;
}

.italic {
    font-style: italic;
}
.text-center { text-align: center; }
.text-muted { color: var(--text-secondary); }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1.5rem; }
.hidden { display: none !important; }

/* Loading */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.9);
    z-index: 50;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    border-radius: 20px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--accent-light);
    border-left-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

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

/* ===== ERROR MODAL POPUP ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 999;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.5rem;
    animation: modalFadeIn 0.25s ease-out;
}

.modal-card {
    background: #fff;
    border-radius: 20px;
    padding: 1.8rem 1.5rem 1.5rem;
    max-width: 380px;
    width: 100%;
    text-align: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 2px 8px rgba(0, 0, 0, 0.08);
    animation: modalSlideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
}

/* Custom Food-Themed Icon */
.modal-icon-wrapper {
    width: 88px;
    height: 76px;
    margin: 0 auto 1rem;
}

.modal-plate-icon {
    width: 100%;
    height: 100%;
    opacity: 0;
    animation: iconFadeIn 0.4s 0.15s ease both;
}

.modal-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.modal-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin-bottom: 0.8rem;
}

/* Confidence Gauge */
.modal-gauge {
    margin-bottom: 0.8rem;
    padding: 0 0.25rem;
}

.modal-gauge-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.modal-gauge-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.modal-gauge-value {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--primary-color);
}

.modal-gauge-track {
    width: 100%;
    height: 6px;
    background: #e2e8f0;
    border-radius: 3px;
    overflow: hidden;
}

.modal-gauge-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #4db6ac);
    border-radius: 3px;
    transition: width 0.8s cubic-bezier(0.22, 1, 0.36, 1);
}

.modal-gauge-hint {
    font-size: 0.7rem;
    color: #94a3b8;
    margin-top: 5px;
    text-align: left;
    font-style: italic;
}

/* Divider */
.modal-divider {
    height: 1px;
    background: #e2e8f0;
    margin: 0.6rem 0;
}

/* Food Label */
.modal-food-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 0.6rem;
    text-align: left;
}

/* Horizontal Scroll Food Items */
.modal-food-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 1rem;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.modal-food-scroll::-webkit-scrollbar {
    display: none;
}

.modal-food-item {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 62px;
    scroll-snap-align: start;
    transition: transform 0.15s ease;
}

.modal-food-item:hover {
    transform: translateY(-2px);
}

.food-emoji {
    width: 42px;
    height: 42px;
    background: var(--accent-light);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.modal-food-item .food-name {
    font-size: 0.58rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-align: center;
    line-height: 1.2;
    word-break: break-word;
}

/* Modal Button */
.modal-btn {
    border-radius: 10px;
    font-size: 0.88rem;
    padding: 12px 20px;
    margin-top: 0.2rem;
}

/* === MODAL KEYFRAMES === */
@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

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

/* Modal closing animation */
.modal-overlay.closing {
    animation: modalFadeOut 0.25s ease forwards;
}

.modal-overlay.closing .modal-card {
    animation: modalSlideDown 0.25s ease forwards;
}

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

@keyframes modalSlideDown {
    from { opacity: 1; transform: translateY(0) scale(1); }
    to { opacity: 0; transform: translateY(16px) scale(0.97); }
}
