/* ============================================================
   ProPDF Editor — Main Stylesheet
   ============================================================ */

:root {
  --bg-primary: #0f0f1a;
  --bg-secondary: #1a1a2e;
  --bg-tertiary: #16213e;
  --bg-panel: #1e1e32;
  --bg-card: #252540;
  --bg-hover: #2a2a4a;
  --accent: #6c63ff;
  --accent-light: #8b85ff;
  --accent-dark: #4a42d0;
  --accent2: #3ecfcf;
  --accent2-dark: #2aabab;
  --text-primary: #f0f0ff;
  --text-secondary: #a0a0c0;
  --text-muted: #606080;
  --border: #2a2a4a;
  --border-light: #3a3a5a;
  --danger: #ff4757;
  --success: #2ed573;
  --warning: #ffa502;
  --info: #1e90ff;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --header-h: 56px;
  --ctx-toolbar-h: 44px;
  --left-toolbar-w: 72px;
  --right-panel-w: 260px;
  --status-h: 28px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ---- SCROLLBARS ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ---- UTILITY ---- */
.hidden { display: none !important; }
.active { /* context-specific */ }

/* ---- BUTTONS ---- */
.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; border: none; border-radius: var(--radius-md);
  padding: 10px 20px; font-size: 14px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  box-shadow: 0 4px 15px rgba(108,99,255,0.4);
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(108,99,255,0.5); }
.btn-primary:active { transform: translateY(0); }
.btn-primary.small { padding: 6px 14px; font-size: 12px; }
.btn-primary.full-width { width: 100%; justify-content: center; margin-top: 16px; }

.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-card); color: var(--text-primary);
  border: 1px solid var(--border-light); border-radius: var(--radius-md);
  padding: 10px 20px; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: var(--transition);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--accent); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: transparent; border: none; color: var(--text-secondary);
  cursor: pointer; transition: var(--transition);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.icon-btn:active { background: var(--bg-card); }
.icon-btn .material-icons-round { font-size: 20px; }

/* ---- SPLASH SCREEN ---- */
.splash-screen {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-primary);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.splash-screen:not(.active) { opacity: 0; pointer-events: none; transform: scale(0.98); }
.splash-screen.hidden { display: none !important; }

.splash-content {
  position: relative; z-index: 2;
  display: flex; flex-direction: column; align-items: center;
  max-width: 640px; width: 90%; text-align: center; gap: 24px;
}

.splash-logo {
  display: flex; align-items: center; gap: 12px;
}
.logo-icon svg { width: 56px; height: 56px; border-radius: 16px; }
.logo-text {
  font-size: 28px; font-weight: 700; color: var(--text-primary);
}
.logo-text span { color: var(--accent); }

.splash-title {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800; line-height: 1.1;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-light));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.splash-subtitle {
  font-size: 16px; color: var(--text-secondary); line-height: 1.6; max-width: 480px;
}

.upload-zone {
  width: 100%; border: 2px dashed var(--border-light);
  border-radius: var(--radius-xl); padding: 40px 32px;
  cursor: pointer; transition: var(--transition);
  background: var(--bg-secondary);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent); background: rgba(108,99,255,0.08);
  transform: scale(1.01);
}
.upload-icon .material-icons-round {
  font-size: 48px; color: var(--accent);
}
.upload-text strong { font-size: 18px; display: block; color: var(--text-primary); }
.upload-text span { font-size: 14px; color: var(--text-secondary); }
.upload-formats { font-size: 12px; color: var(--text-muted); }

.splash-features {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: center;
}
.feature-pill {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 20px; padding: 6px 14px; font-size: 12px;
  color: var(--text-secondary);
}
.feature-pill .material-icons-round { font-size: 14px; color: var(--accent); }

.splash-actions { display: flex; gap: 12px; justify-content: center; }

