/* ============================================
   Baladi Requests — Premium Design System
   ============================================ */

/* ===== Design Tokens ===== */
:root {
  --surface: #E7E5E4;
  --text-color: #1E2938;
  --text-muted: #64748b;
  --primary: #006666;
  --success: #00A63D;
  --warning: #FE9900;
  --danger: #FF2157;
  --border-color: #d1d0ce;

  --shadow-flat: 6px 6px 14px #cccacd, -6px -6px 14px #ffffff;
  --shadow-flat-hover: 8px 8px 18px #c5c3c6, -8px -8px 18px #ffffff;
  --shadow-pressed: inset 4px 4px 8px #cccacd, inset -4px -4px 8px #ffffff;
  --shadow-sm: 4px 4px 10px #d0cecd, -4px -4px 10px #ffffff;

  --radius: 16px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --sidebar-width: 280px;
  --sidebar-collapsed-width: 70px;
  --topbar-height: 64px;
  --transition: .25s ease;
  --transition-bounce: .3s cubic-bezier(.34, 1.56, .64, 1);
}

[data-theme="dark"] {
  --surface: #1E2938;
  --text-color: #F1F2F5;
  --text-muted: #94a3b8;
  --primary: #00A8A8;
  --border-color: #1a2330;
  --shadow-flat: 6px 6px 14px #18212d, -6px -6px 14px #243143;
  --shadow-flat-hover: 8px 8px 18px #151d27, -8px -8px 18px #273549;
  --shadow-pressed: inset 4px 4px 8px #151d27, inset -4px -4px 8px #273549;
  --shadow-sm: 4px 4px 10px #18212d, -4px -4px 10px #243143;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: "Cairo", "IBM Plex Sans Arabic", sans-serif;
  background: var(--surface);
  color: var(--text-color);
  line-height: 1.6;
  min-height: 100vh;
}

/* ===== Layout ===== */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

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

.main-content.sidebar-collapsed {
  margin-right: var(--sidebar-collapsed-width);
}

.page-content {
  flex: 1;
  padding: 28px;
  margin-top: var(--topbar-height);
}

/* ===== Page Header & Cards ===== */
.page-header {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 28px;
  box-shadow: var(--shadow-flat);
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  border: 1px solid var(--border-color);
}

.page-header-title {
  font-size: 24px;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: inherit;
}

.page-header-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 2px;
}

.page-header-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
  justify-content: flex-end;
  width: 100%;
}

/* ===== Stats Cards ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-flat);
  display: flex;
  align-items: center;
  gap: 14px;
  transition: var(--transition-bounce);
  cursor: pointer;
  border: 1px solid transparent;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-flat-hover);
}

.stat-card.active {
  box-shadow: var(--shadow-pressed);
  border: 1px solid var(--border-color);
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
  background: var(--surface);
  box-shadow: var(--shadow-pressed);
  color: var(--primary);
}

.stat-card.new .stat-icon {
  color: var(--secondary);
}

.stat-card.contacting .stat-icon {
  color: var(--primary);
}

.stat-card.approved .stat-icon {
  color: var(--success);
}

.stat-card.waiting .stat-icon {
  color: var(--warning);
}

.stat-card.finance .stat-icon {
  color: #8b5cf6;
}

.stat-card.ready .stat-icon {
  color: #ec4899;
}

.stat-card.converted .stat-icon {
  color: var(--success);
}

.stat-card.expiring .stat-icon {
  color: var(--danger);
  box-shadow: inset 4px 4px 8px #ffcfd8, inset -4px -4px 8px #ffffff;
}

.stat-info {
  flex: 1;
}

.stat-label {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 700;
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--primary);
  font-family: 'JetBrains Mono', 'Space Mono', monospace;
  line-height: 1.1;
}

/* ===== Search Section ===== */
.search-section {
  background: var(--card-bg);
  padding: 18px 22px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: center;
  border: 1px solid var(--border-color);
}

