/* =========================================================
   Pembeda Buah Indonesia - Style System
   Theme: Warm Tropical Nature (Vibrant Green & Mango Amber)
   ========================================================= */

:root {
    /* Color Palette */
    --primary-green: #10b981;
    --primary-green-dark: #059669;
    --primary-green-deep: #064e3b;
    --primary-green-light: #d1fae5;
    
    --mango-yellow: #f59e0b;
    --mango-yellow-dark: #d97706;
    --mango-yellow-light: #fef3c7;

    --papaya-orange: #ea580c;
    --papaya-light: #ffedd5;

    --accent-gold: #fbbf24;
    --accent-red: #ef4444;

    /* Neutrals & Dark Tones */
    --bg-main: #fcfbf7;
    --surface-card: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.88);
    --border-color: #e5e7eb;
    --border-subtle: #f1f5f9;
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;

    /* Shadow tokens */
    --shadow-sm: 0 2px 8px rgba(16, 185, 129, 0.05);
    --shadow-md: 0 10px 25px -5px rgba(15, 23, 42, 0.08), 0 8px 10px -6px rgba(15, 23, 42, 0.04);
    --shadow-lg: 0 20px 35px -10px rgba(16, 185, 129, 0.15), 0 12px 20px -8px rgba(245, 158, 11, 0.12);
    --shadow-card: 0 16px 40px -12px rgba(16, 80, 50, 0.08);

    /* Radii */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
    font-family: 'Plus Jakarta Sans', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 24px 16px;
    background-image: 
        radial-gradient(at 0% 0%, rgba(209, 250, 229, 0.45) 0px, transparent 50%),
        radial-gradient(at 100% 0%, rgba(254, 243, 199, 0.5) 0px, transparent 50%),
        radial-gradient(at 50% 100%, rgba(255, 237, 213, 0.4) 0px, transparent 50%);
}

/* Background Ambient Orbs */
.bg-shape {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    pointer-events: none;
    opacity: 0.6;
}

.shape-1 {
    width: 380px;
    height: 380px;
    background: #a7f3d0;
    top: -100px;
    left: -100px;
}

.shape-2 {
    width: 420px;
    height: 420px;
    background: #fde68a;
    bottom: -100px;
    right: -100px;
}

.shape-3 {
    width: 300px;
    height: 300px;
    background: #fed7aa;
    top: 40%;
    left: 60%;
}

/* Container Structure */
.app-container {
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

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

.badge-tag {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    background: var(--primary-green-light);
    color: var(--primary-green-deep);
    border: 1px solid rgba(16, 185, 129, 0.3);
    border-radius: var(--radius-full);
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    animation: fadeInDown 0.6s ease-out;
}

.badge-tag i {
    width: 15px;
    height: 15px;
    color: var(--primary-green-dark);
}

.main-title {
    font-family: 'Outfit', sans-serif;
    font-size: clamp(2rem, 4.5vw, 2.9rem);
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: -0.03em;
    line-height: 1.15;
}

.main-title span {
    background: linear-gradient(135deg, var(--primary-green-dark), var(--mango-yellow));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

/* Main Grid Layout */
.classifier-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: stretch;
}

@media (max-width: 900px) {
    .classifier-grid {
        grid-template-columns: 1fr;
    }
}

/* Card Styling */
.card {
    background: var(--surface-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.7);
    box-shadow: var(--shadow-card);
    border-radius: var(--radius-xl);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.card-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.icon-bubble {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--primary-green-light);
    color: var(--primary-green-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.icon-bubble.orange {
    background: var(--mango-yellow-light);
    color: var(--mango-yellow-dark);
}

.icon-bubble i {
    width: 22px;
    height: 22px;
}

.card-title-wrap h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
}

.card-hint {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Status Badge */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    font-weight: 600;
}

.status-badge.offline {
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid #e2e8f0;
}

.status-badge.live {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
}

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

.status-badge.live .status-dot {
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
    animation: pulseDot 1.5s infinite;
}

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

/* Webcam Container & Video Frame */
.webcam-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #0f172a;
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.3);
    border: 2px solid #e2e8f0;
}

.webcam-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

/* Canvas & Video elements inside webcam container */
.webcam-container canvas,
.webcam-container video,
.webcam-container img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: var(--radius-lg);
}

/* Webcam Placeholder State */
.webcam-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    color: #94a3b8;
    gap: 12px;
}

.placeholder-icon {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-gold);
    margin-bottom: 4px;
}

.placeholder-icon i {
    width: 32px;
    height: 32px;
}

.webcam-placeholder h3 {
    font-size: 1.15rem;
    color: #f8fafc;
    font-weight: 600;
}

.webcam-placeholder p {
    font-size: 0.85rem;
    max-width: 280px;
    line-height: 1.5;
}

/* Scanner Animation Overlay */
.scanner-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 5;
}

.scan-laser {
    position: absolute;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, #10b981 30%, #fbbf24 70%, transparent 100%);
    box-shadow: 0 0 12px 2px rgba(16, 185, 129, 0.7);
    animation: scanAnim 2.8s infinite ease-in-out alternate;
}

@keyframes scanAnim {
    0% { top: 6%; opacity: 0.4; }
    50% { opacity: 1; }
    100% { top: 92%; opacity: 0.4; }
}

/* Viewfinder corner lines */
.viewfinder-corner {
    position: absolute;
    width: 28px;
    height: 28px;
    border-color: rgba(255, 255, 255, 0.8);
    border-style: solid;
    pointer-events: none;
}

