/* =========================================================
   Law Firm Platform – Professional UI Update
   Aesthetic: Refined Legal / Luxury Minimal
   Fonts: Cormorant Garamond (display) + DM Sans (body)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Cormorant+Garamond:ital,wght@0,400;0,500;0,600;0,700;1,400;1,600&family=DM+Sans:opsz,wght@9..40,300;9..40,400;9..40,500;9..40,600&display=swap');

/* ── Token System ─────────────────────────────────────── */
:root {
  /* Brand */
  --primary:        #1c0b0b;      /* Deep burgundy-black */
  --primary-mid:    #2f1111;      /* Hover / pressed */
  --primary-light:  #5a1f1f;      /* Active states */
  --gold:           #b8973a;      /* Signature gold */
  --gold-light:     #d4af5a;      /* Hover gold */
  --gold-faint:     #f5edd8;      /* Gold tint bg */

  /* Semantic button colours */
  --btn-view:       #1c3f6e;      /* Navy – view / detail */
  --btn-view-hover: #15325a;
  --btn-edit:       #2e6b3e;      /* Forest green – edit */
  --btn-edit-hover: #245831;
  --btn-delete:     #8b1a1a;      /* Crimson – delete */
  --btn-delete-hover: #6e1515;
  --btn-action:     #b8973a;      /* Gold – primary actions */
  --btn-action-hover: #9a7c2e;
  --btn-neutral:    #4a5568;      /* Slate – secondary */
  --btn-neutral-hover: #374151;

  /* Surface */
  --surface:        #fafaf8;      /* Warm off-white page bg */
  --surface-card:   #ffffff;
  --surface-hover:  #f4f0e8;
  --border:         #e8e0d0;      /* Warm grey border */
  --border-subtle:  #f0ebe0;

  /* Typography */
  --text-primary:   #1a1008;
  --text-secondary: #5c4f3d;
  --text-muted:     #9a8e7e;
  --text-inverse:   #ffffff;

  /* Sidebar */
  --nav-bg:         #1c0b0b;
  --nav-w:          190px;

  /* Radius */
  --r-sm:   6px;
  --r-md:   10px;
  --r-lg:   14px;
  --r-pill: 999px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(28,11,11,0.08), 0 1px 2px rgba(28,11,11,0.04);
  --shadow-md: 0 4px 12px rgba(28,11,11,0.10), 0 1px 4px rgba(28,11,11,0.06);
  --shadow-nav: 2px 0 20px rgba(28,11,11,0.18);

  /* Motion */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --dur: 0.22s;
}

/* ── Reset ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--surface);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* ── Sidebar ──────────────────────────────────────────── */
.nav {
  width: var(--nav-w);
  background: var(--nav-bg);
  color: var(--text-inverse);
  position: fixed;
  top: 0; bottom: 0; left: 0;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  z-index: 20;
  box-shadow: var(--shadow-nav);
  display: flex;
  flex-direction: column;
  transition: transform var(--dur) var(--ease);
}

/* Gold rule accent at top of sidebar */
.nav::before {
  content: '';
  display: block;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), transparent);
  flex-shrink: 0;
}

/* Sidebar top logo/brand area */
.nav-brand {
  padding: 16px 14px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.nav-brand .firm-name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: #ffffff;
  line-height: 1.2;
}

.nav-brand .firm-tagline {
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 2px;
}

/* Nav section labels */
.nav-label {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.3);
  padding: 14px 14px 6px;
}

/* Nav links */
.nav-links {
  padding: 8px 12px;
  flex: 1;
}

.nav a {
  color: rgba(255,255,255,0.82);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--r-md);
  margin-bottom: 2px;
  font-size: 13.5px;
  font-weight: 400;
  letter-spacing: 0.01em;
  transition: background var(--dur), color var(--dur), padding-left var(--dur);
  position: relative;
}

.nav a .nav-icon {
  width: 18px;
  flex-shrink: 0;
  opacity: 0.7;
  font-size: 15px;
  text-align: center;
}

.nav a:hover {
  background: rgba(255,255,255,0.07);
  color: #ffffff;
}

.nav a:hover .nav-icon { opacity: 1; }

.nav a.active {
  background: rgba(184,151,58,0.15);
  color: var(--gold-light);
  font-weight: 500;
}

.nav a.active .nav-icon { opacity: 1; }

/* Gold left border for active link */
.nav a.active::before {
  content: '';
  position: absolute;
  left: 0; top: 6px; bottom: 6px;
  width: 3px;
  background: var(--gold);
  border-radius: 0 2px 2px 0;
}

