/* ==========================================================================
   AI FOOD CLASSIFIER - MODERN CULINARY DESIGN SYSTEM
   ========================================================================== */

:root {
    /* Color Palette - Warm Food & Culinary Tones */
    --primary: #FF4D30;
    --primary-hover: #E0371D;
    --primary-light: rgba(255, 77, 48, 0.12);
    --primary-glow: rgba(255, 77, 48, 0.35);

    --spicy-color: #EF4444;
    --sweet-color: #EC4899;
    --snack-color: #F59E0B;
    --drink-color: #06B6D4;
    --fresh-color: #10B981;
    --neutral-color: #8B5CF6;

    /* Dark Modern Surfaces */
    --bg-dark: #0F172A;
    --bg-card: rgba(30, 41, 59, 0.75);
    --bg-card-inner: rgba(15, 23, 42, 0.6);
    --bg-glass: rgba(255, 255, 255, 0.05);

    /* Text Colors */
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    --text-dim: #64748B;

    /* Borders & Accents */
    --border-subtle: rgba(255, 255, 255, 0.08);
    --border-accent: rgba(255, 77, 48, 0.3);

    /* Shadows & Radii */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow-subtle: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(255, 77, 48, 0.2);
    
    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
}

/* Reset & Global */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
    padding: 24px 16px;
    line-height: 1.5;
}

/* Ambient Background Blobs */
.background-decorations {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}

.blob {
    position: absolute;
    filter: blur(100px);
    opacity: 0.25;
    border-radius: 50%;
    animation: blobFloat 16s ease-in-out infinite alternate;
}

.blob-1 {
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, #FF4B2B, #FF416C);
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #F59E0B, #EA580C);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #EC4899, #8B5CF6);
    top: 40%;
    left: 40%;
    animation-delay: -10s;
}

@keyframes blobFloat {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, -40px) scale(1.08); }
    100% { transform: translate(-30px, 30px) scale(0.95); }
}

/* Layout Wrapper */
.main-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1100px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Header */
.app-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    background: rgba(255, 77, 48, 0.15);
    border: 1px solid rgba(255, 77, 48, 0.35);
    border-radius: 999px;
    color: #FFA592;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.badge-pill i {
    color: #FF4D30;
}

.app-title {
    font-family: var(--font-heading);
    font-size: clamp(1.8rem, 4vw, 2.75rem);
    font-weight: 800;
    color: #FFFFFF;
    line-height: 1.2;
}

.gradient-text {
    background: linear-gradient(135deg, #FF6B4A 0%, #FF2E55 50%, #FF8A00 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-subtitle {
    color: var(--text-muted);
    font-size: 1rem;
    max-width: 650px;
    line-height: 1.6;
}

/* Main Card */
.app-card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-subtle), var(--shadow-glow);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Tabs */
.tab-control {
    display: flex;
    background: var(--bg-card-inner);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    padding: 4px;
    gap: 6px;
    max-width: 420px;
    margin: 0 auto;
    width: 100%;
}

.tab-btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
}

.tab-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
    background: linear-gradient(135deg, #FF4D30, #FF2E55);
    color: #FFFFFF;
    box-shadow: 0 4px 14px rgba(255, 77, 48, 0.35);
}

/* Content Grid */
.app-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

/* Viewport Section */
.viewport-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.viewport-container {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    min-height: 320px;
    background: #090D16;
    border-radius: var(--radius-lg);
    border: 2px dashed rgba(255, 255, 255, 0.12);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.3s ease;
}

.viewport-container.active {
    border: 2px solid rgba(255, 77, 48, 0.6);
    box-shadow: inset 0 0 30px rgba(255, 77, 48, 0.15);
}

/* Webcam Box */
.webcam-box {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.webcam-box canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block;
    border-radius: calc(var(--radius-lg) - 2px);
}

/* Placeholder */
.viewport-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 32px 20px;
    gap: 12px;
}

.placeholder-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    margin-bottom: 4px;
    border: 1px solid var(--border-accent);
    animation: pulseIcon 3s infinite ease-in-out;
}

@keyframes pulseIcon {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.viewport-placeholder h3 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
}

