/* ═══════════════════════════════════════════════════════════════
   TAP VET DESIGN SYSTEM — v1.0
   Fuente: Brand Guidelines TAP Vet v0.1
   ═══════════════════════════════════════════════════════════════ */

/* Archivo (display / headings) — Google Fonts. Cooper Hewitt (UI body) — self-hosted, ver @font-face abajo. */
@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@400;500;600;700;800&display=swap');

/* ── Cooper Hewitt (tipografía UI oficial TAP VET, PRD v2.0 §3/§20) ──
   Open-source (Smithsonian / Cooper Hewitt). Self-hosteada en static/fonts/. */
@font-face {
  font-family: 'Cooper Hewitt';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url('../fonts/cooper-hewitt/cooper-hewitt-latin-300-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Cooper Hewitt';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/cooper-hewitt/cooper-hewitt-latin-400-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Cooper Hewitt';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/cooper-hewitt/cooper-hewitt-latin-500-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Cooper Hewitt';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/cooper-hewitt/cooper-hewitt-latin-600-normal.woff2') format('woff2');
}
@font-face {
  font-family: 'Cooper Hewitt';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url('../fonts/cooper-hewitt/cooper-hewitt-latin-700-normal.woff2') format('woff2');
}

/* Alpine.js — ocultar elementos hasta que el JS inicialice */
[x-cloak] { display: none !important; }

/* ── TOKENS ─────────────────────────────────────────────────── */
:root {
  --tapvet-forest:     #003B29;
  --tapvet-orange:     #F74E18;
  --tapvet-amber:      #FF9E00;
  --tapvet-sage:       #8DBD64;
  --tapvet-white:      #FFFFFF;

  --gray-950:  #0A0A0A;
  --gray-900:  #111827;
  --gray-800:  #1F2937;
  --gray-700:  #374151;
  --gray-600:  #4B5563;
  --gray-500:  #6B7280;
  --gray-400:  #9CA3AF;
  --gray-300:  #D1D5DB;
  --gray-200:  #E5E7EB;
  --gray-100:  #F3F4F6;
  --gray-50:   #F9FAFB;

  --color-danger:      #EF4444;
  --color-danger-bg:   #FEF2F2;
  --color-warning:     #FF9E00;
  --color-warning-bg:  #FFFBEB;
  --color-success:     #8DBD64;
  --color-success-bg:  #F0FDF4;
  --color-info:        #3B82F6;
  --color-info-bg:     #EFF6FF;

  --surface-page:      #f5faf8;
  --surface-card:      #FFFFFF;
  --surface-sidebar:   #003B29;
  --surface-topbar:    #FFFFFF;
  --surface-hover:     #e6f7f1;
  --surface-selected:  #e6f7f1;

  --border-default:    #d0e5dc;
  --border-strong:     #b3ead8;
  --border-focus:      #003B29;
  --border-radius-sm:  6px;
  --border-radius-md:  8px;
  --border-radius-lg:  12px;
  --border-radius-xl:  16px;

  --font-display: 'Archivo', sans-serif;
  --font-body:    'Cooper Hewitt', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  --text-xs:   11px;
  --text-sm:   13px;
  --text-base: 14px;
  --text-md:   15px;
  --text-lg:   16px;
  --text-xl:   18px;
  --text-2xl:  22px;
  --text-3xl:  28px;
  --text-4xl:  36px;

  --space-1:  4px;
  --space-2:  8px;
  --space-3:  12px;
  --space-4:  16px;
  --space-5:  20px;
  --space-6:  24px;
  --space-8:  32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;

  --shadow-xs: 0 1px 2px rgba(0,59,41,0.06);
  --shadow-sm: 0 1px 3px rgba(0,59,41,0.08);
  --shadow-md: 0 4px 12px rgba(0,59,41,0.10);
  --shadow-lg: 0 8px 24px rgba(0,59,41,0.12);
  --shadow-xl: 0 16px 40px rgba(0,59,41,0.16);

  --transition-fast:   150ms ease;
  --transition-normal: 200ms ease;
  --transition-slow:   300ms ease;

  --sidebar-width:      240px;
  --sidebar-collapsed:  64px;
  --topbar-height:      56px;
  --content-max-width:  1280px;
}

/* ── RESET & BASE ────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--gray-700);
  background-color: var(--surface-page);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  color: var(--gray-900);
  margin: 0;
}

a { color: inherit; text-decoration: none; }

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

.app-sidebar {
  width: var(--sidebar-width);
  background: var(--surface-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  overflow-y: auto;
  overflow-x: hidden;
}

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

.app-topbar {
  height: var(--topbar-height);
  background: var(--surface-topbar);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-6);
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-xs);
}

.app-content {
  flex: 1;
  padding: var(--space-6);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

/* ── SIDEBAR COMPONENTS ──────────────────────────────────────── */
.sidebar-logo {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-5);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-logo img {
  max-height: 44px;
  width: auto;
  display: block;
}

.sidebar-user {
  padding: var(--space-4);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--tapvet-orange);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--text-sm);
  color: white;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: 600;
  color: rgba(255,255,255,0.95);
  line-height: 1.2;
}