/* User card at bottom of nav */
.nav-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,0.07);
  flex-shrink: 0;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r-md);
  cursor: pointer;
  transition: background var(--dur);
}

.nav-user:hover { background: rgba(255,255,255,0.06); }

.nav-user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--gold);
  color: var(--primary);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 13px;
  flex-shrink: 0;
}

.nav-user-info .name {
  font-size: 13px; font-weight: 500; color: #fff;
  white-space: nowrap;
}
.nav-user-info .role {
  font-size: 11px; color: rgba(255,255,255,0.4);
  white-space: nowrap;
}

/* ── Header ───────────────────────────────────────────── */
.header {
  margin-left: var(--nav-w);
  background: var(--surface-card);
  border-bottom: 1px solid var(--border);
  /* Static, locked dimensions — never shrink or animate */
  padding: 0 24px;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
  /* No transition on the header itself — margin-left only for mobile drawer */
  transition: none;
}

/* Subtle gold underline on header */
.header::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--gold) 0%, transparent 40%);
  opacity: 0.5;
}

.header .brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header .brand img {
  height: 30px;
  width: auto;
  display: block;
}

.header .brand .name {
  font-family: 'Cormorant Garamond', serif;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--primary);
}

/* Page breadcrumb / title in header */
.header .page-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

/* Header right cluster */
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-icon-btn {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--dur), border-color var(--dur);
  font-size: 15px;
}

.header-icon-btn:hover {
  background: var(--gold-faint);
  border-color: var(--gold);
  color: var(--primary);
}

/* Mobile-only toggle (hidden on desktop) */
#menuToggle {
  display: none;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 6px 8px;
  color: var(--text-primary);
  border-radius: var(--r-md);
  transition: background var(--dur);
}

#menuToggle:hover { background: var(--surface-hover); }

/* ── Main Container ───────────────────────────────────── */
.container {
  margin-left: var(--nav-w);
  padding: 24px 28px;
  transition: margin-left var(--dur) var(--ease);
  max-width: 1440px;
}

/* Page heading with gold accent */
.page-heading {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 20px;
}

.page-heading h1 {
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--primary);
  margin: 0;
  letter-spacing: 0.01em;
}

.page-heading .divider {
  width: 1px;
  height: 20px;
  background: var(--gold);
  opacity: 0.5;
}

.page-heading .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 400;
}

/* ── Card ─────────────────────────────────────────────── */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 20px 24px;
  margin-bottom: 18px;
  position: relative;
  overflow: hidden;
}

/* Subtle top-left gold corner accent */
.card.accent-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 40px; height: 3px;
  background: var(--gold);
  border-radius: 0 0 3px 0;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.card-title {
  font-family: 'Cormorant Garamond', serif;
  font-size: 17px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.02em;
}

/* ── KPI Grid ─────────────────────────────────────────── */
.kpi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}

.kpi .card {
  padding: 20px;
  transition: box-shadow var(--dur), transform var(--dur);
}

.kpi .card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.kpi-value {
  font-family: 'Cormorant Garamond', serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}

.kpi-label {
  font-size: 11.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 4px;
}

