/* ============================================================
   Creative Cam — Premium Event Camera CSS
   ============================================================ */
:root {
  --primary: #a78bfa;      /* Lavender accent */
  --primary-dark: #7c3aed;
  --accent: #22d3ee;
  --bg: #050508;           /* Deepest black */
  --card: rgba(20, 20, 28, 0.7); /* Glassmorphism base */
  --text: #f8fafc;
  --muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --radius: 16px;
  --blur: blur(12px);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.lucide { width: 16px; height: 16px; stroke-width: 2; vertical-align: -3px; }

/* Topbar */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 20px;
  background: rgba(5, 5, 8, 0.8);
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--border);
}
.topbar h1 { margin: 0; font-size: 16px; font-weight: 800; letter-spacing: 0.03em; display: flex; align-items: center; gap: 8px; }
.logo-icon { color: var(--accent); width: 20px; height: 20px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }

.badge { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; padding: 4px 10px; border-radius: 20px; background: rgba(255,255,255,0.08); font-weight: 600; }
.badge .lucide { width: 12px; height: 12px; }
.badge.ok { color: #4ade80; }
.badge.err { color: #f87171; }
.queue-badge { background: #f59e0b; color: #000; }

.app { max-width: 600px; margin: 0 auto; padding: 16px; display: flex; flex-direction: column; gap: 16px; }

/* Premium Event Context Card */
.event-card {
  background: linear-gradient(145deg, rgba(124, 58, 237, 0.15), rgba(34, 211, 238, 0.05));
  border: 1px solid rgba(167, 139, 250, 0.3);
  border-radius: var(--radius); padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}
.event-info h2 { margin: 4px 0; font-size: 16px; font-weight: 700; color: #fff; }
.event-info p { margin: 0; font-size: 13px; color: var(--primary); font-weight: 600; }
.event-label { font-size: 9px; font-weight: 800; letter-spacing: 0.1em; color: var(--muted); text-transform: uppercase; }
.btn-change-event {
  background: rgba(255,255,255,0.1); color: #fff; border: 1px solid rgba(255,255,255,0.2);
  padding: 8px 12px; border-radius: 8px; font-size: 12px; font-weight: 600; cursor: pointer;
  display: flex; align-items: center; gap: 4px; transition: background 0.2s;
}
.btn-change-event:hover { background: rgba(255,255,255,0.2); }

/* Forms & Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur);
  box-shadow: 0 4px 24px rgba(0,0,0,0.2);
}
.card h2 { margin: 0 0 16px; font-size: 13px; font-weight: 700; color: #fff; text-transform: uppercase; letter-spacing: 0.05em; display: flex; align-items: center; gap: 8px; }
.card h2 .lucide { color: var(--primary); }

label { display: flex; align-items: center; gap: 6px; margin: 12px 0 6px; font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
input, select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 14px; background: rgba(0,0,0,0.3); color: var(--text); font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
input:focus, select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(167,139,250,0.15); background: rgba(0,0,0,0.5); }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* Setup form transition */
.setup-form { display: none; }
.setup-form.active { display: block; animation: slideDown 0.3s ease-out; }

/* FAB Section */
.camera-fab-section {
  display: flex; gap: 12px; align-items: center; justify-content: center;
  margin: 8px 0;
}
.camera-fab {
  flex: 2; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 18px; border: none; border-radius: 100px;
  background: linear-gradient(135deg, var(--primary), #22d3ee);
  color: #000; font-size: 16px; font-weight: 800; letter-spacing: 0.02em;
  box-shadow: 0 10px 30px rgba(167, 139, 250, 0.3);
  cursor: pointer; transition: transform 0.1s, box-shadow 0.2s;
}
.camera-fab:active { transform: scale(0.96); box-shadow: 0 4px 10px rgba(167, 139, 250, 0.2); }
.camera-fab .lucide { width: 22px; height: 22px; }

.photo-btn.secondary {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 18px; border: 1px solid var(--border); border-radius: 100px;
  background: rgba(255,255,255,0.05); color: #fff; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: background 0.2s;
}
.photo-btn.secondary:hover { background: rgba(255,255,255,0.1); }
.photo-btn.secondary .lucide { width: 18px; height: 18px; }

/* Look & Presets */
.card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-head h2 { margin: 0; }
.toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12px; font-weight: 600; color: var(--muted); }
.toggle input { display: none; }
.toggle .slider { position: relative; width: 34px; height: 20px; background: rgba(255,255,255,0.2); border-radius: 20px; transition: background 0.2s; }
.toggle .slider::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; background: #fff; border-radius: 50%; transition: transform 0.2s; }
.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider::after { transform: translateX(14px); }

.thumbs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.thumb { cursor: pointer; text-align: center; font-size: 10px; color: var(--muted); font-weight: 600; letter-spacing: 0.03em; text-transform: uppercase; }
.thumb canvas { width: 100%; aspect-ratio: 1; border-radius: 12px; border: 2px solid transparent; display: block; transition: all 0.2s; background: rgba(0,0,0,0.5); }
.thumb:hover canvas { transform: scale(1.05); }
.thumb.active canvas { border-color: var(--accent); box-shadow: 0 0 12px rgba(34, 211, 238, 0.4); }
.thumb.active { color: var(--accent); }

/* Watermark Chips */
.wm-chips-row { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; align-items: center; }
.wm-chips-label { font-size: 10px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-right: 4px; }
.wm-chip { padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border); background: rgba(255,255,255,0.03); color: #cbd5e1; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s; }
.wm-chip.active { background: var(--primary); color: #000; border-color: var(--primary); }

/* Preview */
.preview-wrap {
  position: relative; width: 100%; border-radius: 12px; overflow: hidden;
  background: rgba(0,0,0,0.4); min-height: 220px;
  display: flex; align-items: center; justify-content: center;
  border: 1px dashed rgba(255,255,255,0.15); margin-bottom: 16px;
}
canvas#preview { max-width: 100%; display: block; }
.preview-empty {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; color: var(--muted);
  text-align: center; font-size: 13px; pointer-events: none; padding: 20px;
}

.action-buttons { display: flex; gap: 8px; }
#btnUpload {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px; border: none; border-radius: 10px;
  background: var(--primary); color: #000; font-size: 14px; font-weight: 800;
  cursor: pointer; transition: background 0.2s;
}
#btnUpload:disabled { opacity: 0.4; cursor: not-allowed; }
#btnUpload .lucide { width: 18px; height: 18px; }

/* Toast */
.toast-container { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 9999; display: flex; flex-direction: column; gap: 8px; pointer-events: none; width: 90%; max-width: 400px; }
.toast { background: rgba(15, 23, 42, 0.95); color: #fff; padding: 12px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; box-shadow: 0 8px 24px rgba(0,0,0,0.5); text-align: center; border-left: 4px solid var(--primary); backdrop-filter: blur(8px); animation: toastIn 0.3s ease-out forwards; }
.toast.ok { border-left-color: #4ade80; }
.toast.err { border-left-color: #f87171; }
@keyframes toastIn { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================
   KAMERA MODAL (Fullscreen Premium)
   ============================================================ */
.live-cam-modal { position: fixed; inset: 0; z-index: 1000; background: #000; display: none; flex-direction: column; color: #fff; }
.live-cam-modal.active { display: flex; }

.live-cam-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 16px; padding-top: calc(16px + env(safe-area-inset-top)); background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent); z-index: 10; }
.live-cam-context { text-align: center; }
.live-cam-title { display: block; font-size: 12px; font-weight: 800; letter-spacing: 0.1em; color: var(--accent); }
.live-cam-subtitle { display: block; font-size: 10px; color: var(--muted); margin-top: 2px; }

.icon-btn { width: 40px; height: 40px; border-radius: 50%; border: none; background: rgba(255,255,255,0.1); color: #fff; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; backdrop-filter: blur(8px); transition: background 0.2s; }
.icon-btn:hover { background: rgba(255,255,255,0.2); }
.icon-btn .lucide { width: 20px; height: 20px; }

.live-cam-stage { flex: 1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; }
.viewport { position: relative; aspect-ratio: 3 / 2; max-width: 100%; max-height: 100%; width: 100%; background: #000; overflow: hidden; }
#liveVideo { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transition: filter 0.25s; }
.overlay-canvas { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }

/* Camera Tools & Chips */
.cam-tools { position: absolute; top: 16px; right: 16px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; pointer-events: none; }
.cam-tools .cam-chip { pointer-events: auto; }
.cam-chip { min-width: 32px; height: 32px; padding: 0 10px; border-radius: 16px; border: 1px solid rgba(255,255,255,0.2); background: rgba(0,0,0,0.4); color: #fff; font-size: 11px; font-weight: 800; backdrop-filter: blur(4px); cursor: pointer; }
.cam-chip.active { background: var(--accent); color: #000; border-color: var(--accent); }
.histogram { width: 120px; height: 60px; background: rgba(0,0,0,0.5); border: 1px solid rgba(255,255,255,0.15); border-radius: 6px; }
.histogram.hidden { display: none; }

/* Bottom Tray */
.camera-bottom-tray { background: linear-gradient(to top, rgba(0,0,0,0.95), rgba(0,0,0,0.8) 80%, transparent); padding-bottom: 10px; }
.ratio-bar { display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto; justify-content: center; scrollbar-width: none; }
.ratio-bar::-webkit-scrollbar { display: none; }
.ratio-chip { padding: 6px 14px; border-radius: 20px; border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.8); font-size: 11px; font-weight: 700; cursor: pointer; white-space: nowrap; backdrop-filter: blur(4px); }
.ratio-chip.active { background: var(--accent); color: #000; border-color: var(--accent); }

.live-cam-presets { display: flex; gap: 16px; padding: 10px 16px; overflow-x: auto; scrollbar-width: none; justify-content: center; }
.live-cam-presets::-webkit-scrollbar { display: none; }
.live-cam-preset-item { flex-shrink: 0; width: 60px; display: flex; flex-direction: column; align-items: center; gap: 6px; cursor: pointer; opacity: 0.6; transition: all 0.2s; }
.live-cam-preset-item.active { opacity: 1; transform: scale(1.1); }
.live-cam-preset-item canvas { width: 56px; height: 56px; border-radius: 50%; border: 2px solid transparent; object-fit: cover; }
.live-cam-preset-item.active canvas { border-color: var(--accent); box-shadow: 0 0 12px rgba(34, 211, 238, 0.4); }
.live-cam-preset-item span { font-size: 9px; font-weight: 700; color: #fff; text-transform: uppercase; }

.mode-row { display: flex; gap: 8px; padding: 10px 16px; overflow-x: auto; justify-content: center; scrollbar-width: none; }
.mode-row::-webkit-scrollbar { display: none; }
.mode-chip { padding: 8px 16px; border-radius: 20px; border: 1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.8); font-size: 11px; font-weight: 700; cursor: pointer; white-space: nowrap; backdrop-filter: blur(4px); }
.mode-chip.active { background: var(--accent); color: #000; border-color: var(--accent); }

/* Live Controls */
.live-cam-controls { display: flex; justify-content: space-around; align-items: center; padding: 16px 24px calc(16px + env(safe-area-inset-bottom)); background: #000; }
.ctrl-btn { width: 48px; height: 48px; }
.ctrl-btn .lucide { width: 24px; height: 24px; }
.shutter-btn { width: 80px; height: 80px; border-radius: 50%; background: transparent; border: 4px solid #fff; cursor: pointer; padding: 0; display: flex; align-items: center; justify-content: center; transition: transform 0.1s; outline: none; }
.shutter-btn span { width: 64px; height: 64px; border-radius: 50%; background: #fff; transition: transform 0.1s; }
.shutter-btn:active span { transform: scale(0.85); background: var(--accent); }
.live-cam-modal.mode-burst .shutter-btn { border-color: #f59e0b; box-shadow: 0 0 20px rgba(245,158,11,0.5); }
.live-cam-modal.mode-bracket .shutter-btn { border-color: var(--accent); box-shadow: 0 0 20px rgba(34,211,238,0.5); }

/* Focus Box, Level, Exposure (Sama seperti sebelumnya, dirapikan) */
.focus-box { display: none; position: absolute; width: 80px; height: 80px; transform: translate(-50%, -50%); border: 1.5px solid #fbbf24; border-radius: 8px; pointer-events: none; z-index: 6; transition: all 0.15s; }
.focus-box.visible { display: block; }
.focus-box.locked { border-color: #4ade80; }
.focus-lock { display: none; position: absolute; top: -10px; right: -10px; width: 20px; height: 20px; background: #4ade80; border-radius: 50%; align-items: center; justify-content: center; font-size: 10px; color: #000; }
.focus-box.locked .focus-lock { display: flex; }

.level-wrap { position: absolute; inset: 0; pointer-events: none; display: flex; align-items: center; justify-content: center; z-index: 3; }
.level-line { width: 40%; height: 2px; background: #4ade80; border-radius: 2px; transition: transform 0.08s linear; }
.level-line.warn { background: #fbbf24; }
.level-line.bad  { background: #ef4444; }

.exposure-panel { position: absolute; left: 16px; right: 16px; bottom: 16px; background: rgba(15, 23, 42, 0.85); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 12px; padding: 12px 16px; z-index: 4; backdrop-filter: blur(12px); display: flex; flex-direction: column; gap: 8px; }
.exposure-row { display: flex; align-items: center; gap: 12px; }
.exp-label { color: rgba(255,255,255,0.7); font-size: 10px; font-weight: 800; min-width: 36px; text-transform: uppercase; }
.exposure-row input[type=range] { flex: 1; accent-color: var(--accent); height: 20px; }
.exp-val { color: #fff; font-size: 11px; font-weight: 600; min-width: 32px; text-align: right; font-variant-numeric: tabular-nums; }

/* Grading Room & Burst Modal (Sama seperti sebelumnya) */
.grading-room { position: fixed; inset: 0; z-index: 2000; background: #050508; display: none; flex-direction: column; }
.grading-room.active { display: flex; }
.grading-header { display: flex; justify-content: space-between; align-items: center; padding: 16px; padding-top: calc(16px + env(safe-area-inset-top)); background: rgba(20,20,28,0.9); border-bottom: 1px solid var(--border); }
.grading-preview { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; }
#gradingCanvas { max-width: 100%; max-height: 100%; border-radius: 8px; }
.grading-controls { background: rgba(20,20,28,0.9); padding: 20px; padding-bottom: calc(20px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 12px; }
.grading-controls .exp-label { width: 80px; }
.split-toning-row { display: flex; gap: 16px; background: rgba(255,255,255,0.03); padding: 10px; border-radius: 8px; }
.tone-group { flex: 1; display: flex; flex-direction: column; gap: 8px; }
.tone-group input[type="color"] { width: 100%; height: 32px; border: none; border-radius: 4px; cursor: pointer; }
.grading-actions { display: flex; gap: 10px; margin-top: 12px; justify-content: flex-end; }

.burst-modal { display: none; position: absolute; inset: 0; z-index: 60; background: rgba(0,0,0,0.95); flex-direction: column; align-items: center; justify-content: center; gap: 20px; padding: 20px; backdrop-filter: blur(10px); }
.burst-modal.active { display: flex; }
.burst-title { color: #fff; margin: 0; font-size: 18px; font-weight: 700; }
.burst-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; max-width: 520px; width: 100%; }
.burst-item { position: relative; border: 2px solid rgba(255,255,255,0.1); border-radius: 12px; overflow: hidden; background: #1e293b; cursor: pointer; aspect-ratio: 1; padding: 0; }
.burst-item img { width: 100%; height: 100%; object-fit: cover; }
.burst-num { position: absolute; top: 8px; left: 8px; background: rgba(0,0,0,0.7); color: #fff; width: 24px; height: 24px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; }
/* ============================================================
   Fix UI: Bottom Nav, Overlay, Disabled State
   ============================================================ */

/* 1. Beri ruang di bawah agar tidak tertutup Nav */
.app { padding-bottom: 100px; }

/* 2. Fixed Bottom Navigation Bar */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 500;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px 24px; padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.nav-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: transparent; border: none; color: var(--muted);
  font-size: 10px; font-weight: 600; cursor: pointer; width: 60px;
}
.nav-btn .lucide { width: 22px; height: 22px; }
.nav-btn:active { color: #fff; }

.camera-fab {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 16px; border: none; border-radius: 100px;
  background: linear-gradient(135deg, var(--primary), #22d3ee);
  color: #000; font-size: 16px; font-weight: 800; letter-spacing: 0.02em;
  box-shadow: 0 8px 24px rgba(167, 139, 250, 0.4);
  cursor: pointer; transition: transform 0.1s;
}
.camera-fab:active { transform: scale(0.95); }

/* 3. Pastikan Overlay Gallery benar-benar fullscreen */
.gallery-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: #050508;
  display: none; /* Default tersembunyi */
  flex-direction: column;
}
.gallery-overlay.active { display: flex !important; }

/* 4. Perbaiki Tombol Upload saat disabled */
#btnUpload:disabled {
  background: rgba(167, 139, 250, 0.2);
  color: rgba(255, 255, 255, 0.3);
  box-shadow: none;
}
#btnUpload:not(:disabled) {
  background: var(--primary);
  color: #000;
}

/* 5. Rapikan Empty State Pratinjau */
.preview-wrap {
  min-height: 180px; /* Lebih pendek agar tidak terlalu banyak ruang kosong */
}