.top-left { top: 16px; left: 16px; border-width: 3px 0 0 3px; border-top-left-radius: 8px; }
.top-right { top: 16px; right: 16px; border-width: 3px 3px 0 0; border-top-right-radius: 8px; }
.bottom-left { bottom: 16px; left: 16px; border-width: 0 0 3px 3px; border-bottom-left-radius: 8px; }
.bottom-right { bottom: 16px; right: 16px; border-width: 0 3px 3px 0; border-bottom-right-radius: 8px; }

/* Loading State Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    z-index: 10;
    color: #ffffff;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--primary-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-overlay p {
    font-size: 0.92rem;
    font-weight: 500;
}

/* Button & Controls */
.control-actions {
    display: flex;
    gap: 12px;
    width: 100%;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: var(--transition-fast);
}

.btn i {
    width: 18px;
    height: 18px;
}

.btn-primary {
    flex: 1;
    background: linear-gradient(135deg, var(--primary-green), var(--primary-green-dark));
    color: #ffffff;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #10b981, #047857);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.45);
}

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

.btn-primary.stop-mode {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 14px rgba(239, 68, 68, 0.35);
}

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-main);
    border: 1px solid #e2e8f0;
}

.btn-secondary:hover:not(:disabled) {
    background: #e2e8f0;
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
}

/* Upload Alternative */
.upload-alternative {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-top: 6px;
    border-top: 1px dashed var(--border-color);
}

.upload-link {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--primary-green-dark);
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    transition: var(--transition-fast);
}

.upload-link:hover {
    color: var(--primary-green);
}

.upload-link input[type="file"] {
    display: none;
}

.upload-link i {
    width: 16px;
    height: 16px;
}

/* =========================================================
   Right Column: Prediction Card & Progress Elements
   ========================================================= */

/* Top Prediction Hero Card */
.top-prediction-card {
    background: linear-gradient(135deg, #ffffff 0%, #fefce8 100%);
    border: 2px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-lg);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition-smooth);
}

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

.pred-label-tag {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--mango-yellow-dark);
    background: var(--mango-yellow-light);
    padding: 3px 10px;
    border-radius: var(--radius-full);
}

.confidence-badge {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--primary-green-dark);
    background: var(--primary-green-light);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    transition: var(--transition-fast);
}

.top-pred-body {
    display: flex;
    align-items: center;
    gap: 16px;
}

.fruit-avatar {
    width: 58px;
    height: 58px;
    border-radius: var(--radius-md);
    background: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    flex-shrink: 0;
    border: 1px solid var(--border-color);
}

.top-pred-info h3 {
    font-family: 'Outfit', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.top-pred-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
    line-height: 1.4;
}

/* Predictions List Section */
.predictions-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
}

.predictions-list-header h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-main);
}

.pred-count {
    font-size: 0.78rem;
    color: var(--text-muted);
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: var(--radius-full);
    font-weight: 600;
}

/* Label Container & Item Rows */
.label-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 270px;
    overflow-y: auto;
    padding-right: 4px;
}

/* Scrollbar polish */
.label-container::-webkit-scrollbar {
    width: 5px;
}
.label-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: var(--radius-full);
}

/* Individual Prediction Item */
.pred-item {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: var(--transition-fast);
}

.pred-item.is-top {
    border-color: rgba(16, 185, 129, 0.4);
    background: #f0fdf4;
}

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

.pred-item-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}

.pred-item-percent {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

/* Dynamic Progress Bar */
.progress-track {
    width: 100%;
    height: 8px;
    background: #f1f5f9;
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, #10b981, #059669);
    width: 0%;
    transition: width 0.25s ease-out;
}

.progress-fill.high {
    background: linear-gradient(90deg, #10b981, #34d399);
}

.progress-fill.medium {
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
}

.progress-fill.low {
    background: #94a3b8;
}

/* Empty State List */
.empty-state-list {
    text-align: center;
    padding: 24px 16px;
    color: var(--text-muted);
    background: #f8fafc;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.empty-state-list i {
    width: 28px;
    height: 28px;
    color: #cbd5e1;
}

.empty-state-list p {
    font-size: 0.85rem;
    max-width: 280px;
    line-height: 1.4;
}

/* Tips Box */
.tips-box {
    margin-top: auto;
    background: #fffbeb;
    border: 1px solid #fef3c7;
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.tips-icon {
    width: 18px;
    height: 18px;
    color: var(--mango-yellow-dark);
    flex-shrink: 0;
    margin-top: 2px;
}

.tips-box p {
    font-size: 0.82rem;
    color: #92400e;
    line-height: 1.4;
}

/* Footer */
.app-footer {
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-muted);
    padding: 12px 0;
}

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

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.toast {
    background: #1e293b;
    color: #ffffff;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 340px;
}

.toast.error {
    background: #ef4444;
}

.toast.success {
    background: #10b981;
}

.toast.warning {
    background: #f59e0b;
}

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

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

/* Mobile Responsiveness Fine-tuning */
@media (max-width: 600px) {
    body {
        padding: 16px 12px;
    }

    .card {
        padding: 18px;
        gap: 16px;
    }

    .control-actions {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .top-pred-body {
        flex-direction: row;
        gap: 12px;
    }

    .fruit-avatar {
        width: 48px;
        height: 48px;
        font-size: 1.6rem;
    }

    .top-pred-info h3 {
        font-size: 1.15rem;
    }
}