.kpi-delta {
  font-size: 12px;
  font-weight: 500;
  margin-top: 6px;
}
.kpi-delta.up   { color: #2e6b3e; }
.kpi-delta.down { color: #8b1a1a; }

/* ── Buttons ──────────────────────────────────────────── */

/* Base button */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: var(--r-md);
  padding: 7px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: filter var(--dur), background var(--dur), transform 0.1s;
  letter-spacing: 0.01em;
  line-height: 1;
}

.btn:active { transform: translateY(1px); }

/* Primary – gold (new matter, save, primary CTA) */
.btn,
.btn-primary {
  background: var(--btn-action);
  color: #fff;
  box-shadow: 0 1px 3px rgba(184,151,58,0.25);
}
.btn:hover,
.btn-primary:hover { background: var(--btn-action-hover); }

/* View / Open / Detail – navy */
.btn-view {
  background: var(--btn-view);
  color: #fff;
  box-shadow: 0 1px 3px rgba(28,63,110,0.25);
}
.btn-view:hover { background: var(--btn-view-hover); }

/* Edit / Update – forest green */
.btn-edit {
  background: var(--btn-edit);
  color: #fff;
  box-shadow: 0 1px 3px rgba(46,107,62,0.25);
}
.btn-edit:hover { background: var(--btn-edit-hover); }

/* Delete / Remove – crimson */
.btn-delete {
  background: var(--btn-delete);
  color: #fff;
  box-shadow: 0 1px 3px rgba(139,26,26,0.25);
}
.btn-delete:hover { background: var(--btn-delete-hover); }

/* Neutral / Cancel / Secondary */
.btn-neutral {
  background: var(--btn-neutral);
  color: #fff;
  box-shadow: 0 1px 3px rgba(74,85,104,0.2);
}
.btn-neutral:hover { background: var(--btn-neutral-hover); }

/* Ghost (outline) */
.btn-ghost {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
  box-shadow: none;
}
.btn-ghost:hover {
  background: var(--surface-hover);
  border-color: var(--gold);
  color: var(--primary);
}

/* Small variant */
.btn-sm {
  padding: 5px 10px;
  font-size: 12px;
  border-radius: var(--r-sm);
  gap: 4px;
}

/* Icon-only round button */
.btn-icon {
  padding: 6px;
  border-radius: var(--r-sm);
  line-height: 0;
}

/* ── Action button cluster in table rows ──────────────── */
.action-group {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}

/* ── Table ────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
}

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.table thead {
  background: #f7f3eb;
}

.table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.table td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
  vertical-align: middle;
}

.table tbody tr {
  transition: background var(--dur);
}

.table tbody tr:last-child td { border-bottom: none; }

.table tbody tr:hover { background: #fdfaf4; }

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge::before {
  content: '';
  width: 5px; height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.8;
  flex-shrink: 0;
}

.badge-active   { background: #e8f5ec; color: #1e6633; }
.badge-pending  { background: #fef6e4; color: #92600a; }
.badge-closed   { background: #f0f0f0; color: #555; }
.badge-urgent   { background: #fdeaea; color: #8b1a1a; }

/* ── Forms ────────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

input,
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: #fff;
  color: var(--text-primary);
  font-family: 'DM Sans', sans-serif;
  font-size: 13.5px;
  transition: border-color var(--dur), box-shadow var(--dur);
  outline: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(184,151,58,0.12);
}

textarea { min-height: 100px; resize: vertical; }

form .row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

/* ── Login Page ───────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary);
  background-image:
    radial-gradient(ellipse at 20% 80%, rgba(184,151,58,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(184,151,58,0.06) 0%, transparent 50%);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  padding: 40px;
  border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
}

.login-logo {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo .firm {
  font-family: 'Cormorant Garamond', serif;
  font-size: 26px;
  font-weight: 600;
  color: var(--primary);
  letter-spacing: 0.04em;
}

.login-logo .tagline {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-top: 4px;
}

/* ── Backdrop ─────────────────────────────────────────── */
.backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(28,11,11,0.45);
  backdrop-filter: blur(2px);
  z-index: 15;
  transition: opacity var(--dur);
}

.backdrop.show { display: block; }

/* ── Divider ──────────────────────────────────────────── */
.section-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

/* ── Utility ──────────────────────────────────────────── */
.flex           { display: flex; gap: 8px; align-items: center; }
.flex-between   { display: flex; justify-content: space-between; align-items: center; }
.right          { margin-left: auto; }
.text-muted     { color: var(--text-muted); font-size: 13px; }
.text-gold      { color: var(--gold); }
.text-sm        { font-size: 12px; }
.mt-4           { margin-top: 4px; }
.mt-8           { margin-top: 8px; }
.mt-16          { margin-top: 16px; }
.gap-4          { gap: 4px; }
.gap-8          { gap: 8px; }

/* ── Mobile ───────────────────────────────────────────── */
@media (max-width: 900px) {

  /* Show toggle; hide sidebar by default (off-canvas) */
  #menuToggle { display: inline-flex; }

  .header {
    margin-left: 0;
    padding: 0 16px;
    height: 52px;
    min-height: 52px;
    max-height: 52px;
    transition: none;
  }

  /* Keep brand name visible but compact */
  .header .brand .name {
    font-size: 16px;
  }

  .container {
    margin-left: 0;
    padding: 16px;
  }

  /* Off-canvas sidebar */
  .nav {
    transform: translateX(-100%);
    box-shadow: var(--shadow-nav);
  }

  .nav.open {
    transform: translateX(0);
  }

  /* Forms stack on mobile */
  form .row {
    grid-template-columns: 1fr;
  }

  /* Action buttons wrap gracefully on narrow screens */
  .action-group {
    flex-wrap: wrap;
  }

  /* KPI grid: 2 columns on tablet, 1 on small */
  .kpi {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .kpi { grid-template-columns: 1fr; }
  .card { padding: 16px; }
  .login-card { padding: 28px 20px; }
}

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  {
  background: rgba(184,151,58,0.3);
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover { background: var(--gold); }

/* ── Selection ────────────────────────────────────────── */
::selection {
  background: var(--gold-faint);
  color: var(--primary);
}