/* =========================================================
   元端律所案件管理系统 — VI Design System
   Dark Mode First · Borderless · Restrained Color
   ========================================================= */

/* ─── Design Tokens ─────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-base:     #0A0A0B;
  --bg-surface:  #15181C;
  --bg-elevated: #1C2127;
  --bg-overlay:  rgba(10, 10, 11, 0.85);

  /* Text */
  --text-primary:   #F7F7F5;
  --text-secondary: rgba(247, 247, 245, 0.65);
  --text-muted:     rgba(247, 247, 245, 0.3);

  /* Brand */
  --brand-red:      #C91A22;
  --brand-red-dark: #A5151C;
  --brand-red-glow: rgba(201, 26, 34, 0.25);

  /* Semantic */
  --success-bg:   rgba(46, 125, 50, 0.25);
  --success-text: #4CAF50;
  --warning-bg:   rgba(245, 127, 23, 0.2);
  --warning-text: #F5A623;
  --danger-bg:    rgba(201, 26, 34, 0.2);
  --danger-text:  #E8453C;
  --info-bg:      rgba(30, 90, 180, 0.2);
  --info-text:    #64B5F6;

  /* Divider */
  --divider: rgba(247, 247, 245, 0.08);

  /* Aliases (kept for backward-compat with JS helpers that read CSS vars) */
  --primary:        var(--brand-red);
  --danger:         var(--danger-text);
  --success:        var(--success-text);
  --warning:        var(--warning-text);
  --bg:             var(--bg-base);
  --card-bg:        var(--bg-surface);
  --text:           var(--text-primary);
  --border:         var(--divider);
  --shadow:         0 4px 24px rgba(0, 0, 0, 0.45);

  /* Typography */
  --font: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", Inter, -apple-system, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", Consolas, monospace;

  /* Spacing / radius */
  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;
}

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

/* ─── Base ───────────────────────────────────────────────── */
body {
  font-family: var(--font);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--text-secondary);
  text-decoration: none;
  transition: color 0.15s;
}
a:hover { color: var(--text-primary); }

input, select, textarea, button {
  font-family: var(--font);
}

/* ─── Navigation ─────────────────────────────────────────── */
.header {
  background: rgba(15, 18, 22, 0.82);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--divider);
  padding: 0 24px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
}

.header h1 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: 0.02em;
}

.nav {
  display: flex;
  gap: 4px;
  align-items: center;
}

.nav a,
.nav-link {
  color: var(--text-secondary);
  font-size: 14px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  position: relative;
  transition: color 0.15s;
}

.nav a:hover,
.nav-link:hover {
  color: var(--text-primary);
  text-decoration: none;
}

.nav a.active,
.nav-link.active {
  color: var(--text-primary);
}

/* 2px 朱砂红 active 指示线 */
.nav a.active::after,
.nav-link.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 12px;
  right: 12px;
  height: 2px;
  background: var(--brand-red);
  border-radius: 1px;
}

.nav-logout {
  margin-left: 16px;
  color: var(--text-muted) !important;
  font-size: 13px;
}

/* ─── Layout ─────────────────────────────────────────────── */
.main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 80px 24px 40px;
}

/* ─── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--divider);
  padding: 24px;
  margin-bottom: 20px;
}

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

/* ─── Stats Grid ─────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--divider);
  padding: 20px;
  text-align: center;
}

.stat-card .number {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.stat-card .number.danger  { color: var(--danger-text); }
.stat-card .number.warning { color: var(--warning-text); }
.stat-card .number.success { color: var(--success-text); }

.stat-card .label {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 6px;
}

/* ─── Table ──────────────────────────────────────────────── */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid var(--divider);
  font-size: 14px;
}

.table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: transparent;
  padding-bottom: 10px;
}

.table tbody tr {
  transition: background 0.12s;
}

.table tbody tr:hover {
  background: var(--bg-elevated);
}

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