.search-input {
  flex: 1;
  min-width: 250px;
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-color);
  font-family: 'Space Mono', 'Cairo', sans-serif;
  font-size: 14px;
  box-shadow: var(--shadow-pressed);
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-select {
  padding: 12px 18px;
  background: var(--surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-color);
  box-shadow: var(--shadow-pressed);
  min-width: 160px;
  transition: var(--transition);
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

.results-badge {
  padding: 8px 18px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 24px;
  font-weight: 700;
  font-size: 13px;
}

/* ===== Buttons ===== */
/* ===== Neumorphic Buttons ===== */
.btn {
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--text-color);
  font-family: 'Space Mono', 'Cairo', sans-serif;
  font-weight: 700;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: var(--shadow-flat);
  transition: var(--transition);
  cursor: pointer;
}

.btn:hover:not(:disabled) {
  box-shadow: var(--shadow-flat-hover);
  transform: translateY(-2px);
}

.btn:active:not(:disabled) {
  box-shadow: var(--shadow-pressed);
  transform: translateY(0) scale(0.98);
}

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

.btn-success {
  color: var(--success);
}

.btn-warning {
  color: var(--warning);
}

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

.btn-secondary {
  color: var(--text-color);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

/* Styles for active tabs to look pressed */
button.request-type-tab.active {
  box-shadow: var(--shadow-pressed);
  border: 1px solid var(--border-color);
  color: var(--primary);
}

/* ===== Table ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-flat);
  overflow: hidden;
  border: none;
}

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

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

th,
td {
  padding: 14px 18px;
  text-align: right;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
  font-size: 13.5px;
}

th {
  background: var(--surface);
  box-shadow: 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  font-weight: 700;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  position: sticky;
  top: 0;
  z-index: 1;
}

tr {
  transition: var(--transition);
}

tr:hover {
  background: rgba(0, 0, 0, .02);
}

tr.expiring {
  background: rgba(255, 33, 87, .06);
}

tr.urgent {
  background: rgba(254, 153, 0, .06);
}

/* ===== Status Badge ===== */
.status-badge {
  padding: 5px 14px;
  border-radius: 24px;
  font-size: 11.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.status-new {
  background: linear-gradient(135deg, #e0f2fe, #cffafe);
  color: #0369a1;
}

.status-contacting {
  background: linear-gradient(135deg, #dbeafe, #c7d2fe);
  color: #1d4ed8;
}

.status-client_approved {
  background: linear-gradient(135deg, #dcfce7, #d1fae5);
  color: #15803d;
}

.status-waiting_transfer {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
}

.status-waiting_finance {
  background: linear-gradient(135deg, #f3e8ff, #e9d5ff);
  color: #7c3aed;
}

.status-ready_for_contract {
  background: linear-gradient(135deg, #fce7f3, #fbcfe8);
  color: #be185d;
}

.status-converted {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #047857;
}

.status-rejected {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #dc2626;
}

.status-expired {
  background: linear-gradient(135deg, #f1f5f9, #e2e8f0);
  color: #64748b;
}

/* ===== Days Badge ===== */
.days-badge {
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
}

.days-ok {
  background: #dcfce7;
  color: #15803d;
}

.days-warning {
  background: #fef3c7;
  color: #92400e;
}

.days-critical {
  background: #fee2e2;
  color: #dc2626;
  animation: pulse-danger 2s infinite;
}

.days-expired {
  background: #374151;
  color: white;
}

@keyframes pulse-danger {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .7;
  }
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, .6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: var(--transition);
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--surface);
  border-radius: 20px;
  width: 95%;
  max-width: 800px;
  max-height: 92vh;
  overflow: hidden;
  transform: scale(.92) translateY(20px);
  transition: transform .35s cubic-bezier(.34, 1.56, .64, 1);
  box-shadow: var(--shadow-sm);
  /* Using smaller shadow so it doesn't look weird on dark overlay, but wait flat is better! */
  border: none;
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
  box-shadow: var(--shadow-flat-hover);
}

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

.modal-header h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--dark-color);
  display: flex;
  align-items: center;
  gap: 10px;
}

.modal-close {
  background: none;
  border: none;
  font-size: 28px;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  transition: var(--transition);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, .08);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  max-height: calc(92vh - 140px);
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: var(--surface);
}

/* ===== Form ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-group label {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-color);
  font-family: 'Space Mono', 'Cairo', sans-serif;
}

.form-group label .required {
  color: var(--danger);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 14px;
  transition: var(--transition);
  background: var(--surface);
  color: var(--text-color);
  box-shadow: var(--shadow-pressed);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border: 1px solid var(--primary);
}

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

.form-section {
  margin-bottom: 28px;
}

.form-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ===== Detail View ===== */
.detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

.detail-section {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  box-shadow: var(--shadow-pressed);
}

.detail-section-title {
  font-weight: 800;
  color: var(--text-color);
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-family: 'Space Mono', 'Cairo', sans-serif;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px dotted var(--border-color);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-label {
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
}

.detail-value {
  color: var(--primary);
  font-weight: 700;
}

/* ===== Timeline ===== */
.timeline {
  position: relative;
  padding-right: 24px;
}

.timeline::before {
  content: '';
  position: absolute;
  right: 7px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border-color);
}

.timeline-item {
  position: relative;
  padding: 0 30px 20px 0;
}

.timeline-item::before {
  content: '';
  position: absolute;
  right: 0;
  top: 6px;
  width: 16px;
  height: 16px;
  background: var(--surface);
  border-radius: 50%;
  border: 3px solid var(--primary);
}

.timeline-item.success::before {
  border-color: var(--success);
}

.timeline-item.warning::before {
  border-color: var(--warning);
}

.timeline-item.danger::before {
  border-color: var(--danger);
}

.timeline-content {
  background: var(--surface);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-flat);
  border: none;
}

.timeline-title {
  font-weight: 800;
  color: var(--text-color);
  font-size: 13px;
  font-family: 'Space Mono', 'Cairo', sans-serif;
}

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

.timeline-time {
  color: var(--text-light);
  font-size: 11px;
  margin-top: 8px;
}

/* ===== Empty & Loading ===== */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

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

.action-btns {
  display: flex;
  gap: 6px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  flex-direction: column;
  gap: 16px;
}

.loading-overlay.hidden {
  display: none;
}

.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid var(--border-color);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}

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

/* ===== Detail Modal ===== */
.detail-modal {
  max-width: 1250px;
  border-radius: 24px;
}

.detail-modal-header {
  background: var(--surface);
  padding: 14px 28px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  z-index: 2;
}

.detail-header-right {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
  z-index: 1;
}

.detail-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
  position: relative;
  z-index: 1;
}