.sidebar-user-role {
  font-size: var(--text-xs);
  color: rgba(255,255,255,0.5);
  margin-top: 1px;
}

.sidebar-nav {
  flex: 1;
  padding: var(--space-3) 0;
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,255,255,0.35);
  padding: var(--space-4) var(--space-5) var(--space-2);
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-5);
  font-size: var(--text-sm);
  color: rgba(255,255,255,0.65);
  border-left: 3px solid transparent;
  transition: all var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
}

.sidebar-item.active {
  background: rgba(255,255,255,0.12);
  border-left-color: var(--tapvet-orange);
  color: white;
  font-weight: 600;
}

.sidebar-item-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-item.active .sidebar-item-icon {
  opacity: 1;
}

.sidebar-item-badge {
  margin-left: auto;
  background: var(--tapvet-amber);
  color: white;
  font-size: var(--text-xs);
  font-weight: 700;
  /* BUG-40: eran 1px 7px — "24/7" y "URG" quedaban ahogados en la píldora. */
  padding: 3px 10px;
  border-radius: 20px;
  line-height: 1.3;
}

.sidebar-item-urgency {
  background: rgba(247,78,24,0.15);
  border-left-color: var(--tapvet-orange) !important;
  color: var(--tapvet-orange) !important;
}

.sidebar-item-urgency:hover {
  background: rgba(247,78,24,0.25) !important;
}

.sidebar-item-urgency .sidebar-item-icon {
  opacity: 1;
  color: var(--tapvet-orange);
}

.sidebar-footer {
  padding: var(--space-4);
  border-top: 1px solid rgba(255,255,255,0.08);
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  /* BUG-40: 36px de alto con 16px de costado dejaban la etiqueta muy justa
     contra los bordes del botón, sobre todo en los secundarios, que sí tienen
     borde visible. */
  padding: 0 var(--space-5);
  height: 40px;
  border-radius: var(--border-radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  font-family: var(--font-body);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn-sm { height: 34px; padding: 0 var(--space-4); font-size: var(--text-xs); }
.btn-lg { height: 48px; padding: 0 var(--space-8); font-size: var(--text-md); }

.btn-primary {
  background: var(--tapvet-orange);
  color: white;
}
.btn-primary:hover { background: #d93e0e; color: white; }

.btn-secondary {
  background: white;
  color: var(--tapvet-forest);
  border: 1px solid var(--tapvet-forest);
}
.btn-secondary:hover { background: var(--surface-selected); }

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

.btn-ghost {
  background: transparent;
  color: var(--gray-600);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--gray-900); }

/* ── CARDS ───────────────────────────────────────────────────── */
.card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  /* BUG-40: la tarjeta trae su propio aire. Antes el padding vivía sólo en
     `.card-body`, así que las decenas de tarjetas armadas con `class="card"` a
     secas dejaban el contenido pegado al borde — se veía clarísimo en las
     tarjetas de mascota, con los badges tocando el borde de abajo. */
  padding: var(--space-5);
}

/* `.card-header`, `.card-body` y las tablas van a sangre contra el borde: traen
   su propio padding o lo necesitan pegado. Se compensa el del contenedor con
   margen negativo en vez de anularlo, porque hay tarjetas que mezclan las dos
   cosas —un header y después contenido suelto, sin `.card-body`— y anulando el
   padding esas quedaban pegadas al borde igual que antes.

   Una tarjeta con `style="padding:…"` inline le gana a esto por especificidad,
   así que las que ya se ajustaron a mano no se mueven. */
.card > .card-header {
  margin: calc(var(--space-5) * -1) calc(var(--space-5) * -1) var(--space-5);
}

.card > .card-body {
  margin: calc(var(--space-5) * -1);
}

.card > .data-table,
.card > table {
  margin: calc(var(--space-5) * -1);
  width: calc(100% + var(--space-5) * 2);
}

.card-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--gray-900);
  font-family: var(--font-display);
}

.card-body { padding: var(--space-5) var(--space-6); }

