/* ============================================================
   DESIGN TOKENS — Clínica Fisio (Soft UI Evolution)
   ============================================================ */
:root {
  /* Brand */
  --indigo:        #6366F1;
  --indigo-dark:   #4F46E5;
  --indigo-light:  #818CF8;
  --indigo-dim:    #EEF2FF;
  --indigo-mid:    #E0E7FF;
  --cyan:          #0EA5E9;
  --cyan-dark:     #0284C7;
  --cyan-dim:      #E0F2FE;

  /* Surfaces */
  --bg:            #F1F5F9;
  --surface:       #FFFFFF;
  --surface-2:     #F8FAFC;
  --surface-3:     #F1F5F9;
  --border:        #E2E8F0;
  --border-subtle: #F1F5F9;

  /* Text */
  --text:          #0F172A;
  --text-muted:    #64748B;
  --text-placeholder: #94A3B8;

  /* Status */
  --success:       #10B981;
  --success-dim:   #D1FAE5;
  --warning:       #F59E0B;
  --warning-dim:   #FEF3C7;
  --danger:        #EF4444;
  --danger-dim:    #FEE2E2;
  --info:          #3B82F6;
  --info-dim:      #DBEAFE;

  /* Sidebar dark navy */
  --sidebar-bg:    #0B1437;
  --sidebar-width: 240px;

  /* Layout */
  --navbar-h:      58px;
  --pad:           28px;
  --pad-sm:        16px;

  /* Typography */
  --font-fallback:  system-ui, -apple-system, sans-serif;
  --font:           'Plus Jakarta Sans', var(--font-fallback);
  --font-primary:   'Plus Jakarta Sans', var(--font-fallback);
  --font-secondary: 'Plus Jakarta Sans', var(--font-fallback);
  --font-heading:   'Plus Jakarta Sans', var(--font-fallback);

  /* Shadows — soft UI */
  --shadow-xs:  0 1px 2px rgba(15,23,42,.04);
  --shadow-sm:  0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md:  0 4px 16px rgba(15,23,42,.08), 0 2px 4px rgba(15,23,42,.04);
  --shadow-lg:  0 12px 32px rgba(15,23,42,.10), 0 4px 8px rgba(15,23,42,.05);
  --shadow-colored: 0 4px 14px rgba(99,102,241,.25);
  --shadow-focus: 0 0 0 3px rgba(99,102,241,.2);

  /* Radius */
  --r-xs:   4px;
  --r-sm:   8px;
  --r-md:   12px;
  --r-lg:   16px;
  --r-xl:   24px;
  --r-full: 9999px;

  /* Transitions */
  --t:      .15s ease;
  --t-fast: .08s ease;

  /* Compat aliases — templates antigos usam --purple e --teal */
  --purple:       var(--indigo);
  --purple-dark:  var(--indigo-dark);
  --purple-light: var(--indigo-light);
  --purple-dim:   var(--indigo-dim);
  --teal:         var(--cyan);
  --teal-dark:    var(--cyan-dark);
  --teal-dim:     var(--cyan-dim);
}

/* Dark theme */
@media (prefers-color-scheme: dark) {
  :root {
    --bg:            #0B0F1A;
    --surface:       #111827;
    --surface-2:     #1A2234;
    --surface-3:     #1E293B;
    --border:        #1E293B;
    --border-subtle: #162032;
    --text:          #F8FAFC;
    --text-muted:    #94A3B8;
    --text-placeholder: #475569;
    --indigo-dim:    #1E1B4B;
    --indigo-mid:    #312E81;
    --cyan-dim:      #0C2333;
    --success-dim:   #064E3B;
    --warning-dim:   #1C1408;
    --danger-dim:    #2D0D0D;
    --info-dim:      #1E3A5F;
    --shadow-sm:  0 1px 3px rgba(0,0,0,.4);
    --shadow-md:  0 4px 16px rgba(0,0,0,.5);
    --shadow-lg:  0 12px 32px rgba(0,0,0,.6);
  }
}
:root[data-theme="dark"] {
  --bg:            #0B0F1A;
  --surface:       #111827;
  --surface-2:     #1A2234;
  --surface-3:     #1E293B;
  --border:        #1E293B;
  --border-subtle: #162032;
  --text:          #F8FAFC;
  --text-muted:    #94A3B8;
  --text-placeholder: #475569;
  --indigo-dim:    #1E1B4B;
  --indigo-mid:    #312E81;
  --cyan-dim:      #0C2333;
  --success-dim:   #064E3B;
  --warning-dim:   #1C1408;
  --danger-dim:    #2D0D0D;
  --info-dim:      #1E3A5F;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,.5);
  --shadow-lg:  0 12px 32px rgba(0,0,0,.6);
}
:root[data-theme="light"] {
  --bg:            #F1F5F9;
  --surface:       #FFFFFF;
  --surface-2:     #F8FAFC;
  --surface-3:     #F1F5F9;
  --border:        #E2E8F0;
  --border-subtle: #F1F5F9;
  --text:          #0F172A;
  --text-muted:    #64748B;
  --text-placeholder: #94A3B8;
  --indigo-dim:    #EEF2FF;
  --indigo-mid:    #E0E7FF;
}


