/* ═══════════════════════════════════════════════════════════════
   DocuMentor v4 — css/main.css
   Base reset, variables, overlays, toasts & utilities
   ═══════════════════════════════════════════════════════════════ */

/* ─── Reset ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select { font-family: inherit; }
a { text-decoration: none; color: inherit; }

/* ─── Tokens: Dark (default) ────────────────────────────────── */
:root {
  --bg0: #0a0a0c;
  --bg1: #111114;
  --bg2: #18181c;
  --bg3: #1e1e24;
  --bg4: #26262e;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.12);
  --text0: #f1f2f4;
  --text1: #a1a3aa;
  --text2: #5a5c66;
  --accent: #22c55e;
  --accent-d: #16a34a;
  --accent-dim: rgba(34,197,94,0.12);
  --red: #ef4444;
  --shadow: 0 8px 32px rgba(0,0,0,0.6);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.4);
  --r1: 6px;
  --r2: 10px;
  --r3: 14px;
  --transition: 0.18s cubic-bezier(0.4,0,0.2,1);
  --header-h: 52px;
  --strip-w: 110px;
  --panel-w: 264px;
  --mob-nav-h: 60px;
}

[data-theme="light"] {
  --bg0: #f0f0f4;
  --bg1: #ffffff;
  --bg2: #f5f5f8;
  --bg3: #ebebef;
  --bg4: #e0e0e6;
  --border: rgba(0,0,0,0.07);
  --border2: rgba(0,0,0,0.14);
  --text0: #111114;
  --text1: #444450;
  --text2: #888895;
  --shadow: 0 8px 32px rgba(0,0,0,0.1);
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.08);
}

[data-theme="oled"] {
  --bg0: #000000;
  --bg1: #000000;
  --bg2: #080808;
  --bg3: #111111;
  --bg4: #1a1a1a;
  --border: rgba(255,255,255,0.05);
  --border2: rgba(255,255,255,0.1);
}

/* ─── Base Layout ────────────────────────────────────────────── */
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg0);
  color: var(--text0);
  -webkit-font-smoothing: antialiased;
  font-size: 13px;
  line-height: 1.5;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

#body-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.hidden { display: none !important; }

/* Scrollbars */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }

/* Buttons */
.icon-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r1);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text1);
  transition: var(--transition);
}
.icon-btn:hover { background: var(--bg3); color: var(--text0); }
.icon-btn:disabled { opacity: 0.35; pointer-events: none; }
.icon-btn.sm { width: 26px; height: 26px; font-size: 14px; font-weight: 600; }
.icon-btn.danger { color: var(--red); }
.icon-btn.danger:hover { background: rgba(239, 68, 68, 0.15); color: var(--red); }

.hdr-sep { width: 1px; height: 18px; background: var(--border2); }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: var(--r1);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-d); }
.btn-secondary {
  background: var(--bg3);
  color: var(--text0);
  border: 1px solid var(--border2);
}
.btn-secondary:hover { background: var(--bg4); }
.w-full { width: 100%; justify-content: center; }

/* Overlays */
#processing-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.processing-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  background: var(--bg1);
  padding: 32px 40px;
  border-radius: var(--r3);
  border: 1px solid var(--border2);
  box-shadow: var(--shadow);
}
.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.processing-inner p { font-size: 14px; font-weight: 500; color: var(--text1); }

/* Camera Overlay */
#camera-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
}
.camera-shell {
  width: 100%;
  max-width: 640px;
  height: 100%;
  display: flex;
  flex-direction: column;
}
.camera-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: rgba(0,0,0,0.6);
}
.cam-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: background 0.2s;
}
.cam-btn:hover { background: rgba(255,255,255,0.25); }
.cam-title { color: white; font-size: 14px; font-weight: 600; }
.camera-view {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #111;
}
#camera-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.camera-guide {
  position: absolute;
  inset: 12%;
  border: 2px solid rgba(255,255,255,0.5);
  border-radius: 8px;
  pointer-events: none;
}
.camera-guide::before, .camera-guide::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border-color: var(--accent);
  border-style: solid;
}
.camera-guide::before { top: -2px; left: -2px; border-width: 3px 0 0 3px; }
.camera-guide::after { bottom: -2px; right: -2px; border-width: 0 3px 3px 0; }

.camera-bottom-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 28px;
  background: rgba(0,0,0,0.6);
}
#cam-capture-btn {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: 3px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s;
}
#cam-capture-btn:active { transform: scale(0.92); }
.capture-ring {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: white;
  display: block;
}

/* Toast */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-radius: var(--r2);
  background: var(--bg1);
  border: 1px solid var(--border2);
  box-shadow: var(--shadow);
  font-size: 13px;
  font-weight: 500;
  color: var(--text0);
  max-width: 320px;
  pointer-events: all;
  animation: toastIn 0.25s cubic-bezier(0.4,0,0.2,1) forwards;
}
.toast-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.toast.success .toast-dot { background: var(--accent); }
.toast.error .toast-dot { background: var(--red); }
.toast.info .toast-dot { background: #3b82f6; }

@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(20px); } }
