/* ==========================================================================
   STYLE.CSS - PENGINGAT TUGAS SEKOLAH (TEACHABLE MACHINE & TENSORFLOW.JS)
   Nuansa Alam & Rempah Hangat: Sage Green, Forest Green, Warm Sand & Cinnamon Wood
   ========================================================================== */

/* --- CSS Variables & Color Tokens --- */
:root {
    /* Color Palette: Earthy, Sage, Wood & Cream */
    --bg-main: #f5f2eb;
    --bg-pattern-1: #e4eee4;
    --bg-pattern-2: #faeedd;
    --bg-card: rgba(255, 255, 255, 0.88);
    --bg-card-subtle: #fcfbf9;
    
    --primary-forest: #234d34;
    --primary-forest-hover: #1c3f2b;
    --primary-emerald: #3b7a57;
    --primary-sage: #88a38b;
    --primary-sage-light: #e8f0e9;

    --accent-wood: #8c5932;
    --accent-wood-hover: #754826;
    --accent-sand: #f0e6d6;
    --accent-terracotta: #c46d3b;

    --text-main: #1d2720;
    --text-muted: #5e6d62;
    --text-light: #8b998e;
    --text-white: #ffffff;

    --border-color: rgba(35, 77, 52, 0.12);
    --border-highlight: rgba(140, 89, 50, 0.25);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 22px;
    --radius-full: 9999px;

    --shadow-sm: 0 2px 6px rgba(35, 77, 52, 0.05);
    --shadow-md: 0 10px 25px -5px rgba(35, 77, 52, 0.08), 0 8px 10px -6px rgba(35, 77, 52, 0.04);
    --shadow-lg: 0 20px 35px -10px rgba(35, 77, 52, 0.12), 0 10px 15px -5px rgba(140, 89, 50, 0.08);

    --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);
}

/* --- Base Reset & Typography --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    min-height: 100vh;
    background-color: var(--bg-main);
    background-image: 
        radial-gradient(at 15% 15%, rgba(136, 163, 139, 0.22) 0px, transparent 55%),
        radial-gradient(at 85% 20%, rgba(240, 230, 214, 0.8) 0px, transparent 50%),
        radial-gradient(at 70% 85%, rgba(196, 109, 59, 0.12) 0px, transparent 60%),
        radial-gradient(at 20% 80%, rgba(59, 122, 87, 0.15) 0px, transparent 50%);
    background-attachment: fixed;
    font-family: var(--font-body);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    position: relative;
}

/* Ambient Floating Shapes */
.bg-shape {
    position: fixed;
    border-radius: 50%;
    filter: blur(80px);
    z-index: -1;
    pointer-events: none;
}
.shape-1 {
    width: 380px;
    height: 380px;
    top: -100px;
    left: -100px;
    background: rgba(59, 122, 87, 0.18);
}
.shape-2 {
    width: 450px;
    height: 450px;
    bottom: -150px;
    right: -100px;
    background: rgba(140, 89, 50, 0.14);
}
.shape-3 {
    width: 300px;
    height: 300px;
    top: 40%;
    right: 20%;
    background: rgba(136, 163, 139, 0.15);
}

/* --- Layout Wrapper --- */
.main-wrapper {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 20px 48px;
    display: flex;
    flex-direction: column;
    gap: 32px;
}

/* --- Header Section --- */
.app-header {
    text-align: center;
    max-width: 760px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.header-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-sage-light);
    color: var(--primary-forest);
    border: 1px solid rgba(59, 122, 87, 0.25);
    padding: 6px 16px;
    border-radius: var(--radius-full);
    font-size: 0.875rem;
    font-weight: 600;
    box-shadow: var(--shadow-sm);
}

.badge-icon {
    font-size: 1.1rem;
}

.app-title {
    font-family: var(--font-heading);
    font-size: clamp(2rem, 4vw, 2.75rem);
    font-weight: 800;
    color: var(--primary-forest);
    line-height: 1.2;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--primary-forest) 0%, var(--accent-wood) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

/* --- Dashboard Grid --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    gap: 28px;
    align-items: start;
}

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

/* --- Card Base Styling --- */
.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);
    padding: 24px;
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    gap: 20px;
    transition: var(--transition-smooth);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--border-highlight);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    border-bottom: 1px solid rgba(35, 77, 52, 0.08);
    padding-bottom: 16px;
}

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

.section-icon {
    font-size: 1.5rem;
    background: var(--accent-sand);
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.card-header h2 {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--primary-forest);
}

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

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

.status-pill.idle {
    background: #e9ecef;
    color: #495057;
}

.status-pill.loading {
    background: #fff3cd;
    color: #856404;
}

.status-pill.active {
    background: #d4edda;
    color: #155724;
}

.status-pill.error {
    background: #f8d7da;
    color: #721c24;
}

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

.status-pill.active .status-dot {
    animation: pulse 1.5s infinite;
}

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

/* --- Camera Viewport --- */
.camera-viewport-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 4 / 3;
    max-height: 400px;
    background: #111b15;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid rgba(59, 122, 87, 0.2);
    box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.4);
}

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

.webcam-container canvas,
.webcam-container video {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    border-radius: calc(var(--radius-md) - 2px);
}

/* Camera Placeholder */
.camera-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
    color: #d1dcce;
    gap: 12px;
}

.placeholder-icon-circle {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.camera-svg {
    width: 32px;
    height: 32px;
    stroke: var(--primary-sage);
}

.camera-placeholder h3 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 600;
    color: #ffffff;
}

