/* ===========================================================
   Blitz Advocates — Firm App styles
   Loaded by every /app/*.php page
   =========================================================== */

/* Reset / base */
body.app { margin: 0; font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif; background: var(--paper); color: var(--text); }

/* ============== TOP NAV ============== */
.app-nav {
  background: var(--ink); color: white;
  padding: 12px 24px;
  display: flex; align-items: center; gap: 18px;
  border-bottom: 3px solid var(--gold);
  position: sticky; top: 0; z-index: 50;
}
.app-brand {
  font-family: 'Fraunces', serif; font-weight: 600; color: white;
  font-size: 17px; text-decoration: none; letter-spacing: -0.01em;
}
.app-brand:hover { text-decoration: none; color: white; }
.app-brand .mark { color: var(--gold); }
.app-brand .sep { color: rgba(255,255,255,0.3); margin: 0 8px; font-weight: 300; }
.app-brand .firm-name { color: var(--gold); font-weight: 500; }
.app-nav-right {
  margin-left: auto; display: flex; align-items: center; gap: 14px;
  font-size: 13px;
}
.app-nav-right a { color: rgba(255,255,255,0.75); text-decoration: none; }
.app-nav-right a:hover { color: white; text-decoration: none; }
.user-chip { background: rgba(255,255,255,0.08); padding: 6px 12px; border-radius: 3px; font-size: 12px; }
.user-chip .user-role { color: rgba(255,255,255,0.55); margin-left: 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ============== LAYOUT ============== */
.app-layout {
  display: grid; grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 53px);
}
.app-side {
  background: white; border-right: 1px solid var(--line);
  padding: 18px 0; font-size: 14px;
}
.side-link {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: var(--text); text-decoration: none;
  border-left: 3px solid transparent;
  font-weight: 500;
}
.side-link:hover { background: var(--parchment); text-decoration: none; color: var(--ink); }
.side-link.active { border-left-color: var(--gold); background: var(--parchment); color: var(--ink); font-weight: 600; }
.side-link.disabled { color: var(--text-mute); opacity: 0.6; cursor: not-allowed; }
.side-link.disabled:hover { background: transparent; }
.side-link .ico { font-size: 16px; width: 20px; text-align: center; }
.side-divider {
  font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text-mute); font-weight: 600;
  padding: 16px 20px 6px; margin-top: 14px;
  border-top: 1px solid var(--line);
}
.app-main { padding: 28px 32px; max-width: 1200px; width: 100%; box-sizing: border-box; }

/* ============== PAGE HEADER ============== */
.page-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 22px; gap: 16px; flex-wrap: wrap;
}
.page-head h1 {
  font-family: 'Fraunces', serif; font-size: 26px; font-weight: 600;
  color: var(--ink); margin: 0; letter-spacing: -0.015em;
}
.page-head .sub { color: var(--text-soft); font-size: 14px; margin: 4px 0 0; }
.page-head .actions { display: flex; gap: 8px; }
.btn { display: inline-block; padding: 9px 16px; border-radius: 4px; font-weight: 600; font-size: 13px; text-decoration: none; border: 0; cursor: pointer; font-family: inherit; }
.btn-primary { background: var(--ink); color: white; }
.btn-primary:hover { background: var(--navy); color: white; text-decoration: none; }
.btn-gold { background: var(--gold); color: var(--ink); }
.btn-gold:hover { background: var(--gold-soft); color: var(--ink); text-decoration: none; }
.btn-ghost { background: white; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--parchment); color: var(--ink); text-decoration: none; }
.btn-danger { background: var(--error); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ============== STAT CARDS ============== */
.stat-grid {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: white; border: 1px solid var(--line); border-radius: 5px;
  padding: 18px;
}
.stat-card .lbl { font-size: 11px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--text-mute); font-weight: 600; margin-bottom: 6px; }
.stat-card .num { font-family: 'Fraunces', serif; font-size: 26px; font-weight: 600; color: var(--ink); line-height: 1.1; }
.stat-card .delta { font-size: 11px; color: var(--text-soft); margin-top: 5px; }
.stat-card .delta.up { color: #047857; }
.stat-card .delta.down { color: var(--error); }

/* ============== PANELS ============== */
.panel-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 24px; }
.panel {
  background: white; border: 1px solid var(--line); border-radius: 5px;
  padding: 20px;
}
.panel h2 { font-family: 'Fraunces', serif; font-size: 16px; font-weight: 600; color: var(--ink); margin: 0 0 14px; display: flex; justify-content: space-between; align-items: center; }
.panel h2 a { font-family: 'Inter', sans-serif; font-size: 12px; color: var(--navy); font-weight: 500; }
.panel .empty { text-align: center; padding: 30px 20px; color: var(--text-mute); font-size: 13px; }

