/* LawHarbor — Application Styles */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --sidebar-width: 240px;
  --header-height: 68px;

  /* Brand palette */
  --color-midnight:       #013C65;
  --color-midnight-hover: #024d82;
  --color-midnight-light: #d0e4f5;
  --color-sunglow:        #FFB71B;
  --color-sunglow-hover:  #e6a318;
  --color-sunglow-light:  #fff3d0;
  --color-mist:           #E6EBF0;
  --color-white:          #FFFFFF;
  --color-carbon:         #333333;

  /* Semantic aliases used throughout */
  --color-navy:         var(--color-midnight);
  --color-navy-hover:   var(--color-midnight-hover);
  --color-accent:       var(--color-midnight);
  --color-accent-hover: var(--color-midnight-hover);
  --color-bg:           var(--color-mist);
  --color-text:         var(--color-carbon);
  --color-border:       #c8d3dc;
  --color-muted:        #6b7590;

  /* Status colors */
  --color-success: #22a06b;
  --color-warning: #e8832a;
  --color-danger:  #d73c3c;
  --color-info:    var(--color-midnight);

  /* Typography */
  --font:      'IBM Plex Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'IBM Plex Mono', 'Courier New', monospace;

  /* Effects */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.07);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.10);
  --radius: 8px;
}

body {
  font-family: var(--font);
  font-size: 14px;
  color: var(--color-text);
  background: var(--color-midnight);
  line-height: 1.5;
  min-height: 100vh;
}

/* ── Layout ── */

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

/* ── Sidebar ── */

.sidebar {
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  text-decoration: none;
}

.sidebar-logo {
  width: 140px;
  height: auto;
  display: block;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.sidebar-section-label {
  padding: 16px 20px 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

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

.sidebar-nav a.active {
  background: rgba(255, 183, 27, 0.15);
  color: #fff;
  border-left-color: var(--color-sunglow);
}

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

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  color: rgba(255,255,255,0.55);
  text-decoration: none;
  font-size: 13px;
  padding: 6px 0;
  transition: color 0.15s;
}

.sidebar-footer a:hover {
  color: #fff;
}

/* ── Main area ── */

.main-wrapper {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Header ── */

.app-header {
  height: var(--header-height);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
}

.header-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}

.page-title {
  font-size: 17px;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: rgba(255,255,255,0.6);
}

.breadcrumb a {
  color: rgba(255,255,255,0.85);
  text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

.breadcrumb-sep { color: rgba(255,255,255,0.3); }

.header-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--color-sunglow);
  color: var(--color-midnight);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

/* ── Content area (white window) ── */

.content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--color-white);
  border-top-left-radius: var(--radius);
  overflow: hidden;
  box-shadow: -4px -4px 24px rgba(0, 0, 0, 0.18);
}

/* ── Content ── */

.page-content {
  flex: 1;
  padding: 28px;
}

/* ── Page header row ── */

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text);
}

/* ── Buttons ── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: background 0.15s, box-shadow 0.15s;
  line-height: 1;
}

.btn-primary {
  background: var(--color-midnight);
  color: #fff;
}

.btn-primary:hover { background: var(--color-midnight-hover); }

.btn-outline {
  background: transparent;
  color: var(--color-text);
  border: 1px solid var(--color-border);
}

.btn-outline:hover { background: var(--color-mist); }

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-sm {
  padding: 5px 12px;
  font-size: 13px;
}

/* ── Cards ── */

.card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text);
}

.card-body {
  padding: 20px;
}

/* ── Stats row ── */

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
}

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

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text);
}

.stat-sub {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 4px;
}

/* ── Table ── */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-muted);
  background: var(--color-mist);
  border-bottom: 1px solid var(--color-border);
}

tbody tr {
  border-bottom: 1px solid var(--color-border);
  transition: background 0.1s;
}

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

tbody tr:hover { background: var(--color-mist); }

tbody td {
  padding: 12px 16px;
  font-size: 14px;
  color: var(--color-text);
}

.table-link {
  color: var(--color-midnight);
  text-decoration: none;
  font-weight: 500;
}

.table-link:hover { text-decoration: underline; }