/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a { color: var(--indigo); text-decoration: none; transition: color var(--t); }
a:hover { color: var(--indigo-dark); }

img { max-width: 100%; display: block; }

:focus-visible {
  outline: 2px solid var(--indigo);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
  }
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: var(--r-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-placeholder); }

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  color: var(--text);
  line-height: 1.2;
  text-wrap: balance;
  letter-spacing: -.02em;
}
h1 { font-size: 1.5rem;   font-weight: 800; }
h2 { font-size: 1.25rem;  font-weight: 700; }
h3 { font-size: 1.0625rem; font-weight: 700; }
h4 { font-size: .9375rem; font-weight: 600; }

.text-muted        { color: var(--text-muted) !important; }
.text-xs           { font-size: .75rem; }
.text-sm           { font-size: .8125rem; }
.text-base         { font-size: .9375rem; }
.text-lg           { font-size: 1.0625rem; }

.label-upper {
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
}

/* ============================================================
   LAYOUT SHELL
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100dvh;
}

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

.page-content {
  flex: 1;
  padding: var(--pad);
}

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.page-header-left h1 {
  font-size: 1.375rem;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1.15;
}
.page-header-left p {
  font-size: .8125rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-weight: 400;
}

/* Breadcrumb */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  flex-wrap: wrap;
  font-weight: 500;
}
.breadcrumb a { color: var(--text-muted); }
.breadcrumb a:hover { color: var(--indigo); }
.breadcrumb-sep { opacity: .3; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.card-body { padding: 22px 24px; }

.card-header {
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.card-header h3,
.card-header h4 { margin: 0; font-size: .9375rem; letter-spacing: -.01em; }

.card-footer {
  padding: 13px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0 0 var(--r-lg) var(--r-lg);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--r-full);
  font-size: .875rem;
  font-weight: 600;
  font-family: var(--font);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--t);
  white-space: nowrap;
  text-decoration: none;
  line-height: 1.3;
  letter-spacing: -.01em;
}
.btn:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }

.btn-primary {
  background: var(--indigo);
  color: #fff;
  border-color: var(--indigo);
  box-shadow: var(--shadow-colored);
}
.btn-primary:hover {
  background: var(--indigo-dark);
  border-color: var(--indigo-dark);
  color: #fff;
  box-shadow: 0 6px 20px rgba(99,102,241,.35);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0); box-shadow: var(--shadow-colored); }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover {
  border-color: var(--indigo-light);
  color: var(--indigo);
  background: var(--indigo-dim);
  transform: translateY(-1px);
}

.btn-purple, .btn-indigo {
  background: var(--indigo);
  color: #fff;
  border-color: var(--indigo);
  box-shadow: var(--shadow-colored);
}
.btn-purple:hover, .btn-indigo:hover {
  background: var(--indigo-dark);
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99,102,241,.35);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: 0 2px 8px rgba(239,68,68,.2);
}
.btn-danger:hover { filter: brightness(.92); transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-3); color: var(--text); }

.btn-sm  { padding: 5px 13px; font-size: .8125rem; border-radius: var(--r-full); gap: 5px; }
.btn-lg  { padding: 11px 26px; font-size: .9375rem; border-radius: var(--r-full); }
.btn-icon {
  padding: 7px;
  border-radius: var(--r-md);
  width: 34px;
  height: 34px;
  justify-content: center;
  border-radius: var(--r-md);
}

/* ============================================================
   FORMS
   ============================================================ */