/* ── STAT CARDS ──────────────────────────────────────────────── */
.stat-card {
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--border-radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.stat-card-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--border-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-card-value {
  font-family: var(--font-display);
  font-size: var(--text-3xl);
  font-weight: 700;
  color: var(--tapvet-forest);
  line-height: 1;
}

.stat-card-label {
  font-size: var(--text-sm);
  color: var(--gray-500);
}

.stat-card-delta {
  font-size: var(--text-xs);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 2px;
}

.stat-card-delta.up   { color: var(--color-success); }
.stat-card-delta.down { color: var(--color-danger); }

/* ── BADGES ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  /* BUG-40: eran 2px 10px. Con 2px arriba y abajo el texto quedaba montado
     sobre el borde de la píldora. El alto ahora lo fija `line-height` + padding
     para que la caja no dependa de la fuente. */
  padding: 5px 12px;
  line-height: 1.2;
  border-radius: 20px;
  font-size: var(--text-xs);
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.badge-pendiente  { background:#FFF7ED; color:#C2410C; border-color:#FED7AA; }
.badge-confirmado { background:#F0FDF4; color:#15803D; border-color:#BBF7D0; }
.badge-en-curso   { background:#EFF6FF; color:#1D4ED8; border-color:#BFDBFE; }
.badge-cancelado  { background:#FEF2F2; color:#DC2626; border-color:#FECACA; }
.badge-urgente    { background:#FFF1F2; color:#E11D48; border-color:var(--tapvet-orange); }
.badge-success    { background:var(--color-success-bg); color:#15803D; border-color:#BBF7D0; }
.badge-warning    { background:var(--color-warning-bg); color:#92400E; border-color:#FDE68A; }
.badge-info       { background:var(--color-info-bg); color:#1D4ED8; border-color:#BFDBFE; }

/* ── TABLES ──────────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table thead tr {
  background: var(--gray-50);
  border-bottom: 1px solid var(--border-default);
}

.data-table thead th {
  /* BUG-40: las filas eran 12px de alto de padding; con la línea divisoria el
     texto quedaba apretado contra el borde de la fila de al lado. */
  padding: var(--space-4);
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gray-500);
}

.data-table tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr:last-child { border-bottom: none; }

.data-table tbody td {
  padding: var(--space-4);
  color: var(--gray-700);
}

/* ── FORMS ───────────────────────────────────────────────────── */
.form-group { margin-bottom: var(--space-5); }

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: var(--space-2);
}

.form-input {
  width: 100%;
  /* BUG-40: eran 40px de alto y 12px de costado. El texto arrancaba casi sobre
     el borde izquierdo; ahora respira de los dos lados. */
  height: 44px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border-strong);
  border-radius: var(--border-radius-md);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  color: var(--gray-900);
  background: white;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(0,59,41,0.1);
}

.form-input::placeholder { color: var(--gray-400); }
.form-input:disabled { background: var(--gray-50); cursor: not-allowed; }

.form-input.error { border-color: var(--color-danger); }
.form-input.error:focus { box-shadow: 0 0 0 3px rgba(239,68,68,0.1); }

.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  margin-top: var(--space-1);
  display: flex;
  align-items: center;
  gap: 4px;
}

.form-help {
  font-size: var(--text-xs);
  color: var(--gray-500);
  margin-top: var(--space-1);
}

/* ── EMPTY STATE ─────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-8);
  text-align: center;
  gap: var(--space-4);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: var(--gray-300);
}

.empty-state-title {
  font-size: var(--text-lg);
  font-weight: 500;
  color: var(--gray-700);
  font-family: var(--font-display);
}

.empty-state-description {
  font-size: var(--text-sm);
  color: var(--gray-500);
  max-width: 340px;
  line-height: 1.6;
}

/* ── AVATARS ─────────────────────────────────────────────────── */
.avatar {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-family: var(--font-display);
  flex-shrink: 0;
}

.avatar-sm { width: 28px; height: 28px; font-size: 11px; }
.avatar-md { width: 36px; height: 36px; font-size: 13px; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-xl { width: 64px; height: 64px; font-size: 20px; }

.avatar-forest { background: var(--tapvet-forest); color: white; }
.avatar-orange { background: var(--tapvet-orange); color: white; }

/* ── ALERTS / TOASTS ─────────────────────────────────────────── */
.alert {
  padding: var(--space-4) var(--space-5);
  border-radius: var(--border-radius-md);
  font-size: var(--text-sm);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  border: 1px solid transparent;
}

.alert-success { background: var(--color-success-bg); color: #15803D; border-color: #BBF7D0; }
.alert-error   { background: var(--color-danger-bg);  color: #DC2626; border-color: #FECACA; }
.alert-warning { background: var(--color-warning-bg); color: #92400E; border-color: #FDE68A; }
.alert-info    { background: var(--color-info-bg);    color: #1D4ED8; border-color: #BFDBFE; }

/* ── PAGE HEADER ─────────────────────────────────────────────── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
}

.page-title {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--tapvet-forest);
}

.page-subtitle {
  font-size: var(--text-sm);
  color: var(--gray-500);
  margin-top: 2px;
}

/* ── GRID UTILITIES ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-5);
  margin-bottom: var(--space-6);
}

/* ── RESPONSIVE ──────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app-sidebar {
    transform: translateX(-100%);
    transition: transform var(--transition-normal);
  }
  .app-sidebar.open { transform: translateX(0); }
  .app-main { margin-left: 0; }
  .app-content { padding: var(--space-4); }
}
                                                                                                                  