.detail-header-title {
  color: var(--text-color);
  margin: 0;
  font-size: 19px;
  font-weight: 800;
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Space Mono', 'Cairo', sans-serif;
}

.detail-modal-header .modal-close {
  color: #94a3b8;
}

.detail-modal-header .modal-close:hover {
  color: #f1f5f9;
  background: rgba(255, 255, 255, .1);
}

.detail-info-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border-bottom: 1px solid var(--border-color);
}

.detail-info-cell {
  background: var(--surface);
  padding: 10px 20px;
  text-align: center;
  position: relative;
  transition: var(--transition);
}

.detail-info-cell:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 0;
  top: 20%;
  bottom: 20%;
  width: 1px;
  background: var(--border-color);
}

.detail-info-cell:hover {
  box-shadow: var(--shadow-pressed);
}

.detail-info-label {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.detail-info-value {
  font-weight: 800;
  color: var(--text-color);
  font-size: 14px;
  font-family: 'JetBrains Mono', 'Space Mono', sans-serif;
}

.detail-info-value.accent {
  color: var(--primary);
  font-size: 16px;
}

.detail-info-value.money {
  color: var(--success);
  font-size: 16px;
}

.detail-body-grid {
  padding: 24px 28px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 28px;
}

.detail-body-col {
  display: flex;
  flex-direction: column;
}

.detail-client-card {
  border: none;
  border-radius: 16px;
  padding: 22px;
  background: var(--surface);
  transition: var(--transition);
  box-shadow: var(--shadow-flat);
}

.detail-client-card:hover {
  box-shadow: var(--shadow-flat-hover);
}

.detail-client-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border-color);
}

.detail-client-header .detail-section-title {
  margin: 0;
}