/* ─── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.6;
}

.badge-primary { background: var(--info-bg);    color: var(--info-text); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger-text); }
.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-gray    { background: rgba(247,247,245,0.08); color: var(--text-secondary); }

/* ─── Buttons ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  transition: opacity 0.15s, background 0.15s;
  white-space: nowrap;
}

.btn:hover { opacity: 0.85; text-decoration: none; }
.btn:active { opacity: 0.7; }

.btn-primary   { background: var(--brand-red);      color: #fff; }
.btn-danger    { background: var(--danger-text);     color: #fff; }
.btn-success   { background: var(--success-text);    color: #fff; }
.btn-warning   { background: var(--warning-text);    color: #fff; }
.btn-secondary { background: var(--bg-elevated);     color: var(--text-secondary); border: 1px solid var(--divider); }

.btn-block { display: flex; width: 100%; }

/* ─── Utility spacing ────────────────────────────────────── */
.mt-10 { margin-top: 10px; }
.mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }

/* ─── Forms ──────────────────────────────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-group input,
.form-group select,
.form-group textarea,
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='rgba(247,247,245,0.4)' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 3px var(--brand-red-glow);
}

.form-group input::placeholder,
input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

.form-section {
  margin-bottom: 28px;
  padding-bottom: 28px;
  border-bottom: 1px solid var(--divider);
}

.form-section:last-child { border-bottom: none; }

.form-section-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 16px;
}

/* ─── Toolbar ────────────────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}

.toolbar input,
.toolbar select {
  width: auto;
  padding: 7px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
}

.toolbar select {
  padding-right: 28px;
}

.toolbar input::placeholder { color: var(--text-muted); }

/* ─── Kanban Board ───────────────────────────────────────── */
.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.board-column {
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.board-column-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  padding: 0 2px;
}

.board-card {
  background: var(--bg-elevated);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  border: 1px solid var(--divider);
}

.board-card:hover {
  background: rgba(247, 247, 245, 0.06);
  transform: translateY(-1px);
}

.board-card.overdue  { border-left: 3px solid var(--danger-text); }
.board-card.warning  { border-left: 3px solid var(--warning-text); }
.board-card.normal   { border-left: 3px solid var(--brand-red); }
.board-card.inactive { border-left: 3px solid var(--text-muted); opacity: 0.55; }

.board-card-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  color: var(--text-primary);
}

.board-card-meta {
  font-size: 12px;
  color: var(--text-secondary);
}

/* ─── Project Type Selector ──────────────────────────────── */
.type-selector {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.type-btn {
  padding: 7px 16px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s;
}

.type-btn:hover {
  border-color: rgba(201, 26, 34, 0.5);
  color: var(--text-primary);
}

.type-btn.active {
  border-color: var(--brand-red);
  background: var(--brand-red);
  color: #fff;
}

/* ─── Milestones ─────────────────────────────────────────── */
.milestone-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  margin-bottom: 8px;
  background: var(--bg-elevated);
}

.milestone-item.overdue {
  background: rgba(201, 26, 34, 0.08);
  border-color: rgba(201, 26, 34, 0.3);
}

.milestone-item.warning {
  background: rgba(245, 127, 23, 0.08);
  border-color: rgba(245, 127, 23, 0.3);
}

.milestone-date {
  font-size: 13px;
  color: var(--text-secondary);
  min-width: 84px;
}

.milestone-title { flex: 1; font-size: 14px; }
.milestone-status { font-size: 12px; }

/* ─── Alerts ─────────────────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  font-size: 14px;
}

.alert-danger {
  background: var(--danger-bg);
  border: 1px solid rgba(201, 26, 34, 0.35);
  color: var(--danger-text);
}

.alert-warning {
  background: var(--warning-bg);
  border: 1px solid rgba(245, 127, 23, 0.35);
  color: var(--warning-text);
}

.alert-success {
  background: var(--success-bg);
  border: 1px solid rgba(46, 125, 50, 0.35);
  color: var(--success-text);
}

/* ─── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: 28px;
  max-width: 620px;
  width: 90%;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 20px;
  color: var(--text-primary);
}

/* ─── Loading ────────────────────────────────────────────── */
.loading {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 14px;
}

