/**
 * TherapyFlow — Design System (canonical palette + primitives).
 * Loaded after main.css from base.html so layout tokens and utilities apply globally.
 */

:root {
  /* Primary */
  --color-primary: #0f766e;
  --color-primary-light: #14b8a6;
  --color-primary-hover: #115e59;

  /* Background */
  --color-bg: #f8fafc;
  --color-card: #ffffff;

  /* Text */
  --color-text: #111827;
  --color-text-secondary: #6b7280;

  /* Border */
  --color-border: #e5e7eb;

  /* Status */
  --color-success: #22c55e;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
}

/* -------------------------------------------------------------------------- */
/* Buttons (baseline — main.css may add sizes / dark theme)                    */
/* -------------------------------------------------------------------------- */

.btn {
  padding: 10px 16px;
  border-radius: 10px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: 0.2s;
}

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

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

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

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

/* -------------------------------------------------------------------------- */
/* Status pills (lead list / tables)                                          */
/* -------------------------------------------------------------------------- */

.status-badge {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
}

.status-new {
  background: rgba(20, 184, 166, 0.1);
  color: #14b8a6;
}

.status-warning {
  background: rgba(245, 158, 11, 0.1);
  color: #f59e0b;
}

.status-danger {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.status-success {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
}

.status-neutral {
  background: rgba(107, 114, 128, 0.12);
  color: #6b7280;
}

/* Lead status selects: accent dot / border from semantic class */
.status-select-wrapper.status-new {
  --status-color: var(--color-primary-light);
}

.status-select-wrapper.status-warning {
  --status-color: var(--color-warning);
}

.status-select-wrapper.status-danger {
  --status-color: var(--color-danger);
}

.status-select-wrapper.status-success {
  --status-color: var(--color-success);
}

.status-select-wrapper.status-neutral {
  --status-color: #9ca3af;
}

/* -------------------------------------------------------------------------- */
/* Inputs / filters (forms; narrow types to avoid breaking checkboxes)        */
/* -------------------------------------------------------------------------- */

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]):not([type="file"]):not([type="image"]):not([type="reset"]):not([type="range"]),
select,
textarea {
  border: 1px solid var(--color-border);
  border-radius: 10px;
  padding: 10px;
  background: white;
  font-size: 14px;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]):not([type="hidden"]):not([type="file"]):not([type="image"]):not([type="reset"]):not([type="range"]):focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.2);
}

/* -------------------------------------------------------------------------- */
/* Cards                                                                      */
/* -------------------------------------------------------------------------- */

.card {
  background: var(--color-card);
  border-radius: 16px;
  border: 1px solid var(--color-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.04);
  padding: 16px;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

/* -------------------------------------------------------------------------- */
/* Hover / feedback                                                             */
/* -------------------------------------------------------------------------- */

button.btn:hover:not(:disabled) {
  opacity: 0.92;
}

/* Bulk toolbars (leads / follow-up) */
.tf-bulk-toolbar {
  background: var(--primary-light, #e6f4f3);
  border: 1px solid var(--color-border);
  border-radius: 10px;
}

.tf-bulk-toolbar .tf-bulk-toolbar-count {
  font-weight: 600;
  color: var(--color-primary);
}

/* PRO / locked nav hint (SVG next to label) */
.sidebar-pro-lock-icon {
  display: inline-flex;
  align-items: center;
  margin-inline-start: 6px;
  vertical-align: middle;
  opacity: 0.85;
}

.sidebar-pro-lock-icon svg {
  width: 14px;
  height: 14px;
  display: block;
}

.sidebar-bell .bell-icon {
  display: inline-flex;
  line-height: 0;
}

.sidebar-bell .bell-icon svg {
  width: 22px;
  height: 22px;
  display: block;
}

/* -------------------------------------------------------------------------- */
/* Dashboard KPI cards                                                        */
/* -------------------------------------------------------------------------- */

.dashboard-kpi-grid .kpi-card,
.kpi-grid.dashboard-kpi-grid .kpi-card {
  background: linear-gradient(135deg, #ffffff, #f8fafc);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  box-shadow: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.dashboard-kpi-grid .kpi-card::before,
.kpi-grid.dashboard-kpi-grid .kpi-card::before {
  display: none;
}

.dashboard-kpi-grid .kpi-card.kpi-card-clickable,
.kpi-grid.dashboard-kpi-grid .kpi-card.kpi-card-clickable {
  flex-direction: row;
  align-items: flex-start;
  gap: 14px;
}

.dashboard-kpi-grid .kpi-card-stack,
.kpi-grid.dashboard-kpi-grid .kpi-card-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.dashboard-kpi-grid .kpi-card.kpi-card-clickable:hover,
.kpi-grid.dashboard-kpi-grid .kpi-card.kpi-card-clickable:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.06);
  border-color: rgba(15, 118, 110, 0.2);
}

.dashboard-kpi-grid .kpi-card .kpi-label,
.kpi-grid.dashboard-kpi-grid .kpi-card .kpi-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 0;
  letter-spacing: 0.01em;
}

.dashboard-kpi-grid .kpi-card .kpi-value,
.kpi-grid.dashboard-kpi-grid .kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-primary);
  line-height: 1.15;
}

