/* ==========================================================================
   STYLE.CSS — Pembeda Suasana AI (Teachable Machine)
   Nuansa Warna: Warm Sunset Amber, Golden Dusk, Deep Midnight & Glassmorphism
   ========================================================================== */

/* 1. CSS Variables & Design Tokens */
:root {
    /* Color Palette: Warm Nature / Sunset / Atmosphere */
    --bg-primary: #0d1117;
    --bg-surface: rgba(22, 27, 34, 0.75);
    --bg-card: rgba(30, 36, 46, 0.65);
    --bg-card-hover: rgba(38, 46, 58, 0.85);
    
    --primary-gradient: linear-gradient(135deg, #f97316 0%, #fb923c 50%, #f59e0b 100%);
    --accent-orange: #f97316;
    --accent-amber: #f59e0b;
    --accent-gold: #fbbf24;
    --accent-cyan: #06b6d4;
    --accent-indigo: #6366f1;
    --accent-purple: #a855f7;
    --accent-green: #10b981;

    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --border-light: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(249, 115, 22, 0.35);

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

    --shadow-soft: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 35px -5px rgba(249, 115, 22, 0.25);
    --shadow-card: 0 20px 40px -15px rgba(0, 0, 0, 0.7);

    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;

    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. Reset & Global Styles */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
    line-height: 1.6;
}

/* 3. Ambient Background Light Flares */
.ambient-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    z-index: 0;
    pointer-events: none;
    opacity: 0.35;
    animation: floatGlow 14s ease-in-out infinite alternate;
}

.glow-1 {
    width: 450px;
    height: 450px;
    background: radial-gradient(circle, #f97316, transparent 70%);
    top: -100px;
    left: -100px;
}

.glow-2 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #f59e0b, transparent 70%);
    bottom: -150px;
    right: -100px;
    animation-delay: -5s;
}

.glow-3 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #6366f1, transparent 70%);
    top: 40%;
    right: 25%;
    opacity: 0.15;
    animation-delay: -9s;
}

@keyframes floatGlow {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(40px, 30px) scale(1.1); }
}

/* 4. App Container & Wrapper */
.app-wrapper {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

/* 5. Header Styling */
.app-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
}

.brand-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(249, 115, 22, 0.12);
    border: 1px solid rgba(249, 115, 22, 0.3);
    color: #fb923c;
    padding: 0.35rem 1rem;
    border-radius: var(--radius-full);
    font-size: 0.825rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    backdrop-filter: blur(8px);
}

.badge-dot {
    width: 7px;
    height: 7px;
    background-color: #fb923c;
    border-radius: 50%;
    box-shadow: 0 0 10px #fb923c;
}

.main-title {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 4vw, 2.75rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--text-primary);
}

.highlight-text {
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.subtitle {
    color: var(--text-secondary);
    font-size: clamp(0.95rem, 2vw, 1.05rem);
    max-width: 640px;
}

.subtitle strong {
    color: #fdba74;
}

/* 6. Main Glassmorphism Card */
.main-card {
    background: var(--bg-surface);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card);
    padding: clamp(1.25rem, 3vw, 2.25rem);
    position: relative;
    overflow: hidden;
}

.main-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(249, 115, 22, 0.6), transparent);
}

/* 7. Notification / Alert Banner */
.alert-banner {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.85rem 1.25rem;
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
    font-size: 0.9rem;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s ease;
}

.alert-banner.info {
    background: rgba(249, 115, 22, 0.12);
    border-color: rgba(249, 115, 22, 0.35);
    color: #fdba74;
}

.alert-icon {
    font-size: 1.15rem;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-close {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 1.35rem;
    cursor: pointer;
    line-height: 1;
    opacity: 0.8;
    transition: var(--transition-smooth);
}

.alert-close:hover {
    opacity: 1;
    transform: scale(1.1);
}

/* 8. App Grid Layout */
.app-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 2rem;
    align-items: stretch;
}