/* ── Badges ── */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-new        { background: #e8f0fe; color: #2f6bec; }
.badge-contacted  { background: #fff3e0; color: #e8832a; }
.badge-qualified  { background: #e8f5e9; color: #22a06b; }
.badge-converted  { background: #f3e8ff; color: #7c3aed; }
.badge-disqualified { background: #fef2f2; color: #d73c3c; }

.badge-open    { background: #e8f5e9; color: #22a06b; }
.badge-intake  { background: #fff3e0; color: #e8832a; }
.badge-pending { background: #e8f0fe; color: #2f6bec; }
.badge-closed  { background: #f1f5f9; color: #6b7590; }
.badge-archived { background: #f1f5f9; color: #6b7590; }

.badge-todo       { background: #f1f5f9; color: #6b7590; }
.badge-inprogress { background: #e8f0fe; color: #2f6bec; }
.badge-done       { background: #e8f5e9; color: #22a06b; }
.badge-cancelled  { background: #fef2f2; color: #d73c3c; }

.badge-low    { background: #f1f5f9; color: #6b7590; }
.badge-medium { background: #fff3e0; color: #e8832a; }
.badge-high   { background: #fef2f2; color: #d73c3c; }
.badge-urgent { background: #fef2f2; color: #7c0000; }

/* ── Detail layout ── */

.detail-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}

.detail-main { min-width: 0; }
.detail-side { display: flex; flex-direction: column; gap: 16px; }

/* ── Definition list ── */

.def-list {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 12px 16px;
  font-size: 14px;
}

.def-label {
  font-weight: 500;
  color: var(--color-muted);
}

.def-value {
  color: var(--color-text);
}

/* ── Section titles ── */

.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-muted);
  margin-bottom: 14px;
}

/* ── Notes / Comments ── */

.notes-block {
  background: var(--color-mist);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.6;
  white-space: pre-wrap;
}

.comment-list { display: flex; flex-direction: column; gap: 12px; }

.comment {
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  background: var(--color-white);
}

.comment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.comment-author {
  font-weight: 600;
  font-size: 13px;
  color: var(--color-text);
}

.comment-date {
  font-size: 12px;
  color: var(--color-muted);
}

.comment-body {
  font-size: 14px;
  color: var(--color-text);
  line-height: 1.5;
}

/* ── Form elements ── */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-text);
}

.form-control {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-white);
  transition: border-color 0.15s;
  outline: none;
}

.form-control:focus {
  border-color: var(--color-midnight);
  box-shadow: 0 0 0 3px rgba(1, 60, 101, 0.12);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-hint {
  font-size: 12px;
  color: var(--color-muted);
}

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

/* ── Settings layout ── */

.settings-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 24px;
  align-items: start;
}

.settings-nav {
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.settings-nav a {
  display: block;
  padding: 11px 16px;
  font-size: 14px;
  color: var(--color-text);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.settings-nav a:hover { background: var(--color-mist); }

.settings-nav a.active {
  background: var(--color-midnight-light);
  color: var(--color-midnight);
  border-left-color: var(--color-midnight);
  font-weight: 500;
}

.settings-section { display: none; }
.settings-section.active { display: block; }

/* ── Divider ── */

.divider {
  height: 1px;
  background: var(--color-border);
  margin: 20px 0;
}

/* ── Empty state ── */

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--color-muted);
}

.empty-state-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text);
  margin-bottom: 6px;
}

.empty-state p { font-size: 14px; }

/* ── Linked items list ── */

.linked-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
}

.linked-item:last-child { border-bottom: none; }

.linked-item-title {
  font-weight: 500;
  color: var(--color-midnight);
  text-decoration: none;
}

.linked-item-title:hover { text-decoration: underline; }

.linked-item-meta {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 2px;
}

/* ── Footer ── */

.app-footer {
  border-top: 1px solid var(--color-border);
  padding: 14px 28px;
  font-size: 12px;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* ── Filter bar ── */

.filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.filter-bar .form-control {
  width: auto;
  min-width: 160px;
}

.search-input {
  min-width: 240px;
}

/* ── Alerts (inside app layout) ── */

.alert {
  padding: 11px 16px;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 20px;
  position: relative;
}

.alert-error   { background: #fef2f2; border: 1px solid #fecaca; color: var(--color-danger); }
.alert-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: var(--color-success); }
.alert-info    { background: #eff6ff; border: 1px solid #bfdbfe; color: var(--color-info); }

.alert-dismissible { padding-right: 40px; }

.alert-close {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  line-height: 1;
  padding: 0;
}

.alert-close:hover { opacity: 1; }

/* ── User dropdown ── */

.header-user-menu {
  position: relative;
}

.user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  background: var(--color-white);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  z-index: 200;
}

.user-dropdown.open { display: block; }

.user-dropdown-header {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.user-dropdown-header strong {
  font-size: 14px;
  color: var(--color-text);
}

.user-dropdown-header span {
  font-size: 12px;
  color: var(--color-muted);
}

.user-dropdown a {
  display: block;
  padding: 9px 16px;
  font-size: 14px;
  color: var(--color-text);
  text-decoration: none;
  transition: background 0.1s;
}

.user-dropdown a:hover { background: var(--color-mist); }

.user-dropdown-divider {
  height: 1px;
  background: var(--color-border);
}

.user-dropdown-danger { color: var(--color-danger) !important; }

/* ── Pagination ── */

.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 16px;
  border-top: 1px solid var(--color-border);
  font-size: 13px;
}

.pagination a, .pagination span {
  padding: 4px 10px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--color-text);
}

.pagination a:hover { background: var(--color-mist); }
.pagination .current { background: var(--color-midnight); color: #fff; }
.pagination .disabled { color: var(--color-muted); }

/* ── Note form inline ── */

.note-form {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
}

.note-form textarea {
  flex: 1;
  min-height: 60px;
}

/* ── Badge extra variants ── */

.badge-client          { background: #e8f0fe; color: #2f6bec; }
.badge-opposing_party  { background: #fef2f2; color: #d73c3c; }
.badge-witness         { background: #fff3e0; color: #e8832a; }
.badge-expert          { background: #f3e8ff; color: #7c3aed; }
.badge-court_personnel { background: #f0fdf4; color: #22a06b; }
.badge-other           { background: #f1f5f9; color: #6b7590; }

.badge-in_progress { background: #e8f0fe; color: #2f6bec; }

/* ── Header omni-search ── */

.header-search {
  display: flex;
  align-items: center;
  gap: 0;
  position: relative;
}

.header-search-input {
  width: 420px;
  height: 42px;
  padding: 0 44px 0 16px;
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font);
  border: 1px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.12);
  color: #fff;
  transition: width 0.2s, border-color 0.15s, background 0.15s;
  outline: none;
}

.header-search-input::placeholder {
  color: rgba(255,255,255,0.5);
}

.header-search-input:focus {
  width: 480px;
  border-color: var(--color-sunglow);
  background: rgba(255,255,255,0.18);
  box-shadow: 0 0 0 3px rgba(255, 183, 27, 0.2);
}

.header-search-btn {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: rgba(255,255,255,0.6);
  padding: 0;
  line-height: 1;
}

.header-search-btn:hover {
  color: var(--color-sunglow);
}