.viewport-placeholder p {
    color: var(--text-muted);
    font-size: 0.9rem;
    max-width: 320px;
}

/* Upload Preview Box */
.upload-preview-box {
    width: 100%;
    height: 100%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-preview-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: none;
    border-radius: calc(var(--radius-lg) - 2px);
}

.upload-preview-box.has-image img {
    display: block;
}

.upload-drag-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    padding: 24px;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.upload-preview-box.has-image .upload-drag-area {
    display: none;
}

.upload-icon {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 4px;
}

.upload-drag-area h4 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
}

.upload-drag-area p {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.btn-file-select {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 18px;
    background: var(--bg-glass);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-file-select:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
}

.file-hidden {
    display: none;
}

/* Scanner Animation Overlay */
.scan-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
    border-radius: calc(var(--radius-lg) - 2px);
}

.scan-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #FF4D30, #FFB800, #FF4D30, transparent);
    box-shadow: 0 0 15px #FF4D30, 0 0 30px #FF4D30;
    animation: scanAnimation 2.2s ease-in-out infinite alternate;
}

@keyframes scanAnimation {
    0% { top: 2%; opacity: 0.8; }
    50% { opacity: 1; }
    100% { top: 96%; opacity: 0.8; }
}

/* Status Indicator */
.status-indicator {
    position: absolute;
    top: 14px;
    right: 14px;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-subtle);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-muted);
    z-index: 10;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-idle {
    background-color: var(--text-dim);
}

.status-loading {
    background-color: #F59E0B;
    animation: blinkDot 1s infinite;
}

.status-active {
    background-color: #10B981;
    box-shadow: 0 0 8px #10B981;
    animation: pulseDot 2s infinite;
}

.status-error {
    background-color: #EF4444;
}

@keyframes blinkDot {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 1; }
}

@keyframes pulseDot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

/* Controls Buttons */
.controls-action-bar {
    display: flex;
    gap: 12px;
}

.btn-group {
    display: flex;
    width: 100%;
    gap: 10px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    border: none;
    outline: none;
}

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

.btn-primary {
    flex: 1;
    background: linear-gradient(135deg, #FF4D30 0%, #FF2E55 100%);
    color: #FFFFFF;
    box-shadow: 0 6px 20px rgba(255, 77, 48, 0.4);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #FF5F45 0%, #FF4165 100%);
    box-shadow: 0 8px 25px rgba(255, 77, 48, 0.55);
    transform: translateY(-2px);
}

.btn-primary.btn-active {
    background: linear-gradient(135deg, #EF4444 0%, #B91C1C 100%);
    box-shadow: 0 6px 20px rgba(239, 68, 68, 0.4);
}

.btn-secondary {
    background: var(--bg-card-inner);
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    padding: 14px 18px;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Alert Box */
.alert-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.35);
    color: #FECACA;
    animation: fadeIn 0.3s ease;
}

.alert-icon {
    font-size: 1.25rem;
    color: #F87171;
    margin-top: 2px;
}

.alert-content {
    flex: 1;
}

.alert-content h4 {
    font-size: 0.95rem;
    font-weight: 700;
    margin-bottom: 2px;
    color: #FFFFFF;
}

.alert-content p {
    font-size: 0.85rem;
    color: #FCA5A5;
    line-height: 1.4;
}

.alert-close {
    background: transparent;
    border: none;
    color: #FCA5A5;
    font-size: 1.3rem;
    cursor: pointer;
    padding: 0 4px;
}

/* Results Section */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Top Result Card */
.top-result-card {
    background: linear-gradient(135deg, rgba(255, 77, 48, 0.15) 0%, rgba(236, 72, 153, 0.08) 100%);
    border: 1px solid var(--border-accent);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.top-result-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: #FFA592;
}

.top-result-body {
    display: flex;
    align-items: center;
    gap: 18px;
}

.top-result-icon {
    width: 64px;
    height: 64px;
    min-width: 64px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, #FF4D30, #FF2E55);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: #FFFFFF;
    box-shadow: 0 8px 20px rgba(255, 77, 48, 0.35);
    transition: transform 0.3s ease;
}

.top-result-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}