/* ============== TABLE ============== */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl thead th {
  background: var(--parchment); padding: 9px 12px; text-align: left;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-soft); font-weight: 600; border-bottom: 1px solid var(--line);
}
.tbl tbody td {
  padding: 11px 12px; border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover { background: rgba(212,175,55,0.05); }
.tbl .case-link, .tbl .client-link { color: var(--ink); font-weight: 600; text-decoration: none; }
.tbl .case-link:hover, .tbl .client-link:hover { color: var(--navy); text-decoration: underline; }
.tbl .muted { color: var(--text-mute); font-size: 12px; }

/* ============== PILLS ============== */
.pill {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.04em;
}
.pill.active { background: rgba(16,185,129,0.15); color: #065f46; }
.pill.on_hold { background: rgba(245,158,11,0.15); color: #92400e; }
.pill.disposed { background: rgba(99,102,241,0.15); color: #3730a3; }
.pill.withdrawn { background: var(--error-bg); color: var(--error); }
.pill.scheduled { background: rgba(59,130,246,0.15); color: #1e40af; }
.pill.adjourned { background: rgba(245,158,11,0.15); color: #92400e; }
.pill.completed { background: rgba(16,185,129,0.15); color: #065f46; }
.pill.cancelled { background: var(--error-bg); color: var(--error); }
.pill.individual { background: var(--parchment); color: var(--ink); }
.pill.company { background: rgba(59,130,246,0.15); color: #1e40af; }
.pill.government { background: rgba(99,102,241,0.15); color: #3730a3; }

/* ============== FORMS ============== */
.form-card {
  background: white; border: 1px solid var(--line); border-radius: 5px;
  padding: 28px; max-width: 720px;
}
.field { margin-bottom: 16px; }
.field label {
  display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  color: var(--text-soft); text-transform: uppercase; margin-bottom: 4px;
}
.field label .req { color: var(--error); }
.field input[type="text"], .field input[type="email"], .field input[type="tel"],
.field input[type="number"], .field input[type="date"], .field input[type="datetime-local"],
.field select, .field textarea {
  width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 4px;
  font-size: 14px; font-family: inherit; background: var(--paper); box-sizing: border-box;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--gold); outline-offset: -1px; border-color: var(--gold);
}
.field textarea { min-height: 90px; resize: vertical; }
.field .help { font-size: 12px; color: var(--text-mute); margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.section-title {
  font-family: 'Fraunces', serif; font-size: 14px; font-weight: 600;
  color: var(--ink); margin: 24px 0 12px; padding-top: 14px;
  border-top: 1px solid var(--line);
}
.form-actions { display: flex; gap: 12px; align-items: center; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.form-actions a { color: var(--text-soft); font-size: 14px; }

/* ============== FILTER BAR ============== */
.filter-bar {
  background: white; border: 1px solid var(--line); border-radius: 5px;
  padding: 12px; margin-bottom: 16px;
  display: grid; grid-template-columns: 2fr 1fr 1fr auto auto; gap: 8px; align-items: end;
}
.filter-bar .field { margin: 0; }
.filter-bar label { font-size: 10px; margin-bottom: 3px; }
.filter-bar input, .filter-bar select { padding: 7px 9px; font-size: 13px; }
.filter-bar .clear { color: var(--text-mute); font-size: 12px; text-decoration: underline; }

/* ============== CASE/CLIENT DETAIL ============== */
.detail-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; }
.detail-card { background: white; border: 1px solid var(--line); border-radius: 5px; padding: 22px; margin-bottom: 16px; }
.detail-card h3 { font-family: 'Fraunces', serif; font-size: 14px; font-weight: 600; color: var(--ink); margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-mute); font-size: 11px; }
.kv { display: flex; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--text-soft); min-width: 130px; }
.kv .v { color: var(--ink); font-weight: 500; }

/* ============== EMPTY STATE ============== */
.empty-state {
  background: white; border: 1px dashed var(--line); border-radius: 5px;
  padding: 50px 20px; text-align: center; color: var(--text-mute);
}
.empty-state .ico { font-size: 36px; margin-bottom: 10px; }
.empty-state h3 { font-family: 'Fraunces', serif; color: var(--ink); margin: 0 0 6px; }
.empty-state p { margin: 0 0 16px; font-size: 13px; }

/* ============== FLASH ============== */
.flash { padding: 10px 14px; border-radius: 4px; margin-bottom: 18px; font-size: 13px; border-left: 3px solid; }
.flash.success { background: rgba(16,185,129,0.1); color: #065f46; border-color: #065f46; }
.flash.error { background: var(--error-bg); color: var(--error); border-color: var(--error); }
.flash.info { background: rgba(59,130,246,0.08); color: #1e40af; border-color: #1e40af; }

/* ============== RESPONSIVE ============== */
@media (max-width: 980px) {
  .app-layout { grid-template-columns: 1fr; }
  .app-side {
    display: flex; flex-wrap: wrap; gap: 4px; padding: 10px;
    border-right: 0; border-bottom: 1px solid var(--line);
    overflow-x: auto;
  }
  .side-link { padding: 6px 12px; font-size: 12px; border-left: 0; border-bottom: 3px solid transparent; }
  .side-link.active { border-left: 0; border-bottom-color: var(--gold); }
  .side-divider { display: none; }
  .side-link.disabled { display: none; }
  .app-main { padding: 18px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .panel-grid { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .filter-bar { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .stat-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
  .user-chip .user-role { display: none; }
}
