/* =====================================================================
   DocVault — Design tokens
   Palette: deep navy ink + brass accent, on a soft cool-gray surface.
   Type: Sora (display / nav) + Inter (body/data).
   Signature element: the "page-stack" badge on document cards.
   ===================================================================== */

:root {
  --color-bg: #F3F5F8;
  --color-surface: #FFFFFF;
  --color-ink: #1E2A4A;
  --color-ink-soft: #445068;
  --color-muted: #7C8698;
  --color-border: #E3E6EC;
  --color-accent: #B9691E;
  --color-accent-soft: #F4E3CE;
  --color-accent-ink: #7A4413;
  --color-success: #1F9D6C;
  --color-success-soft: #DCF3E8;
  --color-danger: #D6453D;
  --color-danger-soft: #FBE3E1;
  --color-sidebar: #131D35;
  --color-sidebar-hover: #1C2A4C;
  --color-sidebar-text: #B7C0D6;
  --color-sidebar-text-active: #FFFFFF;
  --color-pdf: #C1402F;
  --color-image: #2E6FB0;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(20, 28, 51, 0.06);
  --shadow-md: 0 4px 16px rgba(20, 28, 51, 0.08);
  --shadow-lg: 0 12px 32px rgba(20, 28, 51, 0.14);

  --font-display: 'Sora', sans-serif;
  --font-body: 'Inter', sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { font-family: var(--font-display); margin: 0; color: var(--color-ink); }
a { color: inherit; text-decoration: none; }
button { font-family: var(--font-body); cursor: pointer; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; }

/* ---------------- Layout shell ---------------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  top: 0; left: 0; bottom: 0;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 8px 24px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  color: #fff;
}
.sidebar-brand .mark {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--color-accent), #E0954B);
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: #241102;
}
.nav-section-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #6E7A98;
  padding: 16px 12px 6px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  color: var(--color-sidebar-text);
  transition: background 0.15s, color 0.15s;
}
.nav-link:hover { background: var(--color-sidebar-hover); color: #fff; }
.nav-link.active { background: var(--color-accent); color: #241102; font-weight: 600; }
.nav-link .ico { width: 18px; text-align: center; opacity: 0.9; }
.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 12.5px;
  color: #7986A5;
}

.main {
  margin-left: 240px;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.topbar {
  height: 68px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 19px; font-weight: 600; }
.topbar-user {
  display: flex; align-items: center; gap: 10px;
  font-size: 13.5px;
  color: var(--color-ink-soft);
}
.avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--color-accent-soft);
  color: var(--color-accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  font-family: var(--font-display);
}
.role-pill {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--color-accent-soft);
  color: var(--color-accent-ink);
  font-weight: 700;
}
.content { padding: 28px; flex: 1; }

/* ---------------- Buttons & forms ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  transition: transform 0.05s, box-shadow 0.15s, background 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { background: #A2591A; }
.btn-secondary { background: var(--color-surface); color: var(--color-ink); border: 1px solid var(--color-border); }
.btn-secondary:hover { background: #F7F8FA; }
.btn-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.btn-danger:hover { background: #F7CBC8; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-ink-soft);
  margin-bottom: 6px;
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 14.5px;
  font-family: var(--font-body);
  background: var(--color-surface);
  color: var(--color-ink);
}
.form-control:focus { outline: none; border-color: var(--color-accent); box-shadow: 0 0 0 3px var(--color-accent-soft); }
select.form-control { appearance: none; }
.form-hint { font-size: 12.5px; color: var(--color-muted); margin-top: 5px; }

/* ---------------- Cards / panels ---------------- */

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.card-pad { padding: 24px; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
.stat-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.stat-card .stat-label { font-size: 12.5px; color: var(--color-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stat-card .stat-value { font-family: var(--font-display); font-size: 30px; font-weight: 700; margin-top: 6px; color: var(--color-ink); }
.stat-card .stat-sub { font-size: 12.5px; color: var(--color-muted); margin-top: 4px; }

/* ---------------- Auth screen ---------------- */

.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 20% 20%, #1C2A4C 0%, var(--color-sidebar) 60%);
  padding: 24px;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 36px 32px;
}
.auth-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.auth-brand .mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--color-accent), #E0954B);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #241102; font-family: var(--font-display);
}
.auth-brand span { font-family: var(--font-display); font-weight: 700; font-size: 20px; }
.auth-card p.sub { color: var(--color-muted); font-size: 13.5px; margin: 0 0 26px; }
.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 18px;
}
.alert-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.alert-success { background: var(--color-success-soft); color: var(--color-success); }
.default-creds {
  margin-top: 20px;
  font-size: 12px;
  color: var(--color-muted);
  border-top: 1px solid var(--color-border);
  padding-top: 14px;
}

/* ---------------- Upload dropzone ---------------- */

.dropzone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  padding: 40px 24px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
  margin-bottom: 28px;
  cursor: pointer;
}
.dropzone.dragover { border-color: var(--color-accent); background: var(--color-accent-soft); }
.dropzone .dz-icon {
  width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 50%;
  background: var(--color-accent-soft);
  color: var(--color-accent-ink);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}
.dropzone h3 { font-size: 16px; margin-bottom: 4px; }
.dropzone p { color: var(--color-muted); font-size: 13px; margin: 0; }
.dropzone input[type=file] { display: none; }

