@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&display=swap');

:root {
  --blue:    #2B7FFF;
  --green:   #00C48C;
  --red:     #FF4D4F;
  --yellow:  #FAAD14;
  --bg:      #F4F6FB;
  --surface: #FFFFFF;
  --border:  #E5E9F0;
  --text:    #1A2035;
  --muted:   #6B7A99;
  --sidebar: #0F1929;
  --sidebar-w: 240px;
  --radius:  10px;
  --shadow:  0 2px 12px rgba(0,0,0,.07);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body { font-family: 'DM Sans', sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

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

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  padding: 24px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo span { font-size: 1.15rem; font-weight: 700; color: #fff; }
.sidebar-logo em   { color: var(--blue); font-style: normal; }

.sidebar-nav { flex: 1; padding: 16px 0; overflow-y: auto; }
.nav-section-label {
  font-size: .7rem; font-weight: 600; letter-spacing: .08em;
  color: rgba(255,255,255,.35); padding: 16px 20px 6px; text-transform: uppercase;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px; color: rgba(255,255,255,.65);
  font-size: .9rem; font-weight: 500;
  border-radius: 0; transition: all .15s;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-item.active { background: var(--blue); color: #fff; }
.nav-item .icon { font-size: 1.1rem; width: 22px; text-align: center; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.sidebar-user { display: flex; align-items: center; gap: 10px; }
.sidebar-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--blue); display: flex; align-items: center; justify-content: center;
  font-weight: 700; color: #fff; font-size: .85rem;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name  { font-size: .85rem; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-role  { font-size: .72rem; color: rgba(255,255,255,.45); }
.logout-btn { background: none; border: none; color: rgba(255,255,255,.4); font-size: 1rem; padding: 4px; transition: color .15s; }
.logout-btn:hover { color: var(--red); }

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

.topbar {
  height: 62px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 1.05rem; font-weight: 600; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-body { padding: 28px; flex: 1; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px 16px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: .95rem; font-weight: 600; }
.card-body  { padding: 22px; }

/* Métricas */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; align-items: flex-start; gap: 14px;
}
.metric-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.metric-icon.blue   { background: #EBF3FF; }
.metric-icon.green  { background: #E6FAF4; }
.metric-icon.yellow { background: #FFF8E6; }
.metric-icon.red    { background: #FFF0F0; }
.metric-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.metric-label { font-size: .8rem; color: var(--muted); margin-top: 4px; }

/* ── Tabla ──────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
thead th {
  text-align: left; padding: 11px 14px;
  font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); border-bottom: 1px solid var(--border);
  background: #FAFBFC;
}
tbody td { padding: 13px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #FAFBFC; }

/* ── Badges ─────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 600;
}
.badge.active   { background: #E6FAF4; color: #00875A; }
.badge.inactive { background: #FFF0F0; color: #CF1322; }
.badge.dental     { background: #EBF3FF; color: var(--blue); }
.badge.medical    { background: #FFF8E6; color: #B45309; }
.badge.veterinary { background: #F0FFF4; color: #276749; }
.badge.psychology { background: #FAF5FF; color: #6B21A8; }
.badge.nutrition  { background: #ECFDF5; color: #065F46; }
.badge.other      { background: #F1F5F9; color: #475569; }

/* ── Botones ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 8px; font-size: .88rem; font-weight: 600;
  border: none; transition: all .15s;
}
.btn-primary  { background: var(--blue); color: #fff; }
.btn-primary:hover  { background: #1a6fe8; }
.btn-success  { background: var(--green); color: #fff; }
.btn-danger   { background: var(--red); color: #fff; }
.btn-ghost    { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 5px 12px; font-size: .8rem; }
.btn:disabled { opacity: .5; pointer-events: none; }

/* ── Forms ──────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .85rem; font-weight: 600; margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 10px 13px; border: 1.5px solid var(--border);
  border-radius: 8px; font-size: .9rem; color: var(--text);
  transition: border-color .15s; background: var(--surface);
}
.form-control:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(43,127,255,.1); }
.form-control::placeholder { color: var(--muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: .78rem; color: var(--muted); margin-top: 4px; }

/* ── Modal ──────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 200;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--surface); border-radius: 14px; width: 100%; max-width: 540px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2);
  transform: translateY(20px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-title  { font-size: 1rem; font-weight: 700; }
.modal-close  { background: none; border: none; font-size: 1.3rem; color: var(--muted); line-height: 1; }
.modal-body   { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Alert / Toast ───────────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: 8px; font-size: .88rem; margin-bottom: 16px; }
.alert.error   { background: #FFF0F0; color: #CF1322; border: 1px solid #FFCCC7; }
.alert.success { background: #E6FAF4; color: #00875A; border: 1px solid #B7EBD9; }

/* ── Filtros ────────────────────────────────────────────────────────── */
.filters-bar { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-bottom: 20px; }
.filters-bar .form-control { width: auto; min-width: 160px; }
.search-input { position: relative; }
.search-input input { padding-left: 36px; }
.search-input .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }

/* ── Pagination ─────────────────────────────────────────────────────── */
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 6px; margin-top: 18px; }
.page-btn {
  min-width: 34px; height: 34px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--surface); font-size: .85rem; font-weight: 500;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all .15s;
}
.page-btn:hover  { background: var(--blue); color: #fff; border-color: var(--blue); }
.page-btn.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.page-btn:disabled { opacity: .4; pointer-events: none; }

/* ── Login page ─────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, #0F1929 0%, #1a2d50 100%);
}
.login-box {
  background: var(--surface); border-radius: 18px; padding: 44px;
  width: 100%; max-width: 420px; box-shadow: 0 24px 80px rgba(0,0,0,.3);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo h1 { font-size: 1.6rem; font-weight: 700; }
.login-logo h1 em { color: var(--blue); font-style: normal; }
.login-logo p  { color: var(--muted); font-size: .88rem; margin-top: 4px; }

/* ── Onboarding Wizard ──────────────────────────────────────────────── */
.onboarding-page {
  min-height: 100vh; background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 40px 20px;
}
.wizard-box {
  background: var(--surface); border-radius: 18px; width: 100%; max-width: 640px;
  box-shadow: var(--shadow); overflow: hidden;
}
.wizard-header { background: var(--sidebar); padding: 28px 32px; }
.wizard-header h2 { color: #fff; font-size: 1.1rem; font-weight: 700; }
.wizard-header p  { color: rgba(255,255,255,.5); font-size: .85rem; margin-top: 4px; }
.wizard-steps {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
}
.wizard-step {
  flex: 1; padding: 14px; text-align: center; font-size: .8rem; font-weight: 600;
  color: var(--muted); border-bottom: 3px solid transparent; transition: all .2s;
}
.wizard-step.active { color: var(--blue); border-bottom-color: var(--blue); }
.wizard-step.done   { color: var(--green); }
.wizard-body { padding: 32px; }

/* Clinic type selector */
.type-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.type-card {
  border: 2px solid var(--border); border-radius: 10px; padding: 18px 12px;
  text-align: center; cursor: pointer; transition: all .15s;
}
.type-card:hover  { border-color: var(--blue); background: #EBF3FF; }
.type-card.selected { border-color: var(--blue); background: #EBF3FF; }
.type-card .emoji { font-size: 2rem; display: block; margin-bottom: 8px; }
.type-card .label { font-size: .82rem; font-weight: 600; }

/* ── Empty state ────────────────────────────────────────────────────── */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state p { font-size: .9rem; }

/* ── Loading spinner ─────────────────────────────────────────────────── */
.spinner {
  width: 22px; height: 22px; border: 3px solid rgba(43,127,255,.2);
  border-top-color: var(--blue); border-radius: 50%; animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-center { display: flex; align-items: center; justify-content: center; padding: 40px; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .type-grid { grid-template-columns: repeat(2, 1fr); }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
}
