/* ==========================================================================
   AI Analisis Aktivitas Siswa - Style System
   Theme: Calming & Focused (Deep Ocean Navy, Sage Green, Slate, Muted Gold)
   ========================================================================== */

:root {
  /* Color Tokens */
  --bg-primary: #0b132b;
  --bg-secondary: #111d38;
  --card-bg: rgba(23, 37, 68, 0.72);
  --card-border: rgba(255, 255, 255, 0.08);
  --card-glow: rgba(58, 134, 255, 0.12);

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

  /* Theme Accents */
  --accent-sage: #52b788;
  --accent-sage-glow: rgba(82, 183, 136, 0.35);
  --accent-ocean: #3a86ff;
  --accent-ocean-glow: rgba(58, 134, 255, 0.35);
  --accent-cyan: #00b4d8;
  --accent-amber: #f59e0b;
  --accent-amber-glow: rgba(245, 158, 11, 0.35);
  --accent-rose: #ef4444;
  --accent-purple: #8b5cf6;

  /* Dimensions & Radius */
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  /* Shadows & Glass */
  --shadow-card: 0 20px 45px -10px rgba(0, 0, 0, 0.5), 0 0 1px 1px rgba(255, 255, 255, 0.08);
  --shadow-button: 0 4px 14px 0 rgba(0, 0, 0, 0.25);
  --glass-blur: blur(16px);
  --transition-smooth: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  line-height: 1.6;
}

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

.bg-glow-1 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, var(--accent-ocean) 0%, transparent 70%);
  top: -100px;
  left: -100px;
}

.bg-glow-2 {
  width: 550px;
  height: 550px;
  background: radial-gradient(circle, var(--accent-sage) 0%, transparent 70%);
  bottom: -120px;
  right: -100px;
}

/* Container */
.app-container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

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

.badge-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 1rem;
  border-radius: var(--radius-full);
  background: rgba(58, 134, 255, 0.12);
  border: 1px solid rgba(58, 134, 255, 0.3);
  color: var(--accent-cyan);
  font-size: 0.825rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-sage);
  box-shadow: 0 0 10px var(--accent-sage);
  animation: pulse-glow 2s infinite ease-in-out;
}

@keyframes pulse-glow {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.6; }
}

.main-title {
  font-family: 'Outfit', sans-serif;
  font-size: clamp(2rem, 4vw, 2.75rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 30%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 1rem;
  max-width: 650px;
}

.subtitle strong {
  color: var(--text-primary);
}

/* Dashboard Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 1.75rem;
  align-items: stretch;
}

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

/* Modern Card Glassmorphism */
.card {
  background: var(--card-bg);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: var(--transition-smooth);
}

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

.card-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.02);
}

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

.card-icon {
  font-size: 1.15rem;
  color: var(--accent-cyan);
}

.card-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-primary);
}

.status-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.status-standby {
  background: rgba(100, 116, 139, 0.2);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.3);
}

.status-live {
  background: rgba(82, 183, 136, 0.15);
  color: var(--accent-sage);
  border: 1px solid rgba(82, 183, 136, 0.4);
}

.status-live i {
  color: var(--accent-sage);
  animation: pulse-glow 1.5s infinite ease-in-out;
}

.status-fps {
  background: rgba(58, 134, 255, 0.12);
  color: var(--accent-ocean);
  border: 1px solid rgba(58, 134, 255, 0.25);
  font-family: monospace;
}

.card-body {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  flex: 1;
}

/* Camera Viewport Wrapper */
.camera-viewport-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  background: #060b17;
  border-radius: var(--radius-md);
  border: 1px solid 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.8);
}

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

.camera-viewport canvas,
.camera-viewport video {
  width: 100% !important;
  height: 100% !important;
  object-fit: cover;
  display: block;
}

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

.placeholder-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
  color: var(--text-muted);
}

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

.camera-placeholder p {
  font-size: 0.85rem;
  max-width: 280px;
}

/* Scanline and Corner Accents */
.scanline {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent-cyan), transparent);
  box-shadow: 0 0 15px var(--accent-cyan);
  animation: scan-move 3s linear infinite;
  pointer-events: none;
  z-index: 3;
}

@keyframes scan-move {
  0% { top: 0%; opacity: 0; }
  15% { opacity: 1; }
  85% { opacity: 1; }
  100% { top: 100%; opacity: 0; }
}

.camera-corner {
  position: absolute;
  width: 16px;
  height: 16px;
  border-color: var(--accent-cyan);
  border-style: solid;
  pointer-events: none;
  z-index: 2;
  opacity: 0.7;
}

.camera-corner.top-left { top: 10px; left: 10px; border-width: 2px 0 0 2px; }
.camera-corner.top-right { top: 10px; right: 10px; border-width: 2px 2px 0 0; }
.camera-corner.bottom-left { bottom: 10px; left: 10px; border-width: 0 0 2px 2px; }
.camera-corner.bottom-right { bottom: 10px; right: 10px; border-width: 0 2px 2px 0; }

/* Control Buttons */
.control-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: var(--transition-smooth);
  box-shadow: var(--shadow-button);
}

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

.btn-primary {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  flex: 1;
}