.upload-queue { margin-top: 4px; }
.upload-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13.5px;
  background: var(--color-surface);
}
.upload-row .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-row .status { font-size: 12px; font-weight: 600; }
.upload-row .status.ok { color: var(--color-success); }
.upload-row .status.err { color: var(--color-danger); }
.upload-row .status.pending { color: var(--color-muted); }
.progress-bar {
  width: 80px; height: 6px; border-radius: 4px; background: var(--color-border); overflow: hidden;
}
.progress-bar-fill { height: 100%; background: var(--color-accent); width: 0%; transition: width 0.2s; }

/* ---------------- Document grid & page-stack badge (signature element) ---------------- */

.section-heading {
  display: flex; align-items: baseline; justify-content: space-between;
  margin-bottom: 16px;
}
.section-heading h2 { font-size: 17px; }
.section-heading .count { color: var(--color-muted); font-size: 13px; font-weight: 500; }

.doc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}
.doc-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: box-shadow 0.15s, transform 0.15s;
  display: flex;
  flex-direction: column;
}
.doc-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.doc-thumb {
  height: 140px;
  background: #EEF1F6;
  display: flex; align-items: center; justify-content: center;
  position: relative;
  border-bottom: 3px solid var(--color-border);
  overflow: hidden;
}
.doc-thumb.type-pdf { border-bottom-color: var(--color-pdf); }
.doc-thumb.type-image { border-bottom-color: var(--color-image); }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb .file-ico { font-size: 34px; }
.type-pdf .file-ico { color: var(--color-pdf); }
.type-image .file-ico { color: var(--color-image); }

/* the page-stack badge: layered card corners indicating page count */
.page-stack {
  position: absolute;
  top: 8px; right: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(19, 29, 53, 0.82);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px 3px 6px;
  border-radius: 20px;
}
.page-stack .stack-ico { position: relative; width: 12px; height: 14px; }
.page-stack .stack-ico span {
  position: absolute;
  width: 10px; height: 12px;
  border: 1.4px solid #fff;
  border-radius: 1.5px;
  background: transparent;
}
.page-stack .stack-ico span:nth-child(1) { top: 2px; left: 2px; opacity: 0.55; }
.page-stack .stack-ico span:nth-child(2) { top: 0; left: 0; opacity: 1; }

.doc-info { padding: 12px 14px 14px; flex: 1; display: flex; flex-direction: column; gap: 6px; }
.doc-info .doc-name {
  font-size: 13.5px; font-weight: 600; color: var(--color-ink);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.doc-info .doc-meta { font-size: 11.5px; color: var(--color-muted); display: flex; justify-content: space-between; }
.doc-actions { display: flex; gap: 6px; margin-top: 6px; }
.doc-actions .btn { flex: 1; }

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-muted);
}
.empty-state .ico { font-size: 40px; margin-bottom: 12px; opacity: 0.5; }

/* ---------------- Tables ---------------- */

.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--color-muted);
  font-weight: 700;
  padding: 10px 14px;
  border-bottom: 1px solid var(--color-border);
  white-space: nowrap;
}
table.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-ink-soft);
  vertical-align: middle;
}
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: #FAFBFC; }
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.badge-admin { background: var(--color-accent-soft); color: var(--color-accent-ink); }
.badge-user { background: #E7EAF2; color: var(--color-ink-soft); }
.badge-active { background: var(--color-success-soft); color: var(--color-success); }
.badge-inactive { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-failed { background: var(--color-danger-soft); color: var(--color-danger); }

.toolbar { display: flex; gap: 10px; margin-bottom: 18px; flex-wrap: wrap; align-items: center; }
.toolbar .form-control { max-width: 220px; }

/* ---------------- Preview viewer ---------------- */

.viewer-shell { display: flex; gap: 20px; align-items: flex-start; }
.viewer-main {
  flex: 1;
  background: #2A344E;
  border-radius: var(--radius-lg);
  min-height: 600px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.viewer-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px;
  background: #1E2A4A;
  color: #fff;
}
.viewer-toolbar .page-indicator { font-size: 13px; font-weight: 600; }
.viewer-toolbar .controls { display: flex; gap: 6px; }
.viewer-toolbar button {
  background: rgba(255,255,255,0.08);
  border: none;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 6px;
  font-size: 14px;
}
.viewer-toolbar button:hover { background: rgba(255,255,255,0.18); }
.viewer-toolbar button:disabled { opacity: 0.35; }
.viewer-canvas-wrap {
  flex: 1;
  overflow: auto;
  display: flex;
  justify-content: center;
  padding: 24px;
}
.viewer-canvas-wrap canvas { box-shadow: var(--shadow-lg); border-radius: 4px; background: #fff; }
.viewer-canvas-wrap img { max-width: 100%; box-shadow: var(--shadow-lg); border-radius: 4px; background: #fff; }

.viewer-side { width: 300px; flex-shrink: 0; }
.meta-list { font-size: 13px; }
.meta-list .row { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--color-border); }
.meta-list .row:last-child { border-bottom: none; }
.meta-list .row .k { color: var(--color-muted); }
.meta-list .row .v { font-weight: 600; text-align: right; }

@media (max-width: 1100px) {
  .viewer-shell { flex-direction: column; }
  .viewer-side { width: 100%; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 720px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .stat-grid { grid-template-columns: 1fr; }
}