.top-result-label {
    font-family: var(--font-heading);
    font-size: 1.45rem;
    font-weight: 800;
    color: #FFFFFF;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.top-result-score-wrap {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.top-result-percentage {
    font-family: var(--font-heading);
    font-size: 1.6rem;
    font-weight: 800;
    color: #FF7E67;
}

.top-result-caption {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Prediction List Breakdown */
.prediction-list-card {
    background: var(--bg-card-inner);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.list-header h3 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    gap: 8px;
}

.list-header h3 i {
    color: var(--primary);
}

.live-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
}

.live-tag i {
    font-size: 0.5rem;
    color: var(--text-dim);
}

.live-tag.active {
    background: rgba(16, 185, 129, 0.15);
    color: #34D399;
}

.live-tag.active i {
    color: #10B981;
    animation: blinkDot 1.2s infinite;
}

/* Prediction Items */
.predictions-container {
    display: flex;
    flex-direction: column;
    gap: 14px;
    min-height: 120px;
}

.empty-predictions {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px 12px;
    color: var(--text-dim);
    gap: 10px;
}

.empty-predictions i {
    font-size: 1.8rem;
    opacity: 0.5;
}

.empty-predictions p {
    font-size: 0.85rem;
    max-width: 260px;
}

.pred-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-subtle);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.pred-item.is-highest {
    background: rgba(255, 77, 48, 0.08);
    border-color: rgba(255, 77, 48, 0.3);
}

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

.pred-item-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    color: #FFFFFF;
}

.pred-category-icon {
    font-size: 1rem;
    width: 22px;
    text-align: center;
}

.pred-item-percentage {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-muted);
}

.pred-item.is-highest .pred-item-percentage {
    color: #FF6B4A;
}

/* Progress Bar */
.progress-bar-bg {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 999px;
    overflow: hidden;
    position: relative;
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #FF6B4A, #FF2E55);
    border-radius: 999px;
    transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 0 10px rgba(255, 77, 48, 0.5);
}

/* Category Specific Highlight Accents */
.theme-pedas .progress-bar-fill {
    background: linear-gradient(90deg, #F87171, #EF4444);
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
}
.theme-manis .progress-bar-fill {
    background: linear-gradient(90deg, #F472B6, #EC4899);
    box-shadow: 0 0 10px rgba(236, 72, 153, 0.6);
}
.theme-snack .progress-bar-fill {
    background: linear-gradient(90deg, #FBBF24, #F59E0B);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.6);
}
.theme-minuman .progress-bar-fill {
    background: linear-gradient(90deg, #22D3EE, #06B6D4);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.6);
}
.theme-sehat .progress-bar-fill {
    background: linear-gradient(90deg, #34D399, #10B981);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.6);
}

/* Food Tips Box */
.food-tips-box {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: var(--radius-md);
    color: #FDE68A;
    font-size: 0.85rem;
}

.tip-icon {
    font-size: 1.1rem;
    color: #F59E0B;
    margin-top: 1px;
}

.tip-text {
    line-height: 1.45;
    color: #F3F4F6;
}

.tip-text strong {
    color: #FBBF24;
}

/* Footer */
.app-footer {
    text-align: center;
    color: var(--text-dim);
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.app-footer code {
    background: rgba(255, 255, 255, 0.06);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-all;
}

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

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

/* Responsive Breakpoints */
@media (max-width: 900px) {
    .app-grid {
        grid-template-columns: 1fr;
    }

    .viewport-container {
        min-height: 280px;
    }
}

@media (max-width: 480px) {
    body {
        padding: 16px 10px;
    }

    .app-card {
        padding: 16px;
        border-radius: var(--radius-lg);
    }

    .top-result-body {
        gap: 12px;
    }

    .top-result-icon {
        width: 52px;
        height: 52px;
        min-width: 52px;
        font-size: 1.4rem;
    }

    .top-result-label {
        font-size: 1.2rem;
    }

    .top-result-percentage {
        font-size: 1.35rem;
    }

    .btn {
        padding: 12px 18px;
        font-size: 0.95rem;
    }
}