.btn-primary:not(:disabled):hover {
  background: linear-gradient(135deg, #34d399 0%, #10b981 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px -4px var(--accent-sage-glow);
}

.btn-secondary {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-secondary:not(:disabled):hover {
  background: rgba(239, 68, 68, 0.3);
  color: #ffffff;
  transform: translateY(-2px);
}

.btn-outline {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-secondary);
  border: 1px solid var(--card-border);
  padding: 0.75rem 1rem;
}

.btn-outline:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.tip-box {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(58, 134, 255, 0.06);
  border: 1px solid rgba(58, 134, 255, 0.15);
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-size: 0.825rem;
  color: #93c5fd;
}

.tip-box i {
  color: #60a5fa;
  margin-top: 0.15rem;
  font-size: 0.95rem;
}

/* Dominant Prediction Card */
.dominant-card {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  background: rgba(255, 255, 255, 0.03);
  transition: var(--transition-smooth);
}

.dominant-icon-box {
  width: 58px;
  height: 58px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  flex-shrink: 0;
  transition: var(--transition-smooth);
}

.dominant-details {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.dominant-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.dominant-name {
  font-family: 'Outfit', sans-serif;
  font-size: 1.45rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.dominant-prob-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.dominant-score {
  font-weight: 700;
  font-size: 1rem;
  color: var(--text-primary);
}

/* Status variants for Dominant Card */
.dominant-belajar {
  background: rgba(16, 185, 129, 0.08);
  border-color: rgba(16, 185, 129, 0.35);
  box-shadow: 0 0 25px -5px rgba(16, 185, 129, 0.25);
}
.dominant-belajar .dominant-icon-box {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}
.dominant-belajar .dominant-name,
.dominant-belajar .dominant-score {
  color: #34d399;
}

.dominant-tidak-belajar {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.35);
  box-shadow: 0 0 25px -5px rgba(245, 158, 11, 0.25);
}
.dominant-tidak-belajar .dominant-icon-box {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}
.dominant-tidak-belajar .dominant-name,
.dominant-tidak-belajar .dominant-score {
  color: #fbbf24;
}

.dominant-istirahat {
  background: rgba(58, 134, 255, 0.08);
  border-color: rgba(58, 134, 255, 0.35);
  box-shadow: 0 0 25px -5px rgba(58, 134, 255, 0.25);
}
.dominant-istirahat .dominant-icon-box {
  background: rgba(58, 134, 255, 0.2);
  color: #60a5fa;
}
.dominant-istirahat .dominant-name,
.dominant-istirahat .dominant-score {
  color: #60a5fa;
}

/* Dynamic Predictions List */
.predictions-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

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

.predictions-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

.label-container {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.empty-state {
  text-align: center;
  padding: 1.75rem 1rem;
  border-radius: var(--radius-md);
  border: 1px dashed rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.empty-state i {
  font-size: 1.75rem;
  color: var(--text-muted);
}

.empty-state p {
  font-size: 0.85rem;
  max-width: 320px;
}

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

.prediction-item.is-top {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.12);
}

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

.prediction-name {
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.prediction-item.is-top .prediction-name {
  color: #ffffff;
}

.prediction-percentage {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-secondary);
}

.prediction-item.is-top .prediction-percentage {
  color: #ffffff;
}

.progress-track {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  transition: width 0.2s ease-out, background 0.3s ease;
  background: var(--accent-ocean);
}

/* Color codes per activity type */
.progress-fill.type-belajar {
  background: linear-gradient(90deg, #059669, #10b981);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.progress-fill.type-tidak-belajar {
  background: linear-gradient(90deg, #d97706, #f59e0b);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.progress-fill.type-istirahat {
  background: linear-gradient(90deg, #2563eb, #3b82f6);
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.5);
}

.progress-fill.type-default {
  background: linear-gradient(90deg, #6366f1, #8b5cf6);
}

/* Session Productivity Stats Box */
.session-stats-box {
  margin-top: auto;
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
}

.btn-text-small {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.75rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: var(--transition-smooth);
}

.btn-text-small:hover {
  color: var(--text-primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.stat-item {
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-title {
  font-size: 0.7rem;
  color: var(--text-muted);
  font-weight: 500;
}

.stat-time {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.95rem;
  margin-top: 0.15rem;
}

.stat-belajar .stat-time { color: #34d399; }
.stat-istirahat .stat-time { color: #60a5fa; }
.stat-tidak-belajar .stat-time { color: #fbbf24; }

/* Footer & Model URL Section */
.app-footer {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.model-info-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  padding: 0.85rem 1.25rem;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.model-info-content {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  overflow: hidden;
}

.model-info-content code {
  background: rgba(0, 0, 0, 0.35);
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  color: var(--accent-cyan);
  font-family: monospace;
  word-break: break-all;
}

.btn-model-edit {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--card-border);
  color: var(--text-primary);
  font-size: 0.8rem;
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: var(--transition-smooth);
}

.btn-model-edit:hover {
  background: rgba(255, 255, 255, 0.12);
}

.model-config-panel {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: slide-down 0.25s ease-out;
}

@keyframes slide-down {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.model-config-panel label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.input-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.input-group input {
  flex: 1;
  min-width: 240px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
}

.input-group input:focus {
  outline: none;
  border-color: var(--accent-ocean);
  box-shadow: 0 0 0 2px var(--accent-ocean-glow);
}

.btn-sm {
  padding: 0.5rem 0.9rem;
  font-size: 0.85rem;
}

.helper-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Modals & Loading */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-card {
  background: #131d36;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  padding: 2rem;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  animation: pop-in 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pop-in {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.modal-icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.75rem;
}

.error-icon {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

.modal-card h3 {
  font-family: 'Outfit', sans-serif;
  font-size: 1.25rem;
  color: #ffffff;
}

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

.modal-actions {
  width: 100%;
  margin-top: 0.5rem;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(11, 19, 43, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  z-index: 110;
}

.loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-left-color: var(--accent-sage);
  border-top-color: var(--accent-cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

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

/* Utilities */
.hidden {
  display: none !important;
}
