/* ==========================================================================
   AI Activity Detector - Style System (Bangun, Tidur, Bermain)
   ========================================================================== */

:root {
    /* Base Color Palette */
    --bg-main: #0b0f19;
    --bg-card: rgba(18, 24, 38, 0.75);
    --bg-card-hover: rgba(26, 35, 54, 0.85);
    --bg-viewport: #060911;
    --border-glass: rgba(255, 255, 255, 0.08);
    --border-focus: rgba(99, 102, 241, 0.4);

    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    /* Theme & Activity Accent Colors */
    --color-wake: #f59e0b;       /* Sunrise Warm Amber */
    --color-wake-glow: rgba(245, 158, 11, 0.25);
    --color-sleep: #818cf8;      /* Twilight Lavender */
    --color-sleep-glow: rgba(129, 140, 248, 0.25);
    --color-play: #06b6d4;       /* Neon Cyan / Coral */
    --color-play-glow: rgba(6, 182, 212, 0.25);
    --color-primary: #6366f1;    /* Electric Indigo */
    --color-success: #10b981;    /* Emerald Green */
    --color-danger: #ef4444;     /* Rose Red */

    /* Gradients */
    --gradient-brand: linear-gradient(135deg, #f59e0b 0%, #ec4899 50%, #6366f1 100%);
    --gradient-wake: linear-gradient(135deg, #f59e0b, #ea580c);
    --gradient-sleep: linear-gradient(135deg, #6366f1, #a855f7);
    --gradient-play: linear-gradient(135deg, #06b6d4, #3b82f6);
    --gradient-card: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, rgba(0, 0, 0, 0.2) 100%);

    /* Shadows & Radii */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow-soft: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 25px rgba(99, 102, 241, 0.2);

    /* Fonts */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
}

/* Reset & Box Sizing */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

/* --------------------------------------------------------------------------
   Background Glow Ambience
   -------------------------------------------------------------------------- */
.bg-glow {
    position: fixed;
    border-radius: 50%;
    filter: blur(120px);
    pointer-events: none;
    z-index: 0;
    opacity: 0.4;
}

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

.bg-glow-2 {
    top: 30%;
    right: -5%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, #6366f1, transparent 70%);
}

.bg-glow-3 {
    bottom: -10%;
    left: 25%;
    width: 550px;
    height: 550px;
    background: radial-gradient(circle, #06b6d4, transparent 70%);
}

/* --------------------------------------------------------------------------
   Layout Container
   -------------------------------------------------------------------------- */
.main-wrapper {
    position: relative;
    z-index: 1;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 2.5rem;
}

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

.badge-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(99, 102, 241, 0.15);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #c7d2fe;
    padding: 0.35rem 1rem;
    border-radius: 9999px;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.03em;
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--color-success);
    box-shadow: 0 0 10px var(--color-success);
    animation: pulse 2s infinite;
}

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

.app-title {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 800;
    letter-spacing: -0.02em;
    line-height: 1.15;
}

.gradient-text {
    background: var(--gradient-brand);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.app-subtitle {
    color: var(--text-secondary);
    font-size: 1.05rem;
    max-width: 620px;
    margin: 0 auto;
}

/* Activity Chips */
.activity-chips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 1.1rem;
    border-radius: 9999px;
    font-size: 0.9rem;
    font-weight: 600;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    border: 1px solid var(--border-glass);
}

.chip-wake {
    background: rgba(245, 158, 11, 0.12);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.3);
}

.chip-sleep {
    background: rgba(129, 140, 248, 0.12);
    color: #a5b4fc;
    border-color: rgba(129, 140, 248, 0.3);
}

.chip-play {
    background: rgba(6, 182, 212, 0.12);
    color: #67e8f9;
    border-color: rgba(6, 182, 212, 0.3);
}

.chip:hover {
    transform: translateY(-2px);
}

/* --------------------------------------------------------------------------
   Card System
   -------------------------------------------------------------------------- */
.detector-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.75rem;
    align-items: stretch;
}

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

.card {
    background: var(--bg-card);
    background-image: var(--gradient-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 1.75rem;
    box-shadow: var(--shadow-soft);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transition: border-color 0.3s ease;
}

.card:hover {
    border-color: rgba(255, 255, 255, 0.14);
}

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

.card-title-group {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.icon-circle {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.icon-camera {
    background: rgba(99, 102, 241, 0.18);
    color: #818cf8;
}

.icon-brain {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
}

.card-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
}

.card-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.3rem 0.8rem;
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
}

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

.status-offline {
    background: rgba(148, 163, 184, 0.12);
    color: var(--text-secondary);
}
.status-offline .status-dot {
    background-color: var(--text-muted);
}

.status-online {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}
.status-online .status-dot {
    background-color: #10b981;
    box-shadow: 0 0 8px #10b981;
    animation: pulse 1.5s infinite;
}

/* --------------------------------------------------------------------------
   Webcam Viewport & Overlays
   -------------------------------------------------------------------------- */
.webcam-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 380px;
    background: var(--bg-viewport);
    border-radius: var(--radius-lg);
    border: 2px dashed rgba(255, 255, 255, 0.1);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.6);
}

.webcam-viewport.active {
    border-style: solid;
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.25), inset 0 0 20px rgba(0, 0, 0, 0.4);
}

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

/* Canvas rendered by Teachable Machine */
.webcam-box canvas {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    border-radius: var(--radius-lg);
}

/* Placeholder */
.camera-placeholder {
    padding: 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-secondary);
}

.placeholder-icon-anim {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.04);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
    transition: transform 0.3s ease;
}

.camera-placeholder h3 {
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 600;
}

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

/* Scan Laser Animation */
.scan-laser {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #6366f1, #38bdf8, transparent);
    box-shadow: 0 0 15px #38bdf8;
    animation: scanAnimation 3s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 5;
}

@keyframes scanAnimation {
    0% { top: 2%; }
    100% { top: 96%; }
}

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

.spinner {
    width: 44px;
    height: 44px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-left-color: var(--color-wake);
    border-right-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Buttons & Controls
   -------------------------------------------------------------------------- */
.control-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.85rem 1.4rem;
    font-family: var(--font-body);
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: none;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    user-select: none;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-primary {
    flex: 2;
    background: var(--gradient-wake);
    color: #ffffff;
    box-shadow: 0 4px 15px var(--color-wake-glow);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(245, 158, 11, 0.4);
}

.btn-danger {
    flex: 1.5;
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.25);
    transform: translateY(-2px);
}

.btn-secondary {
    padding: 0.85rem 1.1rem;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-glass);
}

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

/* Alert Box */
.alert-box {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-md);
    background: rgba(239, 68, 68, 0.12);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
    font-size: 0.88rem;
    animation: fadeIn 0.3s ease;
}

.alert-icon {
    font-size: 1.2rem;
    color: var(--color-danger);
    margin-top: 2px;
}

.alert-content strong {
    display: block;
    color: #ffffff;
    font-size: 0.92rem;
    margin-bottom: 2px;
}

/* --------------------------------------------------------------------------
   Results Section (Right Panel)
   -------------------------------------------------------------------------- */
.highlight-box {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: all 0.4s ease;
}

.highlight-box.wake-active {
    border-color: rgba(245, 158, 11, 0.5);
    box-shadow: 0 0 25px var(--color-wake-glow);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.12), rgba(234, 88, 12, 0.04));
}

.highlight-box.sleep-active {
    border-color: rgba(129, 140, 248, 0.5);
    box-shadow: 0 0 25px var(--color-sleep-glow);
    background: linear-gradient(135deg, rgba(129, 140, 248, 0.12), rgba(168, 85, 247, 0.04));
}

.highlight-box.play-active {
    border-color: rgba(6, 182, 212, 0.5);
    box-shadow: 0 0 25px var(--color-play-glow);
    background: linear-gradient(135deg, rgba(6, 182, 212, 0.12), rgba(59, 130, 246, 0.04));
}

.highlight-icon-wrapper {
    width: 60px;
    height: 60px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--text-primary);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