@media (max-width: 868px) {
    .app-grid {
        grid-template-columns: 1fr;
        gap: 1.75rem;
    }
}

/* 9. Section Headers */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
}

.section-title-wrapper {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.section-title-wrapper h2 {
    font-family: var(--font-heading);
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-primary);
}

.section-icon {
    color: var(--accent-orange);
    font-size: 1.1rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-light);
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.status-pill.active {
    background: rgba(16, 185, 129, 0.15);
    border-color: rgba(16, 185, 129, 0.4);
    color: #6ee7b7;
}

.pulse-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
    transition: var(--transition-smooth);
}

.status-pill.active .pulse-indicator {
    background-color: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green);
    animation: pulse 1.5s infinite;
}

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

.confidence-tag {
    background: rgba(249, 115, 22, 0.15);
    color: #fb923c;
    border: 1px solid rgba(249, 115, 22, 0.3);
    padding: 0.2rem 0.65rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

/* 10. Camera / Viewport Container */
.viewport-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.camera-container {
    width: 100%;
    aspect-ratio: 4 / 3;
    background: #090c10;
    border-radius: var(--radius-lg);
    border: 2px solid var(--border-light);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8);
    transition: var(--transition-smooth);
}

.camera-container.active {
    border-color: var(--border-glow);
    box-shadow: var(--shadow-glow), inset 0 0 20px rgba(249, 115, 22, 0.1);
}

/* Placeholder */
.camera-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
    z-index: 2;
    transition: var(--transition-smooth);
}

.placeholder-icon-wrap {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.85rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.camera-placeholder h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
}

.camera-placeholder p {
    font-size: 0.875rem;
    max-width: 280px;
    line-height: 1.45;
}

/* Viewfinder Target & Laser Scanning Animation */
.viewfinder-frame {
    position: absolute;
    inset: 16px;
    pointer-events: none;
    z-index: 5;
    opacity: 0.5;
    transition: var(--transition-smooth);
}

.camera-container.active .viewfinder-frame {
    opacity: 0.85;
}

.corner {
    position: absolute;
    width: 18px;
    height: 18px;
    border-color: var(--accent-orange);
    border-style: solid;
}

.top-left { top: 0; left: 0; border-width: 2.5px 0 0 2.5px; border-top-left-radius: 4px; }
.top-right { top: 0; right: 0; border-width: 2.5px 2.5px 0 0; border-top-right-radius: 4px; }
.bottom-left { bottom: 0; left: 0; border-width: 0 0 2.5px 2.5px; border-bottom-left-radius: 4px; }
.bottom-right { bottom: 0; right: 0; border-width: 0 2.5px 2.5px 0; border-bottom-right-radius: 4px; }

.scan-laser-line {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #f97316, #fbbf24, transparent);
    box-shadow: 0 0 15px #f97316, 0 0 25px #fbbf24;
    z-index: 6;
    opacity: 0;
    pointer-events: none;
}

.camera-container.active .scan-laser-line {
    opacity: 0.85;
    animation: scanMove 2.8s ease-in-out infinite alternate;
}

@keyframes scanMove {
    0% { top: 4%; }
    100% { top: 96%; }
}

/* Target Canvas & Images */
.webcam-target {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: absolute;
    inset: 0;
    z-index: 1;
}

.webcam-target canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    border-radius: var(--radius-lg);
    transform: scaleX(-1); /* Mirror camera view for natural feel */
}

.image-preview-target {
    width: 100%;
    height: 100%;
    object-fit: cover;
    position: absolute;
    inset: 0;
    z-index: 1;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(13, 17, 23, 0.85);
    backdrop-filter: blur(6px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    z-index: 10;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(249, 115, 22, 0.2);
    border-top-color: var(--accent-orange);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

#loading-text {
    font-size: 0.9rem;
    font-weight: 500;
    color: #fed7aa;
}

/* 11. Controls & Buttons */
.controls-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.55rem;
    padding: 0.75rem 1.35rem;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.925rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-smooth);
    border: none;
    outline: none;
    text-decoration: none;
    user-select: none;
}

