/* =================================================================
   ChallanClear — Design System
   Palette:  Ink Navy (authority) + Signal Amber (action/status)
             on a cool Paper Mist background.
   Type:     Fraunces (display/headlines) + Public Sans (UI/body)
   ================================================================= */

:root {
  --ink-900: #0F1C33;
  --ink-800: #16294A;
  --ink-700: #223a63;
  --paper: #EEF1F5;
  --paper-white: #FFFFFF;
  --amber: #E2A73E;
  --amber-dark: #C48A22;
  --green: #1F9D6C;
  --green-bg: #E7F6EF;
  --red: #D64545;
  --red-bg: #FBEAEA;
  --slate-700: #3D4552;
  --slate-500: #6B7280;
  --slate-300: #C7CDD6;
  --slate-100: #E4E8ED;
  --radius-sm: 6px;
  --radius-md: 10px;
  --shadow-card: 0 1px 2px rgba(15, 28, 51, 0.06), 0 1px 1px rgba(15, 28, 51, 0.04);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--slate-700);
  font-family: 'Public Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .display {
  font-family: 'Fraunces', Georgia, serif;
  color: var(--ink-900);
  font-weight: 600;
  line-height: 1.15;
  margin: 0 0 0.4em;
}
h1 { font-size: 2.1rem; font-weight: 500; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.15rem; }
p { margin: 0 0 1em; max-width: 68ch; }
a { color: var(--ink-700); }
small, .text-small { font-size: 0.85rem; color: var(--slate-500); }

/* focus visibility — never remove */
a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--amber-dark);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------------- Layout shells ---------------- */

.public-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 32px;
  background: var(--paper-white);
  border-bottom: 1px solid var(--slate-100);
}
.public-nav .brand {
  font-family: 'Fraunces', serif; font-size: 1.3rem; font-weight: 600; color: var(--ink-900);
  text-decoration: none; letter-spacing: -0.01em;
}
.public-nav .links a {
  margin-left: 22px; text-decoration: none; color: var(--slate-700); font-size: 0.95rem;
}
.public-nav .links a.btn { margin-left: 22px; }

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

.sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--ink-900);
  color: #C9D2E3;
  display: flex; flex-direction: column;
  padding: 22px 0;
}
.sidebar .brand {
  font-family: 'Fraunces', serif; color: #fff; font-size: 1.2rem; font-weight: 600;
  padding: 0 24px 20px; text-decoration: none; display: block;
  border-bottom: 1px solid rgba(255,255,255,0.08); margin-bottom: 14px;
}
.sidebar nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 24px; color: #B7C1D6; text-decoration: none; font-size: 0.94rem;
  border-left: 3px solid transparent;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.04); color: #fff; }
.sidebar nav a.active {
  background: rgba(226,167,62,0.12); color: #fff; border-left-color: var(--amber);
}
.sidebar .role-tag {
  margin: auto 24px 0; padding-top: 16px; border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.8rem; color: #8B96AC;
}
.sidebar .role-tag strong { display: block; color: #fff; font-size: 0.9rem; }

.main {
  flex: 1; min-width: 0;
  padding: 28px 36px 60px;
}
.main .topline {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px;
  flex-wrap: wrap; gap: 12px;
}
.main .topline .logout-link { font-size: 0.88rem; color: var(--slate-500); text-decoration: none; }

/* Mobile: collapse sidebar to a top bar */
@media (max-width: 860px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; align-items: center; padding: 12px 16px; overflow-x: auto; }
  .sidebar .brand { border: none; padding: 0 16px 0 0; margin: 0; white-space: nowrap; }
  .sidebar nav { display: flex; }
  .sidebar nav a { padding: 8px 14px; white-space: nowrap; border-left: none; border-bottom: 3px solid transparent; }
  .sidebar nav a.active { border-left: none; border-bottom-color: var(--amber); }
  .sidebar .role-tag { display: none; }
  .main { padding: 20px 16px 48px; }
}