.form-label {
  display: block;
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  letter-spacing: -.01em;
}
.form-control,
.form-select {
  width: 100%;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
  color: var(--text);
  font-size: .9375rem;
  font-family: var(--font);
  transition: border-color var(--t), box-shadow var(--t);
  outline: none;
  line-height: 1.5;
}
.form-control::placeholder { color: var(--text-placeholder); }
.form-control:focus,
.form-select:focus {
  border-color: var(--indigo);
  box-shadow: var(--shadow-focus);
}
.form-control.is-invalid,
.form-select.is-invalid { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.15); }
.invalid-feedback { font-size: .8rem; color: var(--danger); margin-top: 4px; }
.form-group { margin-bottom: 18px; }
.form-hint { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: var(--r-full);
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .01em;
  line-height: 1.4;
}
.badge-success  { background: var(--success-dim);  color: #059669; }
.badge-warning  { background: var(--warning-dim);  color: #B45309; }
.badge-danger   { background: var(--danger-dim);   color: #DC2626; }
.badge-info     { background: var(--info-dim);     color: #2563EB; }
.badge-purple   { background: var(--indigo-dim);   color: var(--indigo-dark); }
.badge-teal     { background: var(--cyan-dim);     color: var(--cyan-dark); }
.badge-secondary{ background: var(--surface-3);    color: var(--text-muted); }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
  border-radius: var(--r-full);
  object-fit: cover;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: var(--font-heading);
}
.avatar-placeholder {
  border-radius: var(--r-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: var(--font-heading);
  flex-shrink: 0;
  background: var(--indigo-dim);
  color: var(--indigo);
}
.avatar-xs, .avatar-placeholder.av-xs { width: 28px; height: 28px; font-size: .7rem; }
.avatar-sm, .avatar-placeholder.av-sm { width: 36px; height: 36px; font-size: .8rem; }
.avatar-md, .avatar-placeholder.av-md { width: 44px; height: 44px; font-size: .9rem; }
.avatar-lg, .avatar-placeholder.av-lg { width: 56px; height: 56px; font-size: 1.1rem; }

/* ============================================================
   TABLES
   ============================================================ */
.table-responsive { overflow-x: auto; border-radius: var(--r-lg); }
.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  font-size: .875rem;
}
.data-table thead th {
  padding: 11px 16px;
  text-align: left;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--text-muted);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  user-select: none;
}
.data-table tbody td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background var(--t-fast); }
.data-table tbody tr:hover td { background: #FAFBFF; }
.data-table .col-actions { text-align: right; width: 1%; white-space: nowrap; }

/* ============================================================
   TABS
   ============================================================ */
.tabs-wrap {
  display: flex;
  border-bottom: 1px solid var(--border);
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs-wrap::-webkit-scrollbar { display: none; }

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 10px 18px;
  font-size: .875rem;
  font-weight: 500;
  font-family: var(--font);
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--t), border-color var(--t);
  margin-bottom: -1px;
  white-space: nowrap;
  letter-spacing: -.01em;
}
.tab-btn:hover { color: var(--text); }
.tab-btn.active {
  color: var(--indigo);
  border-bottom-color: var(--indigo);
  font-weight: 700;
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 12px 16px;
  border-radius: var(--r-md);
  font-size: .875rem;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-dim); color: #065F46; border-color: rgba(16,185,129,.2); }
.alert-warning { background: var(--warning-dim); color: #92400E; border-color: rgba(245,158,11,.2); }
.alert-danger  { background: var(--danger-dim);  color: #991B1B; border-color: rgba(239,68,68,.2); }
.alert-info    { background: var(--info-dim);    color: #1E40AF; border-color: rgba(59,130,246,.2); }

/* ============================================================
   DIVIDER
   ============================================================ */
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ============================================================
   UTILITIES
   ============================================================ */
.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.items-center    { align-items: center; }
.items-start     { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-end     { justify-content: flex-end; }
.gap-1  { gap: 4px; }  .gap-2  { gap: 8px; }   .gap-3  { gap: 12px; }
.gap-4  { gap: 16px; } .gap-5  { gap: 20px; }  .gap-6  { gap: 24px; }
.flex-1  { flex: 1; }  .w-full  { width: 100%; } .min-w-0 { min-width: 0; }
.flex-wrap { flex-wrap: wrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-num { font-variant-numeric: tabular-nums; }
.mt-1 { margin-top: 4px; }   .mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }  .mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }  .mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; } .mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; } .mb-6 { margin-bottom: 24px; }

/* ============================================================
   SKELETON
   ============================================================ */
.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: skeleton-sweep 1.5s infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton-sweep {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.sk-text   { height: 13px; border-radius: var(--r-sm); }
.sk-circle { border-radius: var(--r-full); }
.sk-card   { height: 76px; border-radius: var(--r-lg); }

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text-muted);
}
.empty-state i {
  font-size: 2.5rem;
  opacity: .2;
  display: block;
  margin-bottom: 16px;
}
.empty-state h3 { font-size: 1rem; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-state p  { font-size: .875rem; max-width: 320px; margin: 0 auto 20px; }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  flex-wrap: wrap;
}
.page-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-full);
  font-size: .8125rem;
  font-weight: 600;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  text-decoration: none;
  transition: all var(--t);
  cursor: pointer;
}
.page-link:hover { border-color: var(--indigo); color: var(--indigo); background: var(--indigo-dim); }
.page-link.active { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.page-link.disabled { opacity: .4; pointer-events: none; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  :root { --sidebar-width: 0px; --pad: var(--pad-sm); }
  .main-wrapper { margin-left: 0; padding-bottom: 68px; }
  .page-content { padding: var(--pad-sm); }
}