.dashboard-kpi-grid .kpi-icon,
.kpi-grid.dashboard-kpi-grid .kpi-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  background: rgba(20, 184, 166, 0.1);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-primary);
}

.dashboard-kpi-grid .kpi-icon svg,
.kpi-grid.dashboard-kpi-grid .kpi-icon svg {
  display: block;
}

@media (max-width: 768px) {
  /* Dashboard + any page using design-system before page-specific CSS */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin: 12px 0;
  }

  .kpi-card {
    padding: 12px;
    border-radius: 12px;
  }

  .kpi-label {
    font-size: 11px;
  }

  .kpi-value {
    font-size: 18px;
  }

  .dashboard-kpi-grid .kpi-card,
  .kpi-grid.dashboard-kpi-grid .kpi-card {
    padding: 12px;
    border-radius: 12px;
  }

  .dashboard-kpi-grid .kpi-card .kpi-label,
  .kpi-grid.dashboard-kpi-grid .kpi-card .kpi-label {
    font-size: 11px;
  }

  .dashboard-kpi-grid .kpi-card .kpi-value,
  .kpi-grid.dashboard-kpi-grid .kpi-card .kpi-value {
    font-size: 18px;
  }

  .dashboard-kpi-grid .kpi-icon,
  .kpi-grid.dashboard-kpi-grid .kpi-icon {
    width: 30px;
    height: 30px;
  }
}

/* -------------------------------------------------------------------------- */
/* Drawers (tf-modal + overlay — RTL left panel)                               */
/* -------------------------------------------------------------------------- */

.tf-modal-overlay.tf-drawer,
.tf-drawer-overlay {
  background: rgba(0, 0, 0, 0.3);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  z-index: 9998;
}

.tf-modal-overlay.tf-drawer .tf-modal {
  width: 420px;
  max-width: 95vw;
  height: 100%;
  background: var(--color-card, #fff);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.15);
  border-radius: 0;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
}

.tf-modal-overlay.tf-drawer.active .tf-modal,
.tf-modal-overlay.tf-drawer.open .tf-modal,
.tf-modal-overlay.tf-drawer.is-open .tf-modal {
  transform: translateX(0);
}

html[dir="ltr"] .tf-modal-overlay.tf-drawer {
  justify-content: flex-end !important;
}

html[dir="ltr"] .tf-modal-overlay.tf-drawer .tf-modal {
  margin-left: auto !important;
  margin-right: 0 !important;
  transform: translateX(100%);
}

html[dir="ltr"] .tf-modal-overlay.tf-drawer.active .tf-modal,
html[dir="ltr"] .tf-modal-overlay.tf-drawer.open .tf-modal,
html[dir="ltr"] .tf-modal-overlay.tf-drawer.is-open .tf-modal {
  transform: translateX(0);
}

.drawer-actions,
.tf-drawer .drawer-footer,
.tf-drawer .tf-drawer-footer,
.tf-drawer-footer {
  position: sticky;
  bottom: 0;
  background: var(--color-card, #fff);
  padding: 16px;
  border-top: 1px solid var(--color-border);
  z-index: 6;
}

/* -------------------------------------------------------------------------- */
/* Motion & micro-interactions                                                 */
/* -------------------------------------------------------------------------- */

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in {
  animation: fadeIn 0.3s ease both;
}

button:active:not(:disabled):not(.icon-btn) {
  transform: scale(0.97);
}

.switch {
  transition: 0.25s ease;
}

/* -------------------------------------------------------------------------- */
/* Empty states                                                               */
/* -------------------------------------------------------------------------- */

.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--color-text-secondary);
  font-size: 15px;
  line-height: 1.5;
}