/* BG SHAPES */
.splash-bg-shapes { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.shape {
  position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: 0.15;
  animation: float 8s ease-in-out infinite;
}
.shape.s1 { width: 400px; height: 400px; background: var(--accent); top: -100px; left: -100px; animation-delay: 0s; }
.shape.s2 { width: 300px; height: 300px; background: var(--accent2); bottom: -50px; right: -50px; animation-delay: 3s; }
.shape.s3 { width: 200px; height: 200px; background: #ff6b6b; top: 50%; left: 50%; animation-delay: 6s; }

@keyframes float {
  0%, 100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-30px) scale(1.05); }
}

/* ---- EDITOR APP ---- */
.editor-app {
  display: flex; flex-direction: column;
  height: 100vh; width: 100vw; overflow: hidden;
}
.editor-app.hidden { display: none; }

/* ---- EDITOR HEADER ---- */
.editor-header {
  height: var(--header-h); min-height: var(--header-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 12px; gap: 8px; z-index: 100;
  box-shadow: var(--shadow-sm);
}
.header-left, .header-right { display: flex; align-items: center; gap: 6px; flex: 1; }
.header-right { justify-content: flex-end; }
.header-center { display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }

.doc-title-wrap { display: flex; align-items: center; gap: 8px; }
.logo-small { font-size: 16px; font-weight: 700; color: var(--accent); white-space: nowrap; }
.doc-title-input {
  background: transparent; border: none; border-bottom: 1px solid transparent;
  color: var(--text-primary); font-size: 14px; font-weight: 500;
  padding: 4px 8px; border-radius: var(--radius-sm);
  min-width: 120px; max-width: 220px;
  transition: var(--transition);
}
.doc-title-input:hover { border-bottom-color: var(--border-light); }
.doc-title-input:focus { outline: none; border-bottom-color: var(--accent); background: var(--bg-card); }

.zoom-controls {
  display: flex; align-items: center; gap: 4px;
  background: var(--bg-card); border-radius: var(--radius-md);
  padding: 4px 8px;
}
.zoom-label { font-size: 13px; font-weight: 600; min-width: 44px; text-align: center; color: var(--text-primary); }

.btn-export {
  display: inline-flex; align-items: center; gap: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff; border: none; border-radius: var(--radius-md);
  padding: 8px 16px; font-size: 13px; font-weight: 600;
  cursor: pointer; transition: var(--transition);
  box-shadow: 0 4px 12px rgba(108,99,255,0.35);
  white-space: nowrap;
}
.btn-export:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(108,99,255,0.5); }
.btn-export .material-icons-round { font-size: 18px; }

.mobile-menu-btn { display: none; }

/* ---- CONTEXT TOOLBAR ---- */
.context-toolbar {
  height: var(--ctx-toolbar-h); min-height: var(--ctx-toolbar-h);
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 12px; gap: 4px;
  overflow-x: auto; overflow-y: hidden;
  z-index: 90;
}
.context-toolbar::-webkit-scrollbar { height: 3px; }