.camera-placeholder p {
    font-size: 0.875rem;
    color: #a4b3a2;
    max-width: 280px;
}

/* Scanning Overlay Effect */
.scan-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.scan-overlay.hidden {
    display: none;
}

.scan-line {
    position: absolute;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, #52b788, #74c69d, transparent);
    box-shadow: 0 0 12px #52b788;
    animation: scanMove 2.8s ease-in-out infinite alternate;
}

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

.scan-corner {
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid #52b788;
}
.scan-corner.top-left { top: 12px; left: 12px; border-right: none; border-bottom: none; }
.scan-corner.top-right { top: 12px; right: 12px; border-left: none; border-bottom: none; }
.scan-corner.bottom-left { bottom: 12px; left: 12px; border-right: none; border-top: none; }
.scan-corner.bottom-right { bottom: 12px; right: 12px; border-left: none; border-top: none; }

/* Alert Box */
.alert-box {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fdf2e9;
    border: 1px solid #f0bc94;
    color: #8f3d0e;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
}

.alert-box.hidden {
    display: none;
}

/* Controls Buttons */
.card-controls {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

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

.btn-icon svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-forest) 0%, var(--primary-emerald) 100%);
    color: var(--text-white);
    box-shadow: 0 4px 14px rgba(35, 77, 52, 0.25);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-forest-hover) 0%, var(--primary-forest) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(35, 77, 52, 0.35);
}

.btn-primary.active {
    background: linear-gradient(135deg, #a63a2a 0%, #c44d38 100%);
    box-shadow: 0 4px 14px rgba(166, 58, 42, 0.3);
}

.btn-secondary {
    background: var(--accent-sand);
    color: var(--accent-wood);
    border: 1px solid rgba(140, 89, 50, 0.2);
}

.btn-secondary:hover:not(:disabled) {
    background: #e6dbcb;
    color: var(--accent-wood-hover);
    transform: translateY(-2px);
}

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

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

/* --- Right Card: Results & Highlights --- */
.highlight-container {
    background: linear-gradient(135deg, #f8fbf9 0%, #fdfbf7 100%);
    border: 1px solid rgba(59, 122, 87, 0.18);
    border-radius: var(--radius-md);
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-sm);
}

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

.highlight-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.highlight-badge-group {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.top-class-badge {
    font-family: var(--font-heading);
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-forest);
    flex: 1;
    word-break: break-word;
}

.top-accuracy-badge {
    background: var(--primary-forest);
    color: #ffffff;
    padding: 6px 14px;
    border-radius: var(--radius-full);
    font-weight: 700;
    font-size: 0.95rem;
    letter-spacing: -0.01em;
    box-shadow: 0 2px 8px rgba(35, 77, 52, 0.2);
}

/* Reminder Banner */
.reminder-banner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid rgba(140, 89, 50, 0.18);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.reminder-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
}

.reminder-text-group h4 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--accent-wood);
    margin-bottom: 2px;
}

.reminder-text-group p {
    font-size: 0.85rem;
    color: var(--text-muted);
    line-height: 1.4;
}

/* --- Predictions Section & Progress Bars --- */
.predictions-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
}

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

.predictions-header h3 {
    font-family: var(--font-heading);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--primary-forest);
}

.live-tag {
    font-size: 0.7rem;
    font-weight: 700;
    color: #2b744a;
    background: #e2f5ea;
    border: 1px solid #b5e4c6;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    letter-spacing: 0.05em;
}

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

.empty-predictions {
    padding: 24px;
    text-align: center;
    color: var(--text-light);
    font-size: 0.875rem;
    background: rgba(0, 0, 0, 0.02);
    border-radius: var(--radius-md);
    border: 1px dashed rgba(35, 77, 52, 0.15);
}

/* Individual Prediction Item */
.prediction-item {
    background: #ffffff;
    border: 1px solid rgba(35, 77, 52, 0.09);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
    transition: var(--transition-smooth);
}

.prediction-item.is-top {
    border-color: rgba(59, 122, 87, 0.4);
    background: #fcfefc;
    box-shadow: 0 4px 12px rgba(59, 122, 87, 0.08);
}

.prediction-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.92rem;
}

.prediction-name {
    font-weight: 600;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 6px;
}

.prediction-percentage {
    font-weight: 700;
    color: var(--primary-forest);
    font-size: 0.95rem;
}

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

.progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6ba17f 0%, #35734d 100%);
    border-radius: var(--radius-full);
    transition: width 0.18s ease-out;
}

.prediction-item.is-top .progress-fill {
    background: linear-gradient(90deg, var(--accent-terracotta) 0%, var(--accent-wood) 50%, var(--primary-forest) 100%);
}

/* --- Task Tips Box --- */
.task-tips-card {
    margin-top: auto;
    background: #f7f3eb;
    border: 1px solid #e3d9c8;
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.tips-icon {
    font-size: 1.4rem;
    flex-shrink: 0;
}

.tips-content {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.tips-content strong {
    color: var(--primary-forest);
    display: block;
    margin-bottom: 2px;
}

/* --- Footer --- */
.app-footer {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-top: 12px;
    border-top: 1px solid rgba(35, 77, 52, 0.08);
}

.app-footer strong {
    color: var(--primary-forest);
}

/* --- Responsive Adjustments --- */
@media (max-width: 640px) {
    .main-wrapper {
        padding: 20px 14px 36px;
        gap: 24px;
    }

    .card {
        padding: 18px 16px;
    }

    .card-controls {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    .top-class-badge {
        font-size: 1.1rem;
    }
}