/* ---------------- Buttons ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 0.95rem; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 1px solid transparent; font-family: inherit;
}
.btn-primary { background: var(--amber); color: var(--ink-900); }
.btn-primary:hover { background: var(--amber-dark); }
.btn-dark { background: var(--ink-900); color: #fff; }
.btn-dark:hover { background: var(--ink-800); }
.btn-outline { background: transparent; border-color: var(--slate-300); color: var(--slate-700); }
.btn-outline:hover { border-color: var(--ink-700); color: var(--ink-900); }
.btn-danger { background: var(--red-bg); color: var(--red); }
.btn-sm { padding: 6px 14px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

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

.card {
  background: var(--paper-white); border-radius: var(--radius-md);
  box-shadow: var(--shadow-card); padding: 22px; margin-bottom: 20px;
}
.case-card {
  background: var(--paper-white); border-radius: var(--radius-sm);
  border-left: 4px solid var(--slate-300);
  box-shadow: var(--shadow-card);
  padding: 16px 18px; margin-bottom: 14px;
}
.case-card.status-open { border-left-color: var(--slate-300); }
.case-card.status-quoted { border-left-color: var(--amber); }
.case-card.status-in_progress { border-left-color: var(--ink-700); }
.case-card.status-resolved { border-left-color: var(--green); }
.case-card.status-cancelled { border-left-color: var(--red); }

.stat-row { display: flex; flex-wrap: wrap; gap: 16px; margin-bottom: 24px; }
.stat-box {
  background: var(--paper-white); border-radius: var(--radius-md);
  padding: 18px 20px; flex: 1; min-width: 150px; box-shadow: var(--shadow-card);
}
.stat-box .num { font-family: 'Fraunces', serif; font-size: 1.9rem; color: var(--ink-900); display:block; }
.stat-box .label { font-size: 0.85rem; color: var(--slate-500); }

/* ---------------- Status labels (not pill badges — plain tag) ---------------- */
.status-label { font-size: 0.78rem; font-weight: 600; padding: 3px 9px; border-radius: 4px; white-space: nowrap; }
.status-open { background: var(--slate-100); color: var(--slate-700); }
.status-quoted { background: #FBF1DC; color: var(--amber-dark); }
.status-in_progress { background: #E7ECF5; color: var(--ink-700); }
.status-resolved { background: var(--green-bg); color: var(--green); }
.status-cancelled { background: var(--red-bg); color: var(--red); }
.status-pending { background: var(--slate-100); color: var(--slate-700); }
.status-approved { background: var(--green-bg); color: var(--green); }
.status-rejected { background: var(--red-bg); color: var(--red); }
.status-active { background: var(--green-bg); color: var(--green); }
.status-inactive { background: var(--slate-100); color: var(--slate-500); }

/* ---------------- Forms ---------------- */

label { display: block; font-size: 0.88rem; font-weight: 600; color: var(--ink-800); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=tel],
input[type=number], input[type=date], select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--slate-300); border-radius: var(--radius-sm);
  font-size: 0.95rem; font-family: inherit; background: #fff; color: var(--slate-700);
  margin-bottom: 16px;
}
textarea { resize: vertical; min-height: 80px; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row > * { flex: 1; min-width: 200px; }
.form-hint { margin-top: -10px; margin-bottom: 16px; }
fieldset { border: 1px solid var(--slate-100); border-radius: var(--radius-sm); padding: 14px 16px; margin-bottom: 16px; }
legend { font-weight: 600; color: var(--ink-800); padding: 0 6px; font-size: 0.9rem; }
.checkbox-row { display: flex; align-items: flex-start; gap: 10px; margin-bottom: 14px; }
.checkbox-row input { width: auto; margin: 4px 0 0; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px 16px; margin-bottom: 16px; }
.checkbox-grid label { display: flex; align-items: center; gap: 8px; font-weight: 400; margin: 0; }
.checkbox-grid input { width: auto; margin: 0; }

/* ---------------- Alerts / flash ---------------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 0.92rem; }
.alert-error { background: var(--red-bg); color: var(--red); }
.alert-success { background: var(--green-bg); color: var(--green); }
.alert-info { background: #E7ECF5; color: var(--ink-700); }

/* ---------------- Tables ---------------- */
table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius-md); overflow: hidden; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--slate-100); font-size: 0.92rem; }
th { background: var(--paper); color: var(--slate-500); font-weight: 600; font-size: 0.82rem; }
tr:last-child td { border-bottom: none; }