.detail-edit-hint {
  font-size: 11px;
  background: var(--surface);
  box-shadow: var(--shadow-pressed);
  color: var(--warning);
  padding: 4px 12px;
  border-radius: 8px;
  display: none;
  font-weight: 700;
}

.detail-section-box {
  border: none;
  border-radius: 16px;
  padding: 18px;
  background: var(--surface);
  transition: var(--transition);
  box-shadow: var(--shadow-flat);
}

.detail-section-box:hover {
  box-shadow: var(--shadow-flat-hover);
}

.detail-notes-text {
  color: var(--text-muted);
  font-size: 13px;
  min-height: 40px;
  line-height: 1.8;
  font-weight: 600;
}

.detail-modal-footer {
  border-top: 1px solid var(--border-color);
  padding: 20px 28px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  background: var(--surface);
  min-height: 80px;
}

/* ===== Detail Tabs ===== */
.detail-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
}

.detail-tab {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 12px;
  background: var(--surface);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  font-family: 'Space Mono', 'Cairo', sans-serif;
  transition: var(--transition);
  box-shadow: var(--shadow-flat);
}

.detail-tab:hover {
  box-shadow: var(--shadow-flat-hover);
  color: var(--text-color);
}

.detail-tab.active-chat,
.detail-tab.active-actions {
  box-shadow: var(--shadow-pressed);
  color: var(--primary);
}

/* ===== Chat Panel ===== */
.chat-panel {
  border: none;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-flat);
  background: var(--surface);
}

.chat-messages {
  height: 340px;
  overflow-y: auto;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-pressed);
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px;
  border-radius: 12px;
}

.chat-empty {
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 40px 20px;
  font-weight: 700;
}

.chat-input-bar {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  align-items: center;
}

.chat-attach-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-flat);
  border: none;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: var(--transition);
}

.chat-attach-btn:hover {
  box-shadow: var(--shadow-flat-hover);
  color: var(--primary);
}

.chat-attach-btn:active {
  box-shadow: var(--shadow-pressed);
}

.chat-text-input {
  flex: 1;
  padding: 11px 16px;
  border: none;
  border-radius: 22px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  background: var(--surface);
  color: var(--text-color);
  box-shadow: var(--shadow-pressed);
}

.chat-send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--success);
  border: none;
  cursor: pointer;
  font-size: 20px;
  box-shadow: var(--shadow-flat);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.chat-send-btn:hover {
  box-shadow: var(--shadow-flat-hover);
}

.chat-send-btn:active {
  box-shadow: var(--shadow-pressed);
}

.actions-panel {
  display: none;
  border: none;
  border-radius: 14px;
  padding: 18px;
  background: var(--surface);
  box-shadow: var(--shadow-flat);
}

/* ===== Pagination ===== */
.pagination-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 22px;
  border-top: 1px solid var(--border-color);
  background: var(--card-bg);
  flex-wrap: wrap;
  gap: 12px;
}

.pagination-info {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

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

.pagination-btn {
  padding: 7px 14px;
  border: 1.5px solid var(--border-color);
  border-radius: var(--radius-xs);
  background: var(--card-bg);
  color: var(--text-color);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: var(--transition);
  font-weight: 500;
}

.pagination-btn:hover:not(.active):not(.disabled) {
  background: var(--primary-soft);
  border-color: var(--primary);
  color: var(--primary);
}

.pagination-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--purple));
  color: white;
  border-color: transparent;
  box-shadow: 0 2px 8px var(--primary-glow);
}

.pagination-btn.disabled {
  opacity: .35;
  cursor: default;
}

.pagination-dots {
  padding: 0 6px;
  color: var(--text-light);
  font-size: 13px;
}

/* ===== Dark Mode ===== */
[data-theme="dark"] .page-header {
  background: var(--card-bg);
  border-color: var(--border-color);
}

[data-theme="dark"] .page-header::before {
  background: linear-gradient(135deg, rgba(99, 102, 241, .08), transparent);
}

[data-theme="dark"] .stat-card {
  background: var(--card-bg);
  border-color: var(--border-color);
}

[data-theme="dark"] .stat-card.expiring {
  background: linear-gradient(135deg, var(--card-bg), rgba(239, 68, 68, .08));
}

