/* ═══════════════════════════════════════════════════════════
   style.css – PDF Toolkit Web v3.0
   Design system: #03aaad primary, Light theme, Glassmorphism
   ═══════════════════════════════════════════════════════════ */

/* ─── Reset & Variables ─── */
*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:       #03aaad;
  --primary-hover: #028a8c;
  --primary-light: #e0f7fa;
  --primary-glow:  rgba(3,170,173,0.25);

  --bg:            #f0f4f8;
  --card:          #ffffff;
  --card-hover:    #f8fafb;
  --text:          #2d3748;
  --text-secondary:#718096;
  --border:        #e2e8f0;

  --success:       #38b2ac;
  --warning:       #ed8936;
  --danger:        #e53e3e;
  --purple:        #805ad5;

  --shadow-sm:     0 1px 3px rgba(0,0,0,0.06);
  --shadow:        0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg:     0 8px 30px rgba(0,0,0,0.12);
  --radius:        10px;
  --radius-lg:     14px;

  --sidebar-w:     220px;
  --header-h:      60px;
}

html { font-size: 14px; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

/* ─── Header ─── */
.header {
  height: var(--header-h);
  background: linear-gradient(135deg, var(--primary), #02898b);
  display: flex;
  align-items: center;
  padding: 0 28px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header h1 {
  color: #fff;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.header .version {
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  margin-left: 12px;
  font-weight: 400;
}

/* ─── Layout ─── */
.app-layout {
  display: flex;
  height: calc(100vh - var(--header-h));
}

/* ─── Sidebars ─── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--card);
  border-right: 1px solid var(--border);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}
.sidebar-right {
  border-right: none;
  border-left: 1px solid var(--border);
}

.sidebar-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  padding: 4px 8px 8px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sidebar-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 4px;
}

/* ─── Sidebar Buttons ─── */
.btn {
  display: grid;
  grid-template-columns: 28px 1fr;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 9px 10px;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
  color: #fff;
  background: var(--primary);
}
.btn:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px var(--primary-glow);
}
.btn:active {
  transform: translateY(0);
}
.btn .icon {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  width: 28px;
}
.btn .label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Button variants */
.btn-warning { background: var(--warning); }
.btn-warning:hover { background: #dd6b20; box-shadow: 0 3px 10px rgba(237,137,54,0.3); }
.btn-purple  { background: var(--purple); }
.btn-purple:hover  { background: #6b46c1; box-shadow: 0 3px 10px rgba(128,90,213,0.3); }
.btn-word { background: #2b579a; color: white !important; border: none; }
.btn-word:hover { background: #1e3f6f; box-shadow: 0 3px 10px rgba(43,87,154,0.3); }
.btn-excel { background: #10b981; color: white !important; border: none; }
.btn-excel:hover { background: #059669; box-shadow: 0 3px 10px rgba(16,185,129,0.3); }
.btn-compress { background: #06b6d4; color: white !important; border: none; }
.btn-compress:hover { background: #0891b2; box-shadow: 0 3px 10px rgba(6,182,212,0.3); }
.btn-image { background: #ec4899; color: white !important; border: none; }
.btn-image:hover { background: #db2777; box-shadow: 0 3px 10px rgba(236,72,153,0.3); }
.btn-confirm {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: linear-gradient(135deg, var(--primary), #02898b) !important;
  color: #fff !important;
  border: none !important;
  font-weight: 700;
  font-family: inherit;
  padding: 9px 28px;
  box-shadow: 0 4px 15px rgba(3,170,173,0.35);
  font-size: 0.95rem;
  border-radius: 24px;
  margin-left: 12px;
  white-space: nowrap;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}
.btn-confirm:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(3,170,173,0.5);
  background: linear-gradient(135deg, #04c2c5, var(--primary)) !important;
}
.btn-danger  { background: var(--danger); }
.btn-danger:hover  { background: #c53030; box-shadow: 0 3px 10px rgba(229,62,62,0.3); }
.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
}
.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
  box-shadow: none;
}

/* ─── Main Content ─── */
.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Upload Zone ─── */
.upload-zone {
  border: 2px dashed var(--primary);
  border-radius: var(--radius);
  padding: 16px 10px;
  margin-bottom: 4px;
  text-align: center;
  background: var(--primary-light);
  cursor: pointer;
  transition: all 0.2s ease;
}
.upload-zone:hover,
.upload-zone.drag-over {
  background: rgba(3,170,173,0.12);
  border-color: var(--primary-hover);
  transform: translateY(-1px);
}
.upload-zone .upload-icon {
  font-size: 2rem;
  margin-bottom: 4px;
  display: block;
}
.upload-zone .upload-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--primary);
  display: block;
}
.upload-zone .upload-hint {
  font-size: 0.72rem;
  color: var(--text-secondary);
  margin-top: 4px;
  line-height: 1.3;
}

/* ─── File List ─── */
.file-list-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.file-list-header {
  padding: 12px 16px;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  background: var(--primary-light);
}
.file-table {
  width: 100%;
  border-collapse: collapse;
}
.file-table th {
  background: var(--primary);
  color: #fff;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 10px 14px;
  text-align: left;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.file-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
}
.file-table tr {
  cursor: grab;
  transition: background 0.12s, border 0.12s;
}
.file-table tr:active {
  cursor: grabbing;
}
.file-table tbody tr:hover {
  background: var(--card-hover);
}
.file-table tbody tr.selected {
  background: var(--primary-light);
  border-left: 3px solid var(--primary);
}
.file-table tbody tr.dragging {
  opacity: 0.6;
  background: #e2e8f0 !important;
}
.file-table tbody tr.drag-over {
  border-top: 2px dashed var(--primary);
}
.file-table .badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-all {
  background: #c6f6d5;
  color: #276749;
}
.badge-partial {
  background: #fefcbf;
  color: #975a16;
}
.badge-none {
  background: #fed7d7;
  color: #9b2c2c;
}
.btn-delete-row {
  background: transparent;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  opacity: 0.5;
  transition: all 0.2s;
  padding: 4px;
  border-radius: 6px;
}
.btn-delete-row:hover {
  opacity: 1;
  background: #fee2e2;
  transform: scale(1.1);
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #94a3b8;
  cursor: pointer;
  border: 2px dashed transparent;
  border-radius: var(--radius-lg);
  transition: all 0.3s;
}
.empty-state:hover {
  background: var(--card-hover);
  border-color: var(--primary-light);
  color: var(--text-primary);
}
.empty-state.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}
.empty-state .empty-icon {
  font-size: 3rem;
  margin-bottom: 10px;
  display: block;
  opacity: 0.5;
}

/* ─── Thumbnail Area ─── */
.thumb-area {
  flex: 1;
  background: var(--card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.thumb-area #thumbContent {
  overflow-y: auto;
  flex: 1;
}
.thumb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--primary-light);
  border-bottom: 1px solid var(--border);
}
.thumb-header-title {
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--primary);
}
.thumb-header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.btn-select-all, .btn-deselect-all {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 9px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
}
.btn-select-all {
  background: rgba(3, 170, 173, 0.1);
  color: var(--primary);
  border: 1px solid rgba(3, 170, 173, 0.3);
}
.btn-select-all:hover {
  background: rgba(3, 170, 173, 0.18);
  transform: translateY(-1px);
}
.btn-deselect-all {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}
.btn-deselect-all:hover {
  background: #e2e8f0;
  color: #475569;
  transform: translateY(-1px);
}

.thumb-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 20px;
  padding: 20px;
}

/* File section in "all files" view */
.file-section {
  margin-bottom: 4px;
}
.file-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  border-radius: 8px;
  margin: 12px 16px 4px;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
}
.file-section-header .section-actions {
  display: flex;
  gap: 6px;
}
.file-section-header .section-actions button {
  padding: 4px 12px;
  border: none;
  border-radius: 5px;
  background: rgba(255,255,255,0.9);
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.12s;
}
.file-section-header .section-actions button:hover {
  background: #fff;
}
.file-section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 20px;
  padding: 16px 20px;
}

.thumb-card {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 8px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: center;
  position: relative;
}
.thumb-card:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 14px var(--primary-glow);
  transform: translateY(-2px);
}
.thumb-card.checked {
  border-color: var(--primary);
  background: var(--primary-light);
}
.thumb-card.unchecked {
  opacity: 0.5;
}
.thumb-card img {
  width: 100%;
  height: auto;
  border-radius: 4px;
  display: block;
  pointer-events: none;
}
.thumb-card .thumb-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 0 4px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}
.thumb-card.checked .thumb-label {
  color: var(--primary);
}
.thumb-card input[type="checkbox"] {
  accent-color: var(--primary);
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* ─── Checkbox toggle (OCR) ─── */
.toggle-group {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--primary-light);
  cursor: pointer;
  transition: background 0.15s;
}
.toggle-group:hover {
  background: rgba(3,170,173,0.15);
}
.toggle-group input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}
.toggle-group .toggle-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text);
}
.toggle-hint {
  font-size: 0.72rem;
  color: var(--text-secondary);
  padding: 0 10px;
  line-height: 1.3;
}

/* ─── Toast Notifications ─── */
.toast-container {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--card);
  border-radius: 10px;
  padding: 14px 24px;
  box-shadow: var(--shadow-lg);
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideDown 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  border-left: 4px solid var(--primary);
  min-width: 320px;
  pointer-events: auto;
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error   { border-left-color: var(--danger); }
.toast.toast-warning { border-left-color: var(--warning); }

@keyframes slideDown {
  from { transform: translateY(-30px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

/* ─── Loading Overlay ─── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}
.loading-card {
  background: var(--card);
  padding: 48px 72px;
  border-radius: 18px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  min-width: 340px;
}
.loading-card .spinner {
  width: 56px;
  height: 56px;
  border: 5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 20px;
}
.loading-card p {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
}
@keyframes spin { to { transform: rotate(360deg); } }

.hidden { display: none !important; }

/* ─── Scrollbar styling ─── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e0; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a0aec0; }
