/* ==========================================================================
   CSS: Proyek Pembeda Wajah Orang (Teachable Machine AI)
   Tema: Modern School / Kampus (Langit Biru, Hijau Daun, Krem Hangat)
   ========================================================================== */

:root {
    /* Skema Warna Sekolah Ceria & Segar */
    --primary-blue: #0284c7;       /* Langit Biru Utama */
    --primary-blue-dark: #0369a1;
    --primary-blue-light: #e0f2fe;
    --leaf-green: #10b981;        /* Hijau Dedaunan */
    --leaf-green-dark: #047857;
    --leaf-green-light: #ecfdf5;
    --cream-bg: #fdfbf7;          /* Krem Lembut */
    --amber-gold: #f59e0b;        /* Kuning Emas Sekolah */
    --amber-light: #fef3c7;
    --coral-red: #ef4444;         /* Merah Notifikasi / Stop */
    --coral-light: #fee2e2;

    /* Warna Netral & Teks */
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --card-bg: rgba(255, 255, 255, 0.94);
    --border-color: rgba(226, 232, 240, 0.9);

    /* Efek & Radius */
    --shadow-soft: 0 10px 30px -5px rgba(2, 132, 199, 0.08), 0 4px 12px -2px rgba(0, 0, 0, 0.03);
    --shadow-hover: 0 20px 40px -10px rgba(2, 132, 199, 0.16), 0 8px 16px -4px rgba(0, 0, 0, 0.05);
    --radius-xl: 24px;
    --radius-lg: 18px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --radius-pill: 9999px;

    /* Transisi */
    --transition-smooth: all 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(145deg, #f0f9ff 0%, #f4fbf7 40%, #fdfbf7 100%);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    overflow-x: hidden;
    padding: 24px 16px;
}

/* Background Animated Blobs / Shapes */
.bg-shape {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    opacity: 0.6;
    pointer-events: none;
    animation: floatShape 16s ease-in-out infinite alternate;
}

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

.shape-2 {
    width: 360px;
    height: 360px;
    background: #bbf7d0;
    bottom: -80px;
    right: -80px;
    animation-delay: -5s;
}

.shape-3 {
    width: 280px;
    height: 280px;
    background: #fde68a;
    top: 50%;
    right: 15%;
    animation-delay: -9s;
}

@keyframes floatShape {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(30px, 20px) scale(1.05); }
    100% { transform: translate(-20px, 35px) scale(0.95); }
}

/* App Container */
.app-container {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

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

.school-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary-blue-light), var(--leaf-green-light));
    color: var(--primary-blue-dark);
    font-size: 0.85rem;
    font-weight: 700;
    padding: 6px 16px;
    border-radius: var(--radius-pill);
    border: 1px solid rgba(2, 132, 199, 0.2);
    box-shadow: 0 2px 8px rgba(2, 132, 199, 0.08);
}

.school-badge i {
    font-size: 1rem;
    color: var(--primary-blue);
}

.main-title {
    font-size: clamp(1.8rem, 4vw, 2.5rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
    line-height: 1.2;
}

.gradient-text {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--leaf-green) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    font-size: 0.98rem;
    color: var(--text-secondary);
    max-width: 600px;
    line-height: 1.6;
}

.badge-person {
    background: #ffffff;
    padding: 2px 8px;
    border-radius: 6px;
    font-weight: 600;
    color: var(--primary-blue);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* ==========================================================================
   Alert / Error Box
   ========================================================================== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    background: var(--coral-light);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #991b1b;
    box-shadow: var(--shadow-soft);
    animation: fadeIn 0.3s ease-out;
}

.alert i {
    font-size: 1.2rem;
    color: var(--coral-red);
    margin-top: 2px;
}

.alert-content strong {
    display: block;
    font-size: 0.95rem;
    margin-bottom: 2px;
}

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

.alert-close {
    margin-left: auto;
    background: transparent;
    border: none;
    cursor: pointer;
    color: #991b1b;
    padding: 4px;
    font-size: 1rem;
    opacity: 0.7;
    transition: var(--transition-smooth);
}

.alert-close:hover {
    opacity: 1;
}

/* ==========================================================================
   Main Grid Layout
   ========================================================================== */
.main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

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

/* ==========================================================================
   Card Styling
   ========================================================================== */
.card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-soft);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: var(--transition-smooth);
}

.card:hover {
    box-shadow: var(--shadow-hover);
}

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

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

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

.card-icon.blue {
    background: var(--primary-blue-light);
    color: var(--primary-blue);
}

.card-icon.green {
    background: var(--leaf-green-light);
    color: var(--leaf-green);
}

.card-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: var(--radius-pill);
    font-size: 0.8rem;
    font-weight: 600;
    transition: var(--transition-smooth);
}

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

.status-idle {
    background: #f1f5f9;
    color: var(--text-secondary);
}
.status-idle .status-dot {
    background: var(--text-muted);
}

.status-loading {
    background: var(--amber-light);
    color: #92400e;
}
.status-loading .status-dot {
    background: var(--amber-gold);
    animation: pulseDot 1s infinite;
}

.status-active {
    background: var(--leaf-green-light);
    color: var(--leaf-green-dark);
}
.status-active .status-dot {
    background: var(--leaf-green);
    animation: pulseDot 1.5s infinite;
}

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

