/* =============================================
   CMS - Enterprise Case Management System
   Global Stylesheet
   ============================================= */

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

:root {
  --primary:        #1a3a5c;
  --primary-light:  #1e4976;
  --accent:         #2d6da4;
  --accent-hover:   #245d8e;
  --bg-page:        #f0f2f5;
  --bg-card:        #ffffff;
  --bg-sidebar:     #1a3a5c;
  --border:         #dde1e7;
  --border-light:   #eaecef;
  --text-primary:   #1a1f2e;
  --text-secondary: #4a5568;
  --text-muted:     #718096;
  --text-white:     #ffffff;
  --success:        #2e7d32;
  --success-bg:     #e8f5e9;
  --warning:        #e65100;
  --warning-bg:     #fff3e0;
  --danger:         #c62828;
  --danger-bg:      #ffebee;
  --info:           #01579b;
  --info-bg:        #e1f5fe;
  --neutral:        #455a64;
  --neutral-bg:     #eceff1;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.10);
  --shadow-md:      0 4px 12px rgba(0,0,0,.10);
  --shadow-lg:      0 8px 24px rgba(0,0,0,.12);
  --radius:         4px;
  --radius-md:      6px;
  --font:           'Segoe UI', system-ui, -apple-system, sans-serif;
}

html, body {
  height: 100%;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-page);
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Typography ────────────────────────── */
h1 { font-size: 1.5rem; font-weight: 600; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
h4 { font-size: .9rem;  font-weight: 600; }

/* ── Buttons ───────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 16px;
  font-size: 13px;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
  font-family: var(--font);
}
.btn-primary   { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-secondary { background: #fff; color: var(--text-primary); border-color: var(--border); }
.btn-secondary:hover { background: #f4f6f8; }
.btn-success   { background: var(--success); color: #fff; border-color: var(--success); }
.btn-success:hover { background: #256427; }
.btn-danger    { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover  { background: #ad1f1f; }
.btn-warning   { background: var(--warning); color: #fff; border-color: var(--warning); }
.btn-warning:hover { background: #cf4600; }
.btn-ghost     { background: transparent; color: var(--accent); border-color: var(--accent); }
.btn-ghost:hover { background: var(--info-bg); }
.btn-sm        { padding: 4px 10px; font-size: 12px; }
.btn-lg        { padding: 10px 22px; font-size: 15px; }
.btn[disabled], .btn:disabled { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ── Badges / Status Pills ─────────────── */
.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .2px;
}
.badge-success  { background: var(--success-bg); color: var(--success); }
.badge-warning  { background: var(--warning-bg); color: var(--warning); }
.badge-danger   { background: var(--danger-bg);  color: var(--danger);  }
.badge-info     { background: var(--info-bg);    color: var(--info);    }
.badge-neutral  { background: var(--neutral-bg); color: var(--neutral); }
.badge-primary  { background: #dce8f5; color: var(--primary); }

/* ── Card ──────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-body    { padding: 20px; }
.card-footer  { padding: 12px 20px; border-top: 1px solid var(--border-light); background: #fafbfc; border-radius: 0 0 var(--radius-md) var(--radius-md); }

/* ── Top Nav Bar ───────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  background: var(--primary);
  display: flex;
  align-items: center;
  padding: 0 20px;
  z-index: 1000;
  box-shadow: var(--shadow-md);
}
.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: .4px;
  flex-shrink: 0;
}
.topbar-brand .brand-icon {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.topbar-spacer { flex: 1; }
.topbar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.topbar-nav a {
  color: rgba(255,255,255,.75);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  border-radius: var(--radius);
  transition: background .15s, color .15s;
}
.topbar-nav a:hover, .topbar-nav a.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  text-decoration: none;
}
.topbar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 16px;
  color: rgba(255,255,255,.9);
  font-size: 13px;
  cursor: pointer;
}
.topbar-user .avatar {
  width: 32px; height: 32px;
  background: var(--accent);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: #fff;
  border: 2px solid rgba(255,255,255,.3);
}
.topbar-divider {
  width: 1px; height: 24px;
  background: rgba(255,255,255,.2);
  margin: 0 8px;
}

/* ── Sidebar ───────────────────────────── */
.sidebar {
  position: fixed;
  top: 56px; left: 0; bottom: 0;
  width: 220px;
  background: var(--bg-sidebar);
  overflow-y: auto;
  z-index: 900;
  padding-top: 8px;
}
.sidebar-section {
  padding: 18px 14px 4px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: rgba(255,255,255,.4);
}
.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  color: rgba(255,255,255,.72);
  font-size: 13.5px;
  transition: background .15s, color .15s;
  cursor: pointer;
  text-decoration: none;
  border-left: 3px solid transparent;
}
.sidebar-item:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
  text-decoration: none;
}
.sidebar-item.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  border-left-color: #5da0e0;
}
.sidebar-item .icon { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.sidebar-badge {
  margin-left: auto;
  background: var(--accent);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
}

/* ── Main Layout ───────────────────────── */
.layout {
  display: flex;
  padding-top: 56px;
  min-height: 100vh;
}
.main-content {
  flex: 1;
  margin-left: 220px;
  padding: 24px;
  min-height: calc(100vh - 56px);
}

/* ── Page Header ───────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 16px;
}
.page-header-left h1 {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-primary);
}
.page-header-left .breadcrumb {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.page-header-left .breadcrumb a { color: var(--accent); }
.page-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* ── Stats Row ─────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 22px;
}
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.stat-card .stat-label  { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .6px; color: var(--text-muted); }
.stat-card .stat-value  { font-size: 1.7rem; font-weight: 700; color: var(--text-primary); line-height: 1; }
.stat-card .stat-sub    { font-size: 11.5px; color: var(--text-muted); }
.stat-card .stat-icon   { font-size: 22px; margin-bottom: 4px; }

/* ── Data Table ────────────────────────── */
.table-wrapper { overflow-x: auto; }
table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.data-table thead th {
  background: #f4f6f9;
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.data-table tbody td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-primary);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover td { background: #f9fafc; }
.data-table tbody tr.clickable-row { cursor: pointer; }
.data-table tbody tr.clickable-row:hover td { background: #eef4fb; }
.data-table .col-id    { width: 110px; font-family: monospace; font-size: 12px; color: var(--text-secondary); }
.data-table .col-name  { min-width: 160px; font-weight: 500; }
.data-table .col-actions { width: 90px; text-align: right; }

/* ── Tabs ──────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 0;
  gap: 0;
}
.tab-item {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s, border-color .15s;
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
}
.tab-item:hover { color: var(--accent); }
.tab-item.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-count {
  background: var(--info-bg);
  color: var(--info);
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 10px;
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ── Search / Filter Bar ───────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  padding: 12px 16px;
  background: #f9fafc;
  border-bottom: 1px solid var(--border-light);
}
.filter-bar input[type="text"],
.filter-bar select {
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-primary);
  background: #fff;
  outline: none;
  font-family: var(--font);
}
.filter-bar input[type="text"]:focus,
.filter-bar select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(45,109,164,.15); }
.filter-bar input[type="text"] { min-width: 220px; }
.search-icon-wrap { position: relative; }
.search-icon-wrap input { padding-left: 30px; }
.search-icon-wrap::before {
  content: '🔍';
  position: absolute;
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 12px;
  pointer-events: none;
}
.filter-spacer { flex: 1; }

/* ── Form Controls ─────────────────────── */
.form-group   { margin-bottom: 16px; }
.form-label   { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-secondary); margin-bottom: 5px; }
.form-control {
  display: block;
  width: 100%;
  padding: 8px 11px;
  font-size: 13.5px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  color: var(--text-primary);
  font-family: var(--font);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(45,109,164,.15); }
.form-control[readonly] { background: #f4f6f8; color: var(--text-secondary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Detail Page Layout ────────────────── */
.detail-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}
.detail-section { margin-bottom: 20px; }
.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

/* ── Case Header Banner ────────────────── */
.case-banner {
  background: var(--primary);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 20px;
  color: #fff;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}
.case-banner h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.case-banner .case-meta { display: flex; gap: 18px; flex-wrap: wrap; margin-top: 10px; }
.case-banner .meta-item { font-size: 12.5px; opacity: .85; }
.case-banner .meta-item strong { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; opacity: .7; margin-bottom: 2px; }
.case-actions-right { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; }

/* ── Info Grid ─────────────────────────── */
.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px 20px;
}
.info-item .info-label { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); margin-bottom: 3px; }
.info-item .info-value { font-size: 13.5px; color: var(--text-primary); font-weight: 500; }
.info-item .info-value a { color: var(--accent); }

/* ── Timeline ──────────────────────────── */
.timeline { list-style: none; position: relative; padding-left: 24px; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.timeline-item { position: relative; padding: 0 0 18px; }
.timeline-item::before {
  content: '';
  position: absolute;
  left: -21px; top: 4px;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--accent);
}
.timeline-item.system::before  { border-color: var(--text-muted); }
.timeline-item.warning::before { border-color: var(--warning); }
.timeline-item.success::before { border-color: var(--success); }
.timeline-time { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.timeline-title { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.timeline-desc  { font-size: 12.5px; color: var(--text-secondary); margin-top: 2px; }

/* ── Document List ─────────────────────── */
.doc-list { list-style: none; }
.doc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}
.doc-item:last-child { border-bottom: none; }
.doc-icon { font-size: 20px; flex-shrink: 0; }
.doc-name { font-weight: 500; }
.doc-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }
.doc-actions { margin-left: auto; }

/* ── Risk Score ────────────────────────── */
.risk-score-wrap { display: flex; flex-direction: column; gap: 8px; }
.risk-bar-outer { background: var(--border); border-radius: 4px; height: 8px; overflow: hidden; }
.risk-bar-inner { height: 100%; border-radius: 4px; }
.risk-low    .risk-bar-inner { background: var(--success); width: 28%; }
.risk-medium .risk-bar-inner { background: var(--warning); width: 55%; }
.risk-high   .risk-bar-inner { background: var(--danger);  width: 82%; }
.risk-label-row { display: flex; justify-content: space-between; font-size: 12px; }

/* ── Alert / Notice ────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 14px;
  border: 1px solid transparent;
}
.alert-info    { background: var(--info-bg);    border-color: #b3d9f7; color: var(--info); }
.alert-warning { background: var(--warning-bg); border-color: #ffcc80; color: var(--warning); }
.alert-success { background: var(--success-bg); border-color: #a5d6a7; color: var(--success); }
.alert-danger  { background: var(--danger-bg);  border-color: #ef9a9a; color: var(--danger); }

/* ── Dropdown Menu (User) ──────────────── */
.dropdown { position: relative; }
.dropdown-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  z-index: 9999;
  overflow: hidden;
}
.dropdown-menu.show { display: block; }
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background .12s;
  text-decoration: none;
}
.dropdown-item:hover { background: #f4f6f8; text-decoration: none; }
.dropdown-item.danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border-light); margin: 4px 0; }

/* ── Scrollbar ─────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c1c8d0; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aab4; }

/* ── Utility ───────────────────────────── */
.text-muted    { color: var(--text-muted); }
.text-secondary{ color: var(--text-secondary); }
.text-danger   { color: var(--danger); }
.text-success  { color: var(--success); }
.text-warning  { color: var(--warning); }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-0 { margin-bottom: 0; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-1 { flex: 1; }
.monospace { font-family: 'Courier New', monospace; font-size: 12px; }

/* ── Responsive tweaks ─────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .main-content { margin-left: 0; }
  .detail-layout { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .form-row, .form-row-3 { grid-template-columns: 1fr; }
}