.btn-primary {
    background: var(--primary-gradient);
    color: #ffffff;
    box-shadow: 0 4px 20px rgba(249, 115, 22, 0.35);
    flex: 1.2;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(249, 115, 22, 0.5);
    filter: brightness(1.06);
}

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

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    flex: 0.9;
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.14);
    transform: translateY(-2px);
}

.btn-tertiary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    border: 1px dashed rgba(255, 255, 255, 0.15);
    flex: 1;
}

.btn-tertiary:hover {
    background: rgba(249, 115, 22, 0.08);
    border-color: rgba(249, 115, 22, 0.4);
    color: #fdba74;
    transform: translateY(-2px);
}

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

.file-input-hidden {
    display: none;
}

/* 12. Results Section */
.results-section {
    display: flex;
    flex-direction: column;
    gap: 1.15rem;
}

/* Top Result Highlight Card */
.top-result-card {
    background: linear-gradient(135deg, rgba(249, 115, 22, 0.15), rgba(245, 158, 11, 0.05));
    border: 1.5px solid rgba(249, 115, 22, 0.35);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.4rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    box-shadow: 0 10px 25px -5px rgba(249, 115, 22, 0.15);
    transition: var(--transition-smooth);
}

.top-result-icon-box {
    width: 62px;
    height: 62px;
    border-radius: var(--radius-md);
    background: var(--primary-gradient);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    flex-shrink: 0;
    box-shadow: 0 6px 16px rgba(249, 115, 22, 0.4);
    transition: var(--transition-smooth);
}

.top-result-info {
    flex: 1;
}

.top-label-title {
    font-size: 0.775rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #fdba74;
}

.top-label-name {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.1rem 0 0.3rem 0;
    line-height: 1.25;
}

.top-confidence-wrapper {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.confidence-number {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    color: #fbbf24;
}

.confidence-caption {
    font-size: 0.775rem;
    color: var(--text-muted);
}

/* 13. Prediction List & Progress Bars */
.prediction-list-wrapper {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    padding: 1.15rem 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    flex: 1;
}

.prediction-list-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.775rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 0.5rem;
}

.prediction-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.empty-state-list {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 1.75rem 1rem;
    color: var(--text-muted);
    gap: 0.6rem;
}

.empty-state-list i {
    font-size: 1.6rem;
    color: var(--text-secondary);
}

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

/* Dynamic Prediction Item */
.prediction-item {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.5rem 0.65rem;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid transparent;
    transition: var(--transition-smooth);
}

.prediction-item.is-top {
    background: rgba(249, 115, 22, 0.08);
    border-color: rgba(249, 115, 22, 0.25);
}

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

.item-class-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.item-class-icon {
    font-size: 0.95rem;
    color: var(--accent-amber);
    width: 18px;
    text-align: center;
}

.item-class-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.item-percentage {
    font-family: var(--font-heading);
    font-size: 0.925rem;
    font-weight: 700;
    color: #fbbf24;
}

/* Progress Bar */
.progress-track {
    width: 100%;
    height: 7px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: var(--radius-full);
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    width: 0%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, #f97316, #fbbf24);
    box-shadow: 0 0 10px rgba(249, 115, 22, 0.6);
    transition: width 0.25s ease-out;
}

.prediction-item.is-top .progress-fill {
    background: linear-gradient(90deg, #ea580c, #f59e0b, #fde047);
}

/* 14. Info Box */
.model-info-box {
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-light);
    color: var(--text-muted);
    font-size: 0.8rem;
    line-height: 1.45;
}

.model-info-box i {
    color: var(--accent-orange);
    font-size: 0.95rem;
    margin-top: 2px;
}

/* 15. Footer */
.app-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.heart-icon {
    color: #f43f5e;
    margin: 0 0.2rem;
    display: inline-block;
    animation: heartbeat 1.8s infinite;
}

@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    15% { transform: scale(1.2); }
    30% { transform: scale(1); }
    45% { transform: scale(1.15); }
}

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

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