/* ═══════════════════════════════════════════════════════════════════════════
   FileVault - Main Stylesheet
   Bootstrap 5 base + custom design tokens + component overrides
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────────────────────────── */
:root {
  --fv-primary:       #4f46e5;
  --fv-primary-light: #6366f1;
  --fv-primary-dark:  #3730a3;
  --fv-admin-accent:  #dc2626;
  --fv-success:       #16a34a;
  --fv-warning:       #d97706;
  --fv-danger:        #dc2626;
  --fv-info:          #0ea5e9;

  --fv-bg:            #f8fafc;
  --fv-surface:       #ffffff;
  --fv-border:        #e2e8f0;
  --fv-text:          #1e293b;
  --fv-text-muted:    #64748b;

  --fv-header-h:      64px;
  --fv-footer-h:      52px;
  --fv-radius:        10px;
  --fv-radius-sm:     6px;
  --fv-shadow:        0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
  --fv-shadow-md:     0 4px 6px -1px rgb(0 0 0 / .1), 0 2px 4px -2px rgb(0 0 0 / .1);

  --fv-transition:    .2s ease;
}

/* ── Base ───────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  background: var(--fv-bg);
  color: var(--fv-text);
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  font-size: .925rem;
}

/* ── Header ─────────────────────────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-user {
  background: var(--fv-surface);
  border-bottom: 2px solid var(--fv-primary);
  min-height: var(--fv-header-h);
}

.navbar-admin {
  background: var(--fv-surface);
  border-bottom: 2px solid var(--fv-admin-accent);
  min-height: var(--fv-header-h);
}

/* ── Navbar layout sections ─────────────────────────────────────────────────── */
.navbar > .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.navbar-brand-wrap { flex: 0 0 auto; }

.navbar-center-label {
  flex: 1;
  text-align: center;
}

.navbar-nav-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: .25rem;
}

/* Dashboard label */
.dashboard-label {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -.01em;
}
.user-label  { color: var(--fv-primary); }
.admin-label { color: var(--fv-admin-accent); }