/* ---------------- Timeline (case status is a real sequence) ---------------- */
.timeline { list-style: none; margin: 0 0 20px; padding: 0; }
.timeline li {
  position: relative; padding: 0 0 20px 28px; border-left: 2px solid var(--slate-100);
}
.timeline li:last-child { border-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: -6px; top: 2px; width: 10px; height: 10px;
  border-radius: 50%; background: var(--slate-300);
}
.timeline li.done::before { background: var(--green); }
.timeline .t-label { font-weight: 600; color: var(--ink-900); font-size: 0.94rem; }
.timeline .t-meta { color: var(--slate-500); font-size: 0.82rem; }

/* ---------------- Chat ---------------- */
.chat-window { background: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-card); display: flex; flex-direction: column; height: 460px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.chat-bubble { max-width: 75%; padding: 9px 13px; border-radius: 12px; font-size: 0.9rem; line-height: 1.4; }
.chat-bubble.mine { align-self: flex-end; background: var(--ink-900); color: #fff; border-bottom-right-radius: 3px; }
.chat-bubble.theirs { align-self: flex-start; background: var(--paper); color: var(--slate-700); border-bottom-left-radius: 3px; }
.chat-bubble .meta { display: block; font-size: 0.7rem; opacity: 0.7; margin-top: 4px; }
.chat-quick-replies { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--slate-100); }
.chat-quick-replies button { background: var(--paper); border: 1px solid var(--slate-300); border-radius: 16px; padding: 6px 14px; font-size: 0.85rem; cursor: pointer; }
.chat-quick-replies button:hover { border-color: var(--ink-700); }
.chat-free-input { display: flex; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--slate-100); }
.chat-free-input input { margin: 0; }
.chat-locked-note { padding: 12px 18px; font-size: 0.85rem; color: var(--slate-500); border-top: 1px solid var(--slate-100); }

/* ---------------- Landing page ---------------- */
.hero {
  display: flex; align-items: center; gap: 48px; padding: 64px 32px; max-width: 1180px; margin: 0 auto;
  flex-wrap: wrap;
}
.hero-copy { flex: 1; min-width: 300px; }
.hero-copy h1 { font-size: 2.6rem; max-width: 12ch; }
.hero-copy .lede { font-size: 1.15rem; color: var(--slate-700); max-width: 44ch; }
.hero-actions { display: flex; gap: 14px; margin-top: 24px; flex-wrap: wrap; }

/* the "ticket stub" motif: a perforated divider used ONCE, where content really is a hand-off */
.ticket-stub {
  flex: 1; min-width: 280px; max-width: 380px;
  background: #fff; border-radius: var(--radius-md); box-shadow: 0 8px 30px rgba(15,28,51,0.12);
  position: relative; padding: 26px 24px;
}
.ticket-stub::before {
  content: ''; position: absolute; left: 0; right: 0; top: 62%;
  height: 0; border-top: 2px dashed var(--slate-300);
}
.ticket-stub::after {
  content: ''; position: absolute; left: -10px; top: 62%; width: 20px; height: 20px;
  background: var(--paper); border-radius: 50%; transform: translateY(-50%);
  box-shadow: 360px 0 0 var(--paper);
}
.ticket-stub .t-top .status-label { margin-bottom: 10px; }
.ticket-stub .t-bottom { padding-top: 22px; }
.ticket-stub .amount { font-family: 'Fraunces', serif; font-size: 1.7rem; color: var(--ink-900); }

.section { max-width: 1180px; margin: 0 auto; padding: 20px 32px 64px; }
.how-steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 24px; margin-top: 28px; }
.how-step .step-num { font-family: 'Fraunces', serif; font-size: 1.6rem; color: var(--amber-dark); }
.role-split { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-top: 20px; }
@media (max-width: 700px) { .role-split { grid-template-columns: 1fr; } .hero { padding: 40px 20px; } }

.role-panel { background: var(--paper-white); border-radius: var(--radius-md); box-shadow: var(--shadow-card); padding: 28px; }
.role-panel.lawyer { background: var(--ink-900); color: #C9D2E3; }
.role-panel.lawyer h3 { color: #fff; }

footer.site-footer { text-align: center; padding: 30px; color: var(--slate-500); font-size: 0.85rem; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--slate-500); }
.empty-state h3 { color: var(--ink-800); }

.quote-list { display: flex; flex-direction: column; gap: 12px; }
.quote-item { background: #fff; border: 1px solid var(--slate-100); border-radius: var(--radius-sm); padding: 14px 16px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.quote-item .fee { font-family: 'Fraunces', serif; font-size: 1.3rem; color: var(--ink-900); }