.loading::after {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--divider);
  border-top-color: var(--brand-red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-left: 10px;
  vertical-align: middle;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Empty State ────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 64px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

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

/* ─── Search Box ─────────────────────────────────────────── */
.search-box {
  position: relative;
  margin-bottom: 20px;
}

.search-box input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  background: var(--bg-elevated);
  border: 1px solid var(--divider);
  border-radius: var(--radius-md);
  font-size: 14px;
  color: var(--text-primary);
}

.search-box::before {
  content: "🔍";
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 13px;
  pointer-events: none;
}

/* ─── Login Page ─────────────────────────────────────────── */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
}

.login-box {
  background: var(--bg-surface);
  border: 1px solid var(--divider);
  padding: 40px;
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
  width: 100%;
  max-width: 400px;
  position: relative;
  overflow: hidden;
}

/* 登录框顶部朱砂红装饰线 */
.login-box::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--brand-red);
}

.login-box h1 {
  text-align: center;
  margin-bottom: 32px;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ─── Contact Links ──────────────────────────────────────── */
.contact-link {
  color: var(--text-primary);
  border-bottom: 1px solid var(--divider);
  transition: color 0.15s, border-color 0.15s;
}
.contact-link:hover {
  color: var(--brand-red);
  border-bottom-color: var(--brand-red);
  text-decoration: none;
}

/* alert-warning used standalone (without .alert parent) */
.alert.alert-warning,
div.alert-warning {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  background: var(--warning-bg);
  border: 1px solid rgba(245, 127, 23, 0.35);
  color: var(--warning-text);
}

/* ─── Dashboard ──────────────────────────────────────────── */
.stat-number-link {
  display: block;
  font-size: 34px;
  font-weight: 700;
  color: var(--text-primary);
  text-decoration: none;
  cursor: pointer;
  padding: 6px 0;
  line-height: 1.2;
  transition: opacity 0.15s;
}
.stat-number-link:hover { opacity: 0.8; text-decoration: none; }
.stat-number-link.warning { color: var(--warning-text); }
.stat-number-link.danger  { color: var(--danger-text); }

.clickable-item {
  cursor: pointer;
  transition: background 0.12s;
}
.clickable-item:hover { background: var(--bg-elevated); }

.lawyer-name {
  color: var(--text-primary);
  cursor: pointer;
  font-weight: 500;
  text-decoration: none;
}
.lawyer-name:hover { color: var(--brand-red); }

/* ─── Pagination ─────────────────────────────────────────── */
.pagination-info {
  padding: 6px 0;
  color: var(--text-muted);
  font-size: 13px;
  margin-bottom: 8px;
}

/* ─── Utility Layout ─────────────────────────────────────── */
.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.flex-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.col-span-full { grid-column: 1 / -1; }

/* Row divider inside cards */
.row-divider {
  padding: 10px 0;
  border-bottom: 1px solid var(--divider);
}
.row-divider:last-child { border-bottom: none; }

/* Info item (label + value) */
.info-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 2px;
}

/* Person status indicator */
.status-dot-active { color: var(--success-text); }
.status-dot-inactive { color: var(--text-muted); }

/* Alert inside card with left accent */
.card-alert {
  padding: 12px 16px;
  background: var(--warning-bg);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--warning-text);
  margin-top: 12px;
}
.card-alert-title {
  font-weight: 600;
  color: var(--warning-text);
  margin-bottom: 6px;
  font-size: 13px;
}

/* Danger accent card */
.card-alert-danger {
  background: var(--danger-bg);
  border-left-color: var(--danger-text);
}
.card-alert-danger .card-alert-title { color: var(--danger-text); }

/* ─── Scrollbar (Webkit) ─────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(247,247,245,0.2); }

/* ─── Selection ──────────────────────────────────────────── */
::selection { background: var(--brand-red-glow); color: var(--text-primary); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    height: auto;
    padding: 10px 0;
    gap: 8px;
  }

  .main { padding: 80px 16px 32px; }

  .stats-grid    { grid-template-columns: repeat(2, 1fr); }
  .form-row      { grid-template-columns: 1fr; }
  .board         { grid-template-columns: 1fr; }
  .toolbar       { gap: 8px; }

  .nav a.active::after,
  .nav-link.active::after { bottom: -6px; }
}