td.empty-state {
  display: table-cell;
  padding: 40px 24px;
}

/* -------------------------------------------------------------------------- */
/* Tables                                                                     */
/* -------------------------------------------------------------------------- */

table tbody tr {
  transition: background-color 0.15s ease;
}

table tbody tr:hover {
  background-color: #f9fafb;
}

[data-theme="dark"] table tbody tr:hover {
  background-color: rgba(255, 255, 255, 0.04);
}

/* -------------------------------------------------------------------------- */
/* Layout rhythm                                                              */
/* -------------------------------------------------------------------------- */

.section {
  margin-bottom: 24px;
}

.block {
  margin-bottom: 16px;
}

/* -------------------------------------------------------------------------- */
/* GLOBAL CARD SYSTEM – Level 2 (card-item / follow-up / client shells)       */
/* -------------------------------------------------------------------------- */

.card-item,
.followup-card,
.client-card {
  background: var(--color-card, #ffffff);
  border: 1px solid var(--color-border, #e5e7eb);
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  padding: 0;
}

/* Premium accent — single bar (elements use .card-item + .followup-card together) */
.card-item::before {
  content: "";
  display: block;
  height: 3px;
  width: 100%;
  background: linear-gradient(
    90deg,
    var(--color-primary-light, #14b8a6),
    var(--color-primary, #0f766e)
  );
}

.card-header,
.followup-card .card-header,
.client-card .card-header {
  background: #ffffff !important;
  border-bottom: 1px solid #f1f5f9;
  padding: 16px;
  margin-bottom: 0;
}

/* Remove heavy teal strip inside headers (mobile + desktop) */
.card-item .mobile-card-header,
.followup-card .mobile-card-header,
.client-card .mobile-card-header {
  background: #ffffff !important;
  color: var(--color-text, #111827) !important;
  border: 1px solid #f1f5f9;
  border-radius: 10px;
  padding: 12px 14px;
  margin: 0;
  box-shadow: none;
}

.card-item .mobile-card-header .card-title,
.followup-card .mobile-card-header .card-title,
.client-card .mobile-card-header .card-title {
  color: var(--color-text, #111827) !important;
}

.card-item .mobile-card-header .card-title a,
.followup-card .mobile-card-header .card-title a,
.client-card .mobile-card-header .card-title a {
  color: var(--color-primary, #0f766e) !important;
}

.card-item .mobile-card-header .card-title a:hover,
.followup-card .mobile-card-header .card-title a:hover,
.client-card .mobile-card-header .card-title a:hover {
  text-decoration: underline;
}

.card-item .mobile-card-header *,
.followup-card .mobile-card-header *,
.client-card .mobile-card-header * {
  color: inherit !important;
}

/* Titles: primary link stays brand; base title uses main text */
.card-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--color-text, #111827);
}

.card-row,
.card-value {
  color: var(--color-text-secondary, #6b7280);
  font-size: 13px;
}

.card-item > .card-body,
.followup-card > .card-body,
.client-card > .card-body {
  padding: 0 16px 16px;
}

.card-item > .card-actions,
.followup-card > .card-actions,
.client-card > .card-actions {
  padding: 12px 16px 16px;
  margin-top: 0;
  border-top: 1px solid var(--color-border, #e5e7eb);
}

/* Plain card-item without header/body structure (edge cases) */
.card-item:not(:has(> .card-header)):not(:has(> .card-body)) {
  padding: 16px;
}

.status-select-wrapper {
  background: #f9fafb;
  border-radius: 8px;
  padding: 4px 8px;
}

[data-theme="dark"] .card-item,
[data-theme="dark"] .followup-card,
[data-theme="dark"] .client-card {
  background: var(--bg-card);
  border-color: var(--border-color);
  box-shadow: var(--shadow-sm, 0 2px 8px rgba(0, 0, 0, 0.2));
}

[data-theme="dark"] .card-header,
[data-theme="dark"] .followup-card .card-header,
[data-theme="dark"] .client-card .card-header {
  background: var(--bg-card) !important;
  border-bottom-color: var(--border-color);
}

[data-theme="dark"] .card-item .mobile-card-header,
[data-theme="dark"] .followup-card .mobile-card-header,
[data-theme="dark"] .client-card .mobile-card-header {
  background: var(--bg-card) !important;
  border-color: var(--border-color);
  color: var(--text-primary) !important;
}

[data-theme="dark"] .status-select-wrapper {
  background: rgba(255, 255, 255, 0.06);
}