.model-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.model-badge i {
    color: var(--primary-blue);
}

/* ==========================================================================
   Webcam Area & Video Stream
   ========================================================================== */
.webcam-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 380px;
    margin: 0 auto;
    border-radius: var(--radius-lg);
    background: #0f172a;
    border: 2px solid rgba(2, 132, 199, 0.2);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.4);
}

.camera-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 30px 20px;
    color: #e2e8f0;
    gap: 12px;
    z-index: 2;
}

.placeholder-icon {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: var(--primary-blue-light);
    border: 1px solid rgba(255, 255, 255, 0.15);
    margin-bottom: 4px;
}

.camera-placeholder h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
}

.camera-placeholder p {
    font-size: 0.85rem;
    color: #94a3b8;
    max-width: 280px;
    line-height: 1.5;
}

.camera-placeholder strong {
    color: #38bdf8;
}

/* Container Canvas TM */
.webcam-container {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Efek Scanning Laser */
.scan-laser {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, transparent, #38bdf8, #10b981, transparent);
    box-shadow: 0 0 16px #38bdf8, 0 0 8px #10b981;
    z-index: 3;
    pointer-events: none;
    animation: scanAnim 2.8s ease-in-out infinite;
}

@keyframes scanAnim {
    0% { top: 0%; opacity: 0.2; }
    50% { top: 96%; opacity: 0.9; }
    100% { top: 0%; opacity: 0.2; }
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.camera-controls {
    display: flex;
    gap: 12px;
}

.btn {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    border: none;
    transition: var(--transition-smooth);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

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

.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue), #0284c7);
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(2, 132, 199, 0.35);
}

.btn-primary:hover {
    background: linear-gradient(135deg, #0369a1, #0284c7);
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(2, 132, 199, 0.45);
}

.btn-danger {
    background: linear-gradient(135deg, var(--coral-red), #dc2626);
    color: #ffffff;
    box-shadow: 0 6px 18px rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #dc2626, #b91c1c);
    transform: translateY(-2px);
    box-shadow: 0 8px 22px rgba(239, 68, 68, 0.4);
}

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

/* ==========================================================================
   Top Match Highlight Banner
   ========================================================================== */
.top-match-banner {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    background: linear-gradient(135deg, #ffffff, #f0fdf4);
    border: 2px solid var(--leaf-green-light);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.08);
    transition: var(--transition-smooth);
}

.top-match-banner.waiting {
    background: #f8fafc;
    border-color: var(--border-color);
    box-shadow: none;
}

.top-match-banner.matched {
    background: linear-gradient(135deg, #ecfdf5, #f0f9ff);
    border-color: var(--leaf-green);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.18);
    transform: scale(1.01);
}

.match-icon {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--primary-blue-light);
    color: var(--primary-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    flex-shrink: 0;
    transition: var(--transition-smooth);
}

.top-match-banner.matched .match-icon {
    background: var(--leaf-green);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.35);
}

.match-info {
    flex: 1;
}

.match-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 700;
    color: var(--text-muted);
}

.top-match-banner h3 {
    font-size: 1.3rem;
    font-weight: 800;
    color: var(--text-primary);
    text-transform: capitalize;
    margin-top: 2px;
}

.match-confidence {
    text-align: right;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.confidence-number {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--primary-blue);
}

.top-match-banner.matched .confidence-number {
    color: var(--leaf-green-dark);
}

.confidence-tag {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--text-muted);
}

/* ==========================================================================
   Prediction List & Progress Bars
   ========================================================================== */
.prediction-list-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.list-heading {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.list-heading i {
    color: var(--primary-blue);
}

.label-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.empty-state {
    text-align: center;
    padding: 24px 16px;
    background: #f8fafc;
    border-radius: var(--radius-md);
    border: 1px dashed var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.empty-state i {
    font-size: 1.8rem;
    color: #cbd5e1;
}

/* Item Prediksi Tiap Baris */
.prediction-item {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    transition: var(--transition-smooth);
}

.prediction-item:hover {
    border-color: rgba(2, 132, 199, 0.3);
    transform: translateX(3px);
}

.prediction-item.is-highest {
    border-color: var(--leaf-green);
    background: linear-gradient(135deg, #ffffff 60%, var(--leaf-green-light));
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.12);
}

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

.item-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary-blue-light);
    color: var(--primary-blue);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 800;
    text-transform: uppercase;
}

.prediction-item.is-highest .user-avatar {
    background: var(--leaf-green);
    color: #ffffff;
}

.user-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
    text-transform: capitalize;
}

.item-percent {
    font-size: 0.9rem;
    font-weight: 800;
    color: var(--primary-blue);
}

.prediction-item.is-highest .item-percent {
    color: var(--leaf-green-dark);
}

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

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-blue), #38bdf8);
    border-radius: var(--radius-pill);
    transition: width 0.18s cubic-bezier(0.4, 0, 0.2, 1), background 0.28s ease;
}

.prediction-item.is-highest .progress-fill {
    background: linear-gradient(90deg, var(--leaf-green), #34d399);
}

/* ==========================================================================
   Tips Box
   ========================================================================== */
.tips-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    background: #f8fafc;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.45;
}

.tips-box i {
    color: var(--amber-gold);
    font-size: 1rem;
    margin-top: 2px;
}

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

.app-footer strong {
    color: var(--text-secondary);
}

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