/* ==========================================================================
   WakeAI - Alarm Interaktif Teachable Machine (CSS Design System)
   Theme: Modern Dark Mode & Glassmorphism
   ========================================================================== */

/* 1. VARIABEL DESAIN (CSS Custom Properties) */
:root {
    /* Color Palette */
    --bg-main: #080c14;
    --bg-card: rgba(18, 26, 43, 0.7);
    --bg-card-hover: rgba(26, 37, 60, 0.8);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-glow: rgba(99, 102, 241, 0.3);
    
    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Accent & Brand Colors */
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-glow: rgba(99, 102, 241, 0.4);
    
    --accent-cyan: #06b6d4;
    --accent-emerald: #10b981;
    --accent-rose: #f43f5e;
    --accent-amber: #f59e0b;
    
    /* Gradients */
    --grad-primary: linear-gradient(135deg, #6366f1 0%, #06b6d4 100%);
    --grad-alarm: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    --grad-success: linear-gradient(135deg, #10b981 0%, #059669 100%);
    
    /* Typography */
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Plus Jakarta Sans', sans-serif;
    
    /* Effects & Transitions */
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-full: 9999px;
    
    --shadow-card: 0 12px 32px rgba(0, 0, 0, 0.4);
    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 2. RESET & BASE STYLES */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.12) 0%, transparent 40%);
    background-attachment: fixed;
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 2rem;
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Container Layout */
.app-container {
    max-width: 1360px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 0 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 100vh;
}

/* 3. HEADER NAVIGATION */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.logo-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: var(--grad-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    box-shadow: 0 4px 16px var(--primary-glow);
}

.brand-text h1 {
    font-family: var(--font-heading);
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    line-height: 1.1;
}

.brand-text h1 span {
    color: var(--accent-cyan);
}

.brand-text .tagline {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.header-status {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Badges */
.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.3);
}

.status-badge.loading {
    color: var(--accent-amber);
    border-color: rgba(245, 158, 11, 0.3);
}
.status-badge.ready {
    color: var(--accent-emerald);
    border-color: rgba(16, 185, 129, 0.3);
}
.status-badge.error {
    color: var(--accent-rose);
    border-color: rgba(244, 63, 94, 0.3);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: currentColor;
    animation: pulse 1.5s infinite;
}

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

.live-clock-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.85rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.25);
    border-radius: var(--radius-full);
    color: var(--accent-cyan);
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
}

/* 4. ALARM BANNERS */
.alarm-banner {
    background: var(--grad-alarm);
    border-radius: var(--radius-md);
    padding: 1.25rem 1.5rem;
    color: #fff;
    box-shadow: 0 8px 30px rgba(244, 63, 94, 0.5);
    animation: bannerPulse 1.2s infinite alternate;
}

@keyframes bannerPulse {
    0% { transform: scale(1); box-shadow: 0 0 20px rgba(244, 63, 94, 0.4); }
    100% { transform: scale(1.01); box-shadow: 0 0 35px rgba(244, 63, 94, 0.8); }
}

.alarm-banner-content {
    display: flex;
    align-items: center;
    gap: 1.25rem;
}

.ringing-bell-icon {
    font-size: 2.2rem;
    animation: bellRing 0.3s infinite alternate ease-in-out;
}

@keyframes bellRing {
    0% { transform: rotate(-15deg); }
    100% { transform: rotate(15deg); }
}

.alarm-banner-text h2 {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.alarm-banner-text p {
    font-size: 0.9rem;
    opacity: 0.95;
}

/* Success Banner */
.success-banner {
    background: var(--grad-success);
    border-radius: var(--radius-md);
    padding: 1rem 1.5rem;
    color: #fff;
    box-shadow: 0 8px 25px rgba(16, 185, 129, 0.4);
    animation: fadeInDown 0.4s ease-out;
}

.success-banner-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.success-banner-content i {
    font-size: 2.5rem;
}

.success-banner-content h2 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
}

.success-banner-content p {
    font-size: 0.85rem;
    opacity: 0.9;
}

.success-banner-content button {
    margin-left: auto;
}

/* 5. MAIN DASHBOARD GRID */
.dashboard-grid {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 1.5rem;
    flex: 1;
}

.panel {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Glass Card Component */
.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 1.5rem;
    transition: border-color var(--transition-fast), transform var(--transition-fast);
}

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

.card-header {
    margin-bottom: 1.25rem;
}

.card-header h2 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.card-header h2 i {
    color: var(--primary);
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    display: block;
    margin-top: 0.2rem;
}

/* 6. ALARM CONTROLS & FORM */
.active-alarm-display {
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    text-align: center;
    margin-bottom: 1.25rem;
    position: relative;
    overflow: hidden;
}

.alarm-status-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-weight: 600;
}

.alarm-time-large {
    font-family: var(--font-heading);
    font-size: 2.8rem;
    font-weight: 800;
    color: var(--accent-cyan);
    letter-spacing: 1px;
    margin: 0.2rem 0;
    line-height: 1;
}

.alarm-countdown-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.alarm-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.input-group label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.time-input-wrapper, .url-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.time-input-wrapper i {
    position: absolute;
    left: 1rem;
    color: var(--primary);
    font-size: 1.2rem;
    pointer-events: none;
}

input[type="time"], input[type="url"] {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.8rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 600;
    outline: none;
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

input[type="url"] {
    padding-left: 1rem;
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 400;
}

input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.button-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.utility-buttons {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

/* BUTTONS SYSTEM */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    text-decoration: none;
}

.btn-primary {
    background: var(--grad-primary);
    color: #fff;
    box-shadow: 0 4px 14px var(--primary-glow);
    flex: 1;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

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

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.18);
}

.btn-danger {
    background: var(--accent-rose);
    color: #fff;
    flex: 1;
}
.btn-danger:hover {
    background: #e11d48;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--accent-cyan);
    flex: 1;
}

.btn-outline:hover {
    background: rgba(99, 102, 241, 0.15);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 0.5rem;
    border-radius: var(--radius-md);
    font-size: 1.2rem;
}

/* Accordion Card */
.collapsible-card {
    padding: 1.25rem 1.5rem;
}

.accordion-toggle {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}

.accordion-arrow {
    font-size: 1.2rem;
    color: var(--text-secondary);
    transition: transform var(--transition-fast);
}

.collapsible-card.active .accordion-arrow {
    transform: rotate(180deg);
}

.accordion-content {
    display: none;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.collapsible-card.active .accordion-content {
    display: block;
    animation: fadeIn 0.3s ease;
}

.help-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}

.model-info-box {
    margin-top: 0.6rem;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.model-info-box code {
    background: rgba(0, 0, 0, 0.4);
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    color: var(--accent-cyan);
}

/* Labels Chip Grid */
.labels-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.label-chip {
    padding: 0.35rem 0.75rem;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.label-chip.active-chip {
    background: rgba(99, 102, 241, 0.2);
    border-color: var(--primary);
    color: var(--accent-cyan);
    font-weight: 600;
}

/* 7. VISION & AI PANEL (RIGHT COLUMN) */
.vision-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

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

.badge-secondary {
    font-size: 0.75rem;
    padding: 0.2rem 0.6rem;
    border-radius: var(--radius-full);
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
}

/* Challenge Box */
.challenge-box {
    background: rgba(15, 23, 42, 0.8);
    border: 2px solid var(--border-glow);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    text-align: center;
    position: relative;
    transition: all var(--transition-smooth);
}

.challenge-box.highlight-challenge {
    border-color: var(--accent-cyan);
    box-shadow: 0 0 20px rgba(6, 182, 212, 0.25);
}

.challenge-badge {
    display: inline-block;
    padding: 0.2rem 0.75rem;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-full);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 0.5rem;
}

.challenge-item-name span {
    display: block;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

.challenge-item-name h3 {
    font-family: var(--font-heading);
    font-size: 1.8rem;
    font-weight: 800;
    color: var(--accent-cyan);
    letter-spacing: 0.5px;
    margin-top: 0.1rem;
}

/* Hold Timer Bar */
.hold-timer-wrapper {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.hold-timer-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent-emerald);
    margin-bottom: 0.4rem;
}

.hold-progress-bar {
    width: 100%;
    height: 10px;
    background: rgba(0, 0, 0, 0.5);
    border-radius: var(--radius-full);
    overflow: hidden;
    padding: 2px;
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.hold-progress-fill {
    height: 100%;
    background: var(--grad-success);
    border-radius: var(--radius-full);
    transition: width 0.1s linear;
}

/* WEBCAM VIEWPORT */
.webcam-viewport {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#webcamVideo, #webcamCanvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.webcam-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.placeholder-icon {
    font-size: 3rem;
    color: var(--text-muted);
    opacity: 0.6;
}

.webcam-placeholder p {
    font-size: 0.88rem;
    max-width: 280px;
}

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

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

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

.scanner-line {
    position: absolute;
    width: 100%;
    height: 2px;
    background: var(--accent-cyan);
    box-shadow: 0 0 10px var(--accent-cyan);
    animation: scanLine 2s infinite ease-in-out;
}

@keyframes scanLine {
    0% { top: 0; opacity: 0.8; }
    50% { top: 100%; opacity: 0.8; }
    100% { top: 0; opacity: 0.8; }
}

/* PREDICTION RESULTS LIST */
.prediction-results-container {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.85rem;
}

.results-header h3 {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
}

.threshold-tag {
    font-size: 0.72rem;
    color: var(--accent-amber);
    background: rgba(245, 158, 11, 0.15);
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius-full);
}

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

.prediction-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.pred-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.82rem;
    font-weight: 600;
}

.pred-label {
    color: var(--text-secondary);
}

.pred-item.matched .pred-label {
    color: var(--accent-emerald);
    font-weight: 700;
}

.pred-value {
    color: var(--text-primary);
    font-family: var(--font-heading);
}

.pred-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.pred-bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-full);
    transition: width 0.15s ease-out, background-color 0.2s ease;
}

.pred-item.matched .pred-bar-fill {
    background: var(--grad-success);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.empty-state-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-align: center;
    padding: 0.75rem;
}

/* 8. FOOTER */
.app-footer {
    text-align: center;
    padding: 1rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border-color);
    margin-top: auto;
}

/* 9. UTILITY CLASSES */
.hidden {
    display: none !important;
}

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

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

/* 10. RESPONSIVE DESIGN (MEDIA QUERIES) */

/* Laptop / Medium Screens (under 1024px) */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Mobile Screens (under 640px) */
@media (max-width: 640px) {
    .app-container {
        padding: 0.85rem;
        gap: 1rem;
    }

    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.85rem;
        padding: 1rem;
    }

    .header-status {
        width: 100%;
        justify-content: space-between;
    }

    .alarm-time-large {
        font-size: 2.2rem;
    }

    .challenge-item-name h3 {
        font-size: 1.4rem;
    }

    .button-group, .utility-buttons {
        flex-direction: column;
    }

    .alarm-banner-content {
        flex-direction: column;
        text-align: center;
    }
}