.ctx-group {
  display: flex; align-items: center; gap: 3px;
  flex-shrink: 0;
}
.ctx-separator {
  width: 1px; height: 24px; background: var(--border);
  margin: 0 4px; flex-shrink: 0;
}
.ctx-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 6px;
  background: transparent; border: none; border-radius: var(--radius-sm);
  color: var(--text-secondary); cursor: pointer;
  font-size: 13px; font-weight: 700;
  transition: var(--transition);
}
.ctx-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.ctx-btn.active { background: var(--accent); color: #fff; }
.ctx-btn .material-icons-round { font-size: 18px; }
.ctx-btn-danger:hover { background: rgba(255,71,87,0.2); color: var(--danger); }

.ctx-select {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius-sm);
  padding: 4px 8px; font-size: 12px; height: 32px; cursor: pointer;
}
.ctx-font-select { min-width: 140px; max-width: 180px; }
.ctx-input {
  background: var(--bg-card); border: 1px solid var(--border);
  color: var(--text-primary); border-radius: var(--radius-sm);
  padding: 4px 8px; font-size: 12px; height: 32px;
}
.ctx-size-input { width: 56px; }
.ctx-range { width: 80px; accent-color: var(--accent); }
.ctx-label { font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.ctx-color-wrap {
  display: inline-flex; align-items: center; gap: 4px;
  cursor: pointer; padding: 4px; border-radius: var(--radius-sm);
  transition: var(--transition);
}
.ctx-color-wrap:hover { background: var(--bg-hover); }
.ctx-color-wrap .material-icons-round { font-size: 18px; color: var(--text-secondary); }
.ctx-color-wrap input[type="color"] {
  width: 24px; height: 24px; border: none; border-radius: 4px;
  cursor: pointer; padding: 0; background: none;
}

/* ---- EDITOR BODY ---- */
.editor-body {
  display: flex; flex: 1; overflow: hidden;
  position: relative;
}

/* ---- STATUS BAR ---- */
.status-bar {
  height: var(--status-h); min-height: var(--status-h);
  background: var(--bg-secondary); border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 0 16px; font-size: 11px; color: var(--text-muted);
  z-index: 100;
}
.status-bar span { white-space: nowrap; }

/* ---- CANVAS AREA ---- */
.canvas-area {
  flex: 1; position: relative; overflow: hidden;
  background: var(--bg-primary);
  background-image:
    radial-gradient(circle, rgba(255,255,255,0.03) 1px, transparent 1px);
  background-size: 24px 24px;
}
.canvas-scroll-container {
  position: absolute; inset: 0;
  overflow: auto; display: flex;
  align-items: flex-start; justify-content: flex-start;
  padding: 40px;
}
.canvas-wrapper {
  position: relative; display: inline-block;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
  border-radius: 2px;
  /* No CSS transform zoom - Fabric.js handles zoom internally */
}
.canvas-wrapper canvas {
  display: block;
}

/* Ruler */
.ruler-h, .ruler-v {
  position: absolute; background: var(--bg-secondary);
  z-index: 10; pointer-events: none;
}
.ruler-h { top: 0; left: 40px; right: 0; height: 20px; border-bottom: 1px solid var(--border); }
.ruler-v { left: 0; top: 20px; bottom: 0; width: 20px; border-right: 1px solid var(--border); }

/* Page navigation overlay */
.page-nav-overlay {
  position: absolute; bottom: 20px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-secondary); border: 1px solid var(--border);
  border-radius: 24px; padding: 6px 12px;
  box-shadow: var(--shadow-md); z-index: 20;
}
.page-nav-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%;
  background: transparent; border: none; color: var(--text-secondary);
  cursor: pointer; transition: var(--transition);
}
.page-nav-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.page-nav-btn .material-icons-round { font-size: 20px; }
.page-indicator { font-size: 13px; font-weight: 600; color: var(--text-primary); padding: 0 8px; }

/* ---- TOAST ---- */
.toast-container {
  position: fixed; bottom: 40px; right: 24px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 9999; pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  background: var(--bg-card); border: 1px solid var(--border-light);
  border-radius: var(--radius-md); padding: 12px 16px;
  box-shadow: var(--shadow-lg); pointer-events: all;
  animation: slideInRight 0.3s ease;
  min-width: 240px; max-width: 360px;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--info); }
.toast.warning { border-left: 3px solid var(--warning); }
.toast-icon .material-icons-round { font-size: 20px; }
.toast.success .toast-icon { color: var(--success); }
.toast.error .toast-icon { color: var(--danger); }
.toast.info .toast-icon { color: var(--info); }
.toast.warning .toast-icon { color: var(--warning); }
.toast-text { flex: 1; font-size: 13px; color: var(--text-primary); }
.toast-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 18px; }
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOutRight {
  from { transform: translateX(0); opacity: 1; }
  to { transform: translateX(100%); opacity: 0; }
}

/* ---- LOADING OVERLAY ---- */
.loading-overlay {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(15,15,26,0.9); backdrop-filter: blur(8px);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 20px;
}
.loading-spinner {
  width: 56px; height: 56px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 16px; font-weight: 600; color: var(--text-primary); }
.loading-progress { width: 240px; }
.progress-bar {
  width: 100%; height: 4px; background: var(--border);
  border-radius: 2px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 2px; transition: width 0.3s ease;
  width: 0%;
}