[data-theme="dark"] .search-section {
  background: var(--card-bg);
  border-color: var(--border-color);
}

[data-theme="dark"] .card {
  background: var(--card-bg);
  border-color: var(--border-color);
}

[data-theme="dark"] th {
  background: linear-gradient(135deg, #1e293b, #1a2332);
  color: var(--text-muted);
}

[data-theme="dark"] tr:hover {
  background: rgba(99, 102, 241, .06);
}

[data-theme="dark"] .modal {
  background: var(--card-bg);
  border-color: var(--border-color);
}

[data-theme="dark"] .modal-header {
  background: linear-gradient(135deg, #1e293b, #0f172a);
}

[data-theme="dark"] .modal-footer {
  background: linear-gradient(135deg, #1e293b, #0f172a);
}

[data-theme="dark"] .detail-modal-header {
  background: linear-gradient(135deg, #0f172a, #1e293b, #334155);
}

[data-theme="dark"] .detail-info-cell {
  background: var(--card-bg);
}

[data-theme="dark"] .detail-info-cell::after {
  background: var(--border-color);
}

[data-theme="dark"] .detail-info-value.money {
  color: #34d399;
}

[data-theme="dark"] .detail-client-card {
  background: var(--card-bg);
  border-color: var(--border-color);
}

[data-theme="dark"] .detail-edit-hint {
  background: rgba(254, 243, 199, .1);
  color: #fbbf24;
}

[data-theme="dark"] .detail-section-box {
  background: var(--card-bg);
  border-color: var(--border-color);
}

[data-theme="dark"] .detail-modal-footer {
  background: linear-gradient(135deg, #1e293b, #0f172a);
}

[data-theme="dark"] .chat-messages {
  background: linear-gradient(180deg, #1a1e2e, #151926);
}

[data-theme="dark"] .chat-input-bar {
  background: #1e293b;
  border-color: #334155;
}

[data-theme="dark"] .chat-attach-btn {
  color: #94a3b8;
}

[data-theme="dark"] .chat-attach-btn:hover {
  background: rgba(255, 255, 255, .06);
}

[data-theme="dark"] .chat-panel {
  border-color: #128C7E;
}

[data-theme="dark"] .chat-text-input {
  background: #0f172a;
  color: #f1f5f9;
  box-shadow: none;
}

[data-theme="dark"] .actions-panel {
  background: var(--card-bg);
  border-color: var(--border-color);
}

[data-theme="dark"] .pagination-bar {
  background: var(--card-bg);
}

[data-theme="dark"] .pagination-btn {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .loading-overlay {
  background: rgba(15, 23, 42, .92);
}

[data-theme="dark"] .btn-secondary {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}

[data-theme="dark"] .btn-secondary:hover {
  border-color: var(--primary);
  background: var(--primary-soft);
  color: var(--primary);
}

[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea {
  background: #0f172a;
  color: #f1f5f9;
  border-color: #334155;
}

[data-theme="dark"] .search-input {
  background: var(--card-bg);
  color: var(--text-color);
}

[data-theme="dark"] .filter-select {
  background: var(--card-bg);
  color: var(--text-color);
}

/* ===== Responsive ===== */
@media (max-width: 1024px) {
  .main-content {
    margin-right: var(--sidebar-collapsed-width);
  }

  .detail-grid,
  .detail-body-grid {
    grid-template-columns: 1fr;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .main-content {
    margin-right: 0;
  }

  .page-content {
    padding: 16px;
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  th,
  td {
    padding: 10px 12px;
    font-size: 13px;
  }

  .detail-body-grid {
    grid-template-columns: 1fr;
  }

  .detail-info-bar {
    grid-template-columns: repeat(2, 1fr);
  }

  .pagination-bar {
    justify-content: center;
  }

  .stat-value {
    font-size: 22px;
  }
}

@media (max-width: 480px) {
  .stats-row {
    grid-template-columns: 1fr;
  }

  .page-header-actions {
    flex-direction: column;
  }

  .page-header-actions .btn {
    width: 100%;
  }
}

/* ===== Print ===== */
@media print {

  .sidebar,
  .topbar,
  .footer,
  .toast-container {
    display: none !important;
  }

  .main-content {
    margin: 0 !important;
  }
}

/* ===== Scrollbar ===== */
.chat-messages::-webkit-scrollbar,
.modal-body::-webkit-scrollbar,
.actions-panel::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, .15);
  border-radius: 10px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, .25);
}

/* --- ULTIMATE CLEAN OVERRIDE (LIGHT MODE) --- */
html:not([data-theme="dark"]) .detail-modal {
  background: #f8fafc !important;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.12) !important;
}

html:not([data-theme="dark"]) .detail-modal-header {
  background: #ffffff !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

html:not([data-theme="dark"]) .detail-modal-footer {
  background: #ffffff !important;
  border-top: 1px solid #e2e8f0 !important;
}

html:not([data-theme="dark"]) .detail-info-bar {
  background: #ffffff !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

html:not([data-theme="dark"]) .detail-info-cell:not(:last-child)::after {
  background: #e2e8f0 !important;
}

html:not([data-theme="dark"]) .detail-client-card,
html:not([data-theme="dark"]) .detail-section-box {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03) !important;
  border-radius: 12px !important;
}

html:not([data-theme="dark"]) .detail-client-header {
  border-bottom: 1px dashed #e2e8f0 !important;
}

html:not([data-theme="dark"]) .detail-modal .form-group input,
html:not([data-theme="dark"]) .detail-modal .form-group select,
html:not([data-theme="dark"]) .detail-modal .form-group textarea {
  box-shadow: none !important;
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 8px !important;
  font-size: 14px !important;
  color: #1e293b !important;
}

html:not([data-theme="dark"]) .detail-modal .form-group input:focus,
html:not([data-theme="dark"]) .detail-modal .form-group select:focus,
html:not([data-theme="dark"]) .detail-modal .form-group textarea:focus {
  background: #ffffff !important;
  border-color: #0ea5e9 !important;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1) !important;
}

html:not([data-theme="dark"]) .chat-panel {
  border: 1px solid #e2e8f0 !important;
  border-radius: 12px !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.03) !important;
  background: #ffffff !important;
}

html:not([data-theme="dark"]) .chat-messages {
  background: #f1f5f9 !important;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.02) !important;
  border-radius: 0 !important;
  margin: 0 !important;
}

html:not([data-theme="dark"]) .chat-input-bar {
  border-top: 1px solid #e2e8f0 !important;
  background: #ffffff !important;
}

html:not([data-theme="dark"]) .chat-attach-btn {
  box-shadow: none !important;
  background: #f1f5f9 !important;
}

html:not([data-theme="dark"]) .chat-attach-btn:hover {
  background: #e2e8f0 !important;
  color: var(--primary) !important;
}

html:not([data-theme="dark"]) .chat-text-input {
  box-shadow: none !important;
  background: #f8fafc !important;
  border: 1px solid #e2e8f0 !important;
}

html:not([data-theme="dark"]) .chat-text-input:focus {
  background: #ffffff !important;
  border-color: #0ea5e9 !important;
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1) !important;
}

html:not([data-theme="dark"]) .chat-send-btn {
  box-shadow: 0 4px 12px rgba(0, 102, 102, 0.2) !important;
}

html:not([data-theme="dark"]) .detail-tab {
  border-radius: 8px !important;
  box-shadow: none !important;
  background: transparent !important;
}

html:not([data-theme="dark"]) .detail-tab:hover {
  background: rgba(255, 255, 255, 0.5) !important;
}

html:not([data-theme="dark"]) .detail-tab.active-chat,
html:not([data-theme="dark"]) .detail-tab.active-actions {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04) !important;
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
}

html:not([data-theme="dark"]) .detail-tabs {
  background: #f1f5f9 !important;
  border: 1px solid #e2e8f0 !important;
  border-radius: 10px !important;
  box-shadow: none !important;
}

html:not([data-theme="dark"]) .detail-modal-footer .btn {
  box-shadow: none !important;
  border-radius: 8px !important;
  font-weight: 600 !important;
}

html:not([data-theme="dark"]) .detail-modal-footer .btn:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
  transform: translateY(-1px) !important;
}