/* =============================================
   PDFLokal — Premium PDF Editor Stylesheet
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ===== CSS VARIABLES ===== */
:root {
  --bg-primary:    #0f0f1a;
  --bg-secondary:  #161627;
  --bg-tertiary:   #1e1e35;
  --bg-panel:      #1a1a2e;
  --bg-card:       #22223a;
  --bg-hover:      #2a2a48;

  --accent:        #6C63FF;
  --accent-2:      #FF6B6B;
  --accent-grad:   linear-gradient(135deg, #6C63FF, #FF6B6B);
  --accent-light:  rgba(108, 99, 255, 0.15);

  --text-primary:  #f0f0ff;
  --text-secondary:#a0a0c0;
  --text-muted:    #606080;
  --border:        rgba(108, 99, 255, 0.2);
  --border-hover:  rgba(108, 99, 255, 0.5);

  --shadow:        0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg:     0 8px 48px rgba(0,0,0,0.6);

  --topbar-h:      56px;
  --toolbar-h:     60px;
  --sidebar-w:     200px;
  --right-panel-w: 260px;
  --radius:        10px;
  --radius-sm:     6px;

  --transition:    0.18s ease;
}

/* ===== RESET ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; font-family: 'Inter', sans-serif; background: var(--bg-primary); color: var(--text-primary); }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
.hidden { display: none !important; }

/* ===== SPLASH SCREEN ===== */
.splash {
  position: fixed; inset: 0; z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.splash-bg {
  position: absolute; inset: 0;
  background: radial-gradient(ellipse at 30% 30%, rgba(108,99,255,0.25) 0%, transparent 60%),
              radial-gradient(ellipse at 70% 70%, rgba(255,107,107,0.15) 0%, transparent 60%),
              var(--bg-primary);
  animation: bgPulse 6s ease-in-out infinite alternate;
}
@keyframes bgPulse {
  from { opacity: 0.8; } to { opacity: 1; }
}
.splash-content {
  position: relative; z-index: 1; text-align: center;
  max-width: 640px; padding: 40px 24px;
  animation: fadeUp 0.8s cubic-bezier(0.22,1,0.36,1) both;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
.splash-logo {
  display: inline-block; margin-bottom: 20px;
  animation: floatIcon 3s ease-in-out infinite;
  filter: drop-shadow(0 8px 32px rgba(108,99,255,0.5));
}
@keyframes floatIcon {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}
.splash-title {
  font-size: 3rem; font-weight: 800; letter-spacing: -1px;
  background: var(--accent-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text; margin-bottom: 8px;
}
.splash-sub {
  font-size: 1.15rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 8px;
}
.splash-desc {
  font-size: 0.9rem; color: var(--text-muted); margin-bottom: 36px;
  padding: 8px 16px; background: var(--accent-light); border-radius: 20px; display: inline-block;
}
.btn-upload-big {
  display: inline-flex; align-items: center; gap: 12px; cursor: pointer;
  padding: 16px 40px; border-radius: 50px; font-size: 1.05rem; font-weight: 600;
  background: var(--accent-grad); color: white; border: none; outline: none;
  box-shadow: 0 8px 32px rgba(108,99,255,0.4);
  transition: transform 0.2s, box-shadow 0.2s;
  margin-bottom: 48px;
}
.btn-upload-big:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 14px 48px rgba(108,99,255,0.55);
}
.splash-features {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 12px;
}
.feat {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 18px; border-radius: 20px;
  background: var(--bg-card); border: 1px solid var(--border);
  font-size: 0.85rem; color: var(--text-secondary); font-weight: 500;
  transition: border-color 0.2s, transform 0.2s;
}
.feat:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.feat-icon { font-size: 1.1em; }

/* ===== APP LAYOUT ===== */
.app {
  display: flex; flex-direction: column; height: 100vh; overflow: hidden;
  animation: fadeIn 0.4s ease both;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ===== TOP BAR ===== */
.topbar {
  height: var(--topbar-h); flex-shrink: 0;
  background: var(--bg-secondary); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; gap: 12px; z-index: 100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; min-width: 200px; }
.topbar-right { justify-content: flex-end; }
.topbar-center { display: flex; align-items: center; gap: 16px; flex: 1; justify-content: center; }

.logo-small { display: flex; align-items: center; gap: 8px; }
.logo-text { font-weight: 700; font-size: 1.05rem; background: var(--accent-grad); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.file-name-label { font-size: 0.82rem; color: var(--text-muted); max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 3px 8px; background: var(--bg-tertiary); border-radius: var(--radius-sm); }

.zoom-controls { display: flex; align-items: center; gap: 4px; background: var(--bg-tertiary); border-radius: 8px; padding: 4px 8px; }
.zoom-label { font-size: 0.82rem; font-weight: 600; min-width: 46px; text-align: center; color: var(--text-secondary); }
.page-nav { display: flex; align-items: center; gap: 4px; background: var(--bg-tertiary); border-radius: 8px; padding: 4px 8px; }
.page-info { font-size: 0.82rem; font-weight: 500; color: var(--text-secondary); min-width: 80px; text-align: center; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 7px; border: none; outline: none;
  background: transparent; color: var(--text-secondary); font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn:hover { background: var(--accent-light); color: var(--accent); }

.btn-primary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 18px; border-radius: 8px; border: none; outline: none;
  background: var(--accent-grad); color: white; font-weight: 600; font-size: 0.88rem;
  transition: opacity 0.15s, transform 0.15s;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-secondary {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--border); outline: none;
  background: var(--bg-tertiary); color: var(--text-secondary); font-weight: 500; font-size: 0.88rem;
  transition: border-color 0.15s, background 0.15s;
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--bg-hover); color: var(--text-primary); }

/* ===== TOOLBAR ===== */
.toolbar {
  height: var(--toolbar-h); flex-shrink: 0;
  background: var(--bg-panel); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 6px; padding: 0 14px;
  overflow-x: auto; scrollbar-width: thin; z-index: 99;
}
.toolbar::-webkit-scrollbar { height: 3px; }
.toolbar::-webkit-scrollbar-track { background: transparent; }
.toolbar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.tool-group { display: flex; align-items: center; gap: 4px; }
.tool-label { font-size: 0.68rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; padding: 0 4px; white-space: nowrap; }
.tool-label-sm { font-size: 0.68rem; color: var(--text-muted); white-space: nowrap; }
.divider { width: 1px; height: 36px; background: var(--border); margin: 0 4px; flex-shrink: 0; }

.tool-btn {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; padding: 5px 10px; border-radius: 8px; border: 1px solid transparent;
  background: transparent; color: var(--text-secondary); font-size: 0.62rem; font-weight: 500;
  transition: all 0.15s; white-space: nowrap; min-width: 50px; height: 48px; cursor: pointer;
}
.tool-btn:hover { background: var(--accent-light); color: var(--accent); border-color: var(--border); }
.tool-btn.active { background: var(--accent-light); color: var(--accent); border-color: var(--accent); }
.tool-btn.danger { color: #FF6B6B; }
.tool-btn.danger:hover { background: rgba(255,107,107,0.12); color: #FF6B6B; border-color: rgba(255,107,107,0.4); }

.color-picker-wrap { position: relative; display: flex; align-items: center; }
.color-swatch-btn { cursor: pointer; display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 8px; background: var(--bg-tertiary); border: 1px solid var(--border); overflow: hidden; position: relative; }
.color-swatch-btn input[type="color"] { position: absolute; width: 200%; height: 200%; opacity: 0; cursor: pointer; }
.color-swatch-preview { width: 22px; height: 22px; border-radius: 5px; background: #6C63FF; display: block; pointer-events: none; }

.size-controls { display: flex; align-items: center; gap: 6px; padding: 0 4px; }
.size-controls input[type="range"] { width: 80px; accent-color: var(--accent); }
.size-controls span { font-size: 0.72rem; color: var(--text-muted); min-width: 18px; }

/* ===== WORKSPACE ===== */
.workspace {
  display: flex; flex: 1; overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--bg-secondary); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: width var(--transition);
}
.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 12px; border-bottom: 1px solid var(--border);
  font-size: 0.82rem; font-weight: 600; color: var(--text-secondary);
}
.icon-btn-sm {
  width: 22px; height: 22px; border-radius: 5px; border: none; outline: none;
  background: transparent; color: var(--text-muted); font-size: 0.75rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.icon-btn-sm:hover { background: var(--accent-light); color: var(--accent); }

.thumb-container {
  flex: 1; overflow-y: auto; padding: 8px;
  display: flex; flex-direction: column; gap: 8px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.thumb-container::-webkit-scrollbar { width: 4px; }
.thumb-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.thumb-item {
  position: relative; cursor: pointer; border-radius: 8px; overflow: hidden;
  border: 2px solid transparent; transition: border-color 0.15s, transform 0.15s;
  background: var(--bg-card);
}
.thumb-item:hover { border-color: var(--border-hover); transform: scale(1.02); }
.thumb-item.active { border-color: var(--accent); }
.thumb-item canvas { width: 100%; display: block; }
.thumb-num {
  position: absolute; bottom: 0; left: 0; right: 0; text-align: center;
  font-size: 0.65rem; font-weight: 600; color: white;
  background: linear-gradient(transparent, rgba(0,0,0,0.7)); padding: 4px 0;
}

.sidebar-toggle-btn {
  position: fixed; left: 12px; bottom: 24px; z-index: 200;
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-grad); color: white; border: none; outline: none;
  font-size: 1.1rem; box-shadow: var(--shadow);
  transition: transform 0.2s;
}
.sidebar-toggle-btn:hover { transform: scale(1.1); }

/* ===== CANVAS AREA ===== */
.canvas-area {
  flex: 1; overflow: auto; background: var(--bg-primary);
  display: flex; justify-content: center; align-items: flex-start; padding: 24px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.canvas-area::-webkit-scrollbar { width: 6px; height: 6px; }
.canvas-area::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.pdf-container {
  position: relative; display: inline-block;
  box-shadow: 0 8px 48px rgba(0,0,0,0.6);
  border-radius: 4px; overflow: hidden;
  cursor: crosshair;
}
.pdf-container.tool-select { cursor: default; }
.pdf-container.tool-pan    { cursor: grab; }
.pdf-container.tool-pan.panning { cursor: grabbing; }
.pdf-container.tool-text   { cursor: text; }
.pdf-container.tool-draw,
.pdf-container.tool-sign   { cursor: crosshair; }

.pdf-canvas  { display: block; }
.annot-canvas { position: absolute; top: 0; left: 0; pointer-events: none; }

/* ===== RIGHT PANEL ===== */
.right-panel {
  width: var(--right-panel-w); flex-shrink: 0;
  background: var(--bg-secondary); border-left: 1px solid var(--border);
  overflow-y: auto; padding: 12px;
  scrollbar-width: thin; scrollbar-color: var(--border) transparent;
  display: flex; flex-direction: column; gap: 2px;
}
.right-panel::-webkit-scrollbar { width: 4px; }
.right-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.panel-section {
  background: var(--bg-card); border-radius: var(--radius); padding: 12px;
  border: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 8px;
}
.panel-section h3 { font-size: 0.78rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 2px; }
.panel-section label { font-size: 0.75rem; color: var(--text-muted); font-weight: 500; }
.panel-section select,
.panel-section input[type="number"],
.panel-section input[type="range"] { width: 100%; padding: 5px 8px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-tertiary); color: var(--text-primary); font-size: 0.82rem; outline: none; transition: border-color 0.15s; }
.panel-section select:focus,
.panel-section input[type="number"]:focus { border-color: var(--accent); }
.panel-section input[type="range"] { accent-color: var(--accent); padding: 0; cursor: pointer; }
.panel-section .full-color { width: 100%; height: 36px; padding: 2px; border-radius: 6px; border: 1px solid var(--border); background: var(--bg-tertiary); cursor: pointer; }

.checkbox-row { display: flex; align-items: center; gap: 6px; font-size: 0.75rem; color: var(--text-muted); cursor: pointer; }
.checkbox-row input { accent-color: var(--accent); }

.btn-row { display: flex; gap: 6px; }
.btn-col { display: flex; flex-direction: column; gap: 6px; }

.prop-btn {
  flex: 1; padding: 6px 10px; border-radius: 6px; border: 1px solid var(--border);
  background: var(--bg-tertiary); color: var(--text-secondary); font-size: 0.78rem; font-weight: 500;
  transition: all 0.15s; cursor: pointer; text-align: center;
}
.prop-btn:hover { border-color: var(--border-hover); background: var(--bg-hover); color: var(--text-primary); }
.prop-btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.prop-btn.primary:hover { opacity: 0.85; }
.prop-btn.danger { color: #FF6B6B; border-color: rgba(255,107,107,0.3); }
.prop-btn.danger:hover { background: rgba(255,107,107,0.12); }

/* ===== SIGNATURE CANVAS ===== */
.sign-canvas {
  width: 100%; height: 100px; background: white; border-radius: 8px;
  border: 2px dashed var(--border); cursor: crosshair; display: block;
}

/* ===== TEXT INPUT OVERLAY ===== */
.text-input-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
}
.text-input-box {
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px; width: 380px;
  box-shadow: var(--shadow-lg); animation: popIn 0.2s cubic-bezier(0.22,1,0.36,1);
}
@keyframes popIn { from { transform: scale(0.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.text-input-box textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg-tertiary); color: var(--text-primary); padding: 10px;
  font-size: 1rem; outline: none; resize: vertical; min-height: 80px; margin-bottom: 12px;
}
.text-input-box textarea:focus { border-color: var(--accent); }
.text-input-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px; z-index: 9999;
  padding: 12px 20px; border-radius: var(--radius); font-size: 0.88rem; font-weight: 500;
  background: var(--bg-card); border: 1px solid var(--border);
  box-shadow: var(--shadow); color: var(--text-primary);
  animation: slideInToast 0.3s cubic-bezier(0.22,1,0.36,1);
}
.toast.success { border-color: #4ade80; color: #4ade80; }
.toast.error   { border-color: #FF6B6B; color: #FF6B6B; }
@keyframes slideInToast { from { transform: translateX(20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ===== LOADING ===== */
.loading {
  position: fixed; inset: 0; z-index: 2000;
  background: rgba(15,15,26,0.88); backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.loading-inner {
  display: flex; flex-direction: column; align-items: center; gap: 16px;
}
.spinner {
  width: 44px; height: 44px; border-radius: 50%;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-inner span { font-size: 0.9rem; color: var(--text-secondary); }

/* ===== SCROLLBAR GLOBAL ===== */
* { scrollbar-width: thin; scrollbar-color: rgba(108,99,255,0.3) transparent; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  :root { --sidebar-w: 0px; --right-panel-w: 0px; }
  .sidebar, .right-panel { display: none; }
  .toolbar { gap: 2px; padding: 0 8px; }
  .tool-btn span { display: none; }
  .tool-btn { min-width: 36px; padding: 6px; }
}
@media (max-width: 600px) {
  .topbar-center { display: none; }
  .file-name-label { display: none; }
}

/* ===== SELECTION HANDLE ===== */
.annot-selected {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ===== DRAG RESIZE HANDLES ===== */
.resize-handle {
  position: absolute; width: 10px; height: 10px;
  background: white; border: 2px solid var(--accent);
  border-radius: 50%; z-index: 10; cursor: nwse-resize;
}