.highlight-box.wake-active .highlight-icon-wrapper {
    background: var(--gradient-wake);
    color: #fff;
    transform: scale(1.05);
}

.highlight-box.sleep-active .highlight-icon-wrapper {
    background: var(--gradient-sleep);
    color: #fff;
    transform: scale(1.05);
}

.highlight-box.play-active .highlight-icon-wrapper {
    background: var(--gradient-play);
    color: #fff;
    transform: scale(1.05);
}

.highlight-details {
    flex: 1;
}

.highlight-tag {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-secondary);
    font-weight: 600;
}

.highlight-name {
    font-family: var(--font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0.15rem 0 0.3rem 0;
}

.highlight-confidence {
    font-size: 0.88rem;
    color: var(--text-secondary);
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.highlight-confidence strong {
    color: var(--text-primary);
    font-size: 1.05rem;
}

/* --------------------------------------------------------------------------
   Prediction Breakdown List
   -------------------------------------------------------------------------- */
.prediction-breakdown-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

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

.breakdown-header h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.badge-subtle {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.06);
    padding: 0.2rem 0.55rem;
    border-radius: 4px;
    color: var(--text-muted);
}

.label-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    min-height: 160px;
    justify-content: center;
}

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--text-muted);
    font-size: 0.9rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
}

.empty-state i {
    font-size: 2rem;
    opacity: 0.5;
}

/* Single Prediction Item */
.prediction-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    padding: 0.85rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    transition: all 0.25s ease;
}

.prediction-item.item-active {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(255, 255, 255, 0.15);
}

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

.item-label-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 600;
    font-size: 0.95rem;
}

.item-badge-icon {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
}

.item-percent {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

/* Progress Track and Bar */
.progress-track {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 9999px;
    width: 0%;
    transition: width 0.18s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dynamic Classes for Bars */
.bar-wake {
    background: var(--gradient-wake);
    box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

.bar-sleep {
    background: var(--gradient-sleep);
    box-shadow: 0 0 10px rgba(129, 140, 248, 0.4);
}

.bar-play {
    background: var(--gradient-play);
    box-shadow: 0 0 10px rgba(6, 182, 212, 0.4);
}

.bar-default {
    background: linear-gradient(90deg, #6366f1, #a855f7);
}

/* --------------------------------------------------------------------------
   Model Info Footer
   -------------------------------------------------------------------------- */
.model-info-footer {
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-glass);
}

.model-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-muted);
    overflow: hidden;
}

.model-meta code {
    background: rgba(0, 0, 0, 0.35);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    color: #cbd5e1;
    font-family: monospace;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
    max-width: 260px;
}

/* --------------------------------------------------------------------------
   Guide Section
   -------------------------------------------------------------------------- */
.guide-section {
    background: var(--bg-card);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: 2rem;
    backdrop-filter: blur(16px);
}

.guide-title {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: var(--text-primary);
}

.guide-title i {
    color: #fbbf24;
}

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
}

.guide-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    transition: all 0.3s ease;
}

.guide-card:hover {
    background: rgba(255, 255, 255, 0.04);
    transform: translateY(-3px);
    border-color: rgba(255, 255, 255, 0.15);
}

.guide-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    margin-bottom: 0.25rem;
}

.guide-wake-icon {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.guide-sleep-icon {
    background: rgba(129, 140, 248, 0.15);
    color: #a5b4fc;
}

.guide-play-icon {
    background: rgba(6, 182, 212, 0.15);
    color: #67e8f9;
}

.guide-card h4 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
}

.guide-card p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

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

.app-footer a {
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.app-footer a:hover {
    color: #fff;
    text-decoration: underline;
}

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

/* --------------------------------------------------------------------------
   Responsive Adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 600px) {
    .main-wrapper {
        padding: 1.25rem 1rem;
        gap: 1.75rem;
    }

    .card {
        padding: 1.25rem;
    }

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

    .btn {
        width: 100%;
    }

    .guide-section {
        padding: 1.25rem;
    }
}