/* Nav pills */
.nav-link-pill {
  display: inline-flex;
  align-items: center;
  padding: .35rem .75rem;
  border-radius: 20px;
  font-size: .85rem;
  font-weight: 500;
  color: var(--fv-text-muted);
  text-decoration: none;
  transition: background var(--fv-transition), color var(--fv-transition);
}
.nav-link-pill:hover { background: var(--fv-bg); color: var(--fv-text); }
.navbar-user  .nav-link-pill.active { background: #ede9fe; color: var(--fv-primary); }
.navbar-admin .nav-link-pill.active { background: #fee2e2; color: var(--fv-admin-accent); }

/* Role badge */
.role-badge { font-size: .7rem; letter-spacing: .04em; text-transform: uppercase; }

/* ── Avatar ─────────────────────────────────────────────────────────────────── */
.avatar-circle {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fv-primary) 0%, var(--fv-primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--fv-border);
}
.navbar-admin .avatar-circle {
  background: linear-gradient(135deg, var(--fv-admin-accent) 0%, #ef4444 100%);
}
.avatar-initials  { color: #fff; font-weight: 700; font-size: .85rem; line-height: 1; }
.avatar-img       { width: 100%; height: 100%; object-fit: cover; }
.avatar-name      { font-weight: 600; font-size: .875rem; }

/* Large avatar (profile page) */
.avatar-circle-lg {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--fv-primary) 0%, var(--fv-primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 0 0 3px var(--fv-border);
}
.avatar-initials-lg { color: #fff; font-weight: 700; font-size: 2rem; line-height: 1; }
.avatar-img-lg      { width: 100%; height: 100%; object-fit: cover; }

/* Small avatar (tables) */
.avatar-circle-sm {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--fv-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: .75rem;
  flex-shrink: 0;
}

/* ── Profile dropdown ────────────────────────────────────────────────────────── */
.profile-toggle { outline: none; }
.profile-dropdown {
  min-width: 220px;
  border: 1px solid var(--fv-border);
  border-radius: var(--fv-radius);
  box-shadow: var(--fv-shadow-md);
}
.profile-dropdown .dropdown-item { font-size: .875rem; }
.profile-dropdown .dropdown-item:hover { background: var(--fv-bg); }

/* ── Footer ─────────────────────────────────────────────────────────────────── */
.app-footer {
  background: var(--fv-surface);
  border-top: 1px solid var(--fv-border);
  min-height: var(--fv-footer-h);
}
.footer-brand {
  font-weight: 700;
  color: var(--fv-primary);
  font-size: .95rem;
}

/* ── Auth pages ─────────────────────────────────────────────────────────────── */
.auth-wrapper {
  min-height: calc(100vh - 2rem);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  border: none;
  border-radius: var(--fv-radius);
}

.auth-logo-icon {
  width: 64px;
  height: 64px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--fv-primary) 0%, var(--fv-primary-light) 100%);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

/* ── Page header ────────────────────────────────────────────────────────────── */
.page-title {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.02em;
  margin-bottom: .25rem;
}

/* ── Stat cards ─────────────────────────────────────────────────────────────── */
.stat-card {
  border-radius: var(--fv-radius);
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  box-shadow: var(--fv-shadow);
  background: var(--fv-surface);
  border-left: 4px solid transparent;
}
.stat-primary { border-left-color: var(--fv-primary); }
.stat-success { border-left-color: var(--fv-success); }
.stat-info    { border-left-color: var(--fv-info);    }
.stat-danger  { border-left-color: var(--fv-danger);  }
.stat-warning { border-left-color: var(--fv-warning); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}
.stat-primary .stat-icon { background: #ede9fe; color: var(--fv-primary); }
.stat-success .stat-icon { background: #dcfce7; color: var(--fv-success); }
.stat-info    .stat-icon { background: #e0f2fe; color: var(--fv-info); }
.stat-danger  .stat-icon { background: #fee2e2; color: var(--fv-danger); }
.stat-warning .stat-icon { background: #fef3c7; color: var(--fv-warning); }

.stat-value { font-size: 1.75rem; font-weight: 800; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--fv-text-muted); margin-top: .2rem; text-transform: uppercase; letter-spacing: .05em; }

/* ── Upload card / drop-zone ─────────────────────────────────────────────────── */
.upload-card { border: none; border-radius: var(--fv-radius); }

.upload-dropzone {
  border: 2px dashed var(--fv-border);
  border-radius: var(--fv-radius);
  background: var(--fv-bg);
  transition: border-color var(--fv-transition), background var(--fv-transition);
  cursor: pointer;
  position: relative;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.upload-dropzone:hover,
.upload-dropzone.drag-over {
  border-color: var(--fv-primary);
  background: #f5f3ff;
}

.upload-file-input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.upload-dropzone-inner { text-align: center; pointer-events: none; padding: 1.5rem; }
.upload-dropzone label { pointer-events: all; cursor: pointer; }
.upload-hint { font-size: .8rem; color: var(--fv-text-muted); }

/* ── File icon chips ────────────────────────────────────────────────────────── */
.file-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--fv-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .9rem;
  flex-shrink: 0;
}
.file-pdf { background: #fee2e2; color: var(--fv-danger); }
.file-img { background: #e0f2fe; color: var(--fv-info); }

.file-name {
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: inline-block;
  vertical-align: middle;
}

/* ── Badges ─────────────────────────────────────────────────────────────────── */
.badge-pdf { background-color: var(--fv-danger) !important; color: #fff; }
.badge-img { background-color: var(--fv-info)   !important; color: #fff; }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.card {
  border: 1px solid var(--fv-border);
  border-radius: var(--fv-radius);
}
.card-header {
  background: var(--fv-surface);
  border-bottom: 1px solid var(--fv-border);
  padding: .875rem 1.25rem;
}

/* ── Tables ─────────────────────────────────────────────────────────────────── */
.table { font-size: .875rem; }
.table > :not(caption) > * > * { padding: .75rem 1rem; }
.table-hover > tbody > tr:hover > * { background-color: #f8f7ff; }
.table th { font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--fv-text-muted); }

/* ── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 2rem;
}

/* ── Error pages ────────────────────────────────────────────────────────────── */
.error-page .error-code {
  font-size: 8rem;
  font-weight: 900;
  line-height: 1;
  color: var(--fv-border);
  text-shadow: 0 2px 4px rgb(0 0 0 / .08);
}

/* ── S3 key monospace ───────────────────────────────────────────────────────── */
.s3-key {
  font-size: .75rem;
  background: var(--fv-bg);
  padding: .1rem .35rem;
  border-radius: 4px;
  border: 1px solid var(--fv-border);
  color: var(--fv-text-muted);
}

/* ── Buttons override ───────────────────────────────────────────────────────── */
.btn-primary {
  background-color: var(--fv-primary);
  border-color: var(--fv-primary);
}
.btn-primary:hover, .btn-primary:focus {
  background-color: var(--fv-primary-dark);
  border-color: var(--fv-primary-dark);
}

/* ── Forms ──────────────────────────────────────────────────────────────────── */
.form-control:focus, .form-select:focus {
  border-color: var(--fv-primary);
  box-shadow: 0 0 0 .2rem rgb(79 70 229 / .2);
}

/* ── Pagination ─────────────────────────────────────────────────────────────── */
.page-link { color: var(--fv-primary); }
.page-item.active .page-link {
  background-color: var(--fv-primary);
  border-color: var(--fv-primary);
}

/* ── Alerts ─────────────────────────────────────────────────────────────────── */
.flash-container .alert { border-radius: var(--fv-radius); }

/* ── Admin layout accent ────────────────────────────────────────────────────── */
.admin-layout .btn-primary {
  background-color: var(--fv-admin-accent);
  border-color: var(--fv-admin-accent);
}
.admin-layout .btn-primary:hover {
  background-color: #b91c1c;
  border-color: #b91c1c;
}
.admin-layout .page-item.active .page-link {
  background-color: var(--fv-admin-accent);
  border-color: var(--fv-admin-accent);
}
.admin-layout .form-control:focus,
.admin-layout .form-select:focus {
  border-color: var(--fv-admin-accent);
  box-shadow: 0 0 0 .2rem rgb(220 38 38 / .2);
}

/* ── Responsive tweaks ──────────────────────────────────────────────────────── */
@media (max-width: 576px) {
  .page-title { font-size: 1.25rem; }
  .stat-value { font-size: 1.4rem; }
  .auth-card { border-radius: var(--fv-radius-sm); }
  .table > :not(caption) > * > * { padding: .5rem .75rem; }
}
