/* ==========================================================
   VetFaifex - Estilos personalizados
   ========================================================== */

:root {
  --vf-primary: #1e7e8c;
  --vf-primary-dark: #155e69;
  --vf-accent: #f4a261;
  --vf-success: #2a9d8f;
  --vf-danger: #e63946;
  --vf-warning: #f4a261;
  --vf-bg: #f3f5f8;
  --vf-sidebar-bg: #11253b;
  --vf-sidebar-bg-hover: #1c3656;
  --vf-sidebar-text: #c2cbd7;
  --vf-sidebar-active: #1e7e8c;
  --vf-topbar-bg: #14304d;
  --vf-card-radius: 12px;
}

html, body { height: 100%; }
body {
  background: var(--vf-bg);
  font-family: 'Inter', system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: #1a2a3a;
}

[data-bs-theme="dark"] body { background: #0f1622; color: #e9ecef; }

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

.sidebar {
  width: 250px;
  background: var(--vf-sidebar-bg);
  color: var(--vf-sidebar-text);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: margin-left .25s ease;
  box-shadow: 2px 0 8px rgba(0,0,0,.08);
}
.sidebar.collapsed { margin-left: -250px; }

.sidebar-brand {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  padding: 1.1rem 1.25rem .25rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.sidebar-brand i { color: var(--vf-accent); font-size: 1.6rem; }
.sidebar-subtitle {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: #6b8aaa;
  padding: 0 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-nav { padding: .75rem 0; flex: 1; overflow-y: auto; }
.sidebar-nav .nav-section {
  font-size: .7rem;
  letter-spacing: .12em;
  color: #5d7793;
  padding: 1rem 1.25rem .25rem;
}
.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .55rem 1.25rem;
  color: var(--vf-sidebar-text);
  font-size: .92rem;
  border-left: 3px solid transparent;
  text-decoration: none;
  transition: all .15s;
}
.sidebar-nav .nav-link i { width: 1.1rem; text-align: center; font-size: 1.05rem; }
.sidebar-nav .nav-link:hover {
  background: var(--vf-sidebar-bg-hover);
  color: #fff;
}
.sidebar-nav .nav-link.active {
  background: linear-gradient(90deg, rgba(30,126,140,.25), transparent);
  color: #fff;
  border-left-color: var(--vf-accent);
}

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  background: var(--vf-topbar-bg);
  color: #fff;
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  box-shadow: 0 2px 6px rgba(0,0,0,.07);
}
.topbar-title { font-weight: 600; font-size: 1.05rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .btn-outline-light { border-color: rgba(255,255,255,.4); }

.avatar-circle {
  width: 32px; height: 32px; border-radius: 50%;
  background: var(--vf-accent); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: .8rem;
}

.content { padding: 1.5rem; flex: 1; }
.footer { text-align: center; padding: .75rem; color: #6c757d; font-size: .85rem; }

/* ====== Cards / KPIs ====== */
.card { border: 0; border-radius: var(--vf-card-radius); box-shadow: 0 2px 8px rgba(16,30,54,.05); }
.card-header { background: #fff; border-bottom: 1px solid #eef2f7; font-weight: 600; border-radius: var(--vf-card-radius) var(--vf-card-radius) 0 0 !important; }
[data-bs-theme="dark"] .card { background: #1a2535; }
[data-bs-theme="dark"] .card-header { background: #1a2535; border-bottom-color: #2a3650; }

.kpi-card {
  background: linear-gradient(135deg, var(--vf-primary), var(--vf-primary-dark));
  color: #fff;
  border-radius: var(--vf-card-radius);
  padding: 1rem 1.25rem;
  display: flex; align-items: center; justify-content: space-between;
  height: 100%;
}
.kpi-card .kpi-value { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.kpi-card .kpi-label { font-size: .82rem; opacity: .85; text-transform: uppercase; letter-spacing: .04em; }
.kpi-card .kpi-icon  { font-size: 2.3rem; opacity: .35; }

.kpi-card.kpi-success { background: linear-gradient(135deg, #2a9d8f, #1d7269); }
.kpi-card.kpi-warning { background: linear-gradient(135deg, #f4a261, #e07a26); }
.kpi-card.kpi-danger  { background: linear-gradient(135deg, #e63946, #b21f2d); }
.kpi-card.kpi-info    { background: linear-gradient(135deg, #4895ef, #3672bd); }

/* ====== Tabla / Forms ====== */
.table { background: #fff; border-radius: var(--vf-card-radius); overflow: hidden; }
[data-bs-theme="dark"] .table { background: #1a2535; color: #e9ecef; }
.table thead th { background: #f3f6fa; font-size: .85rem; text-transform: uppercase; letter-spacing: .04em; }
[data-bs-theme="dark"] .table thead th { background: #243246; }

.btn-primary { background: var(--vf-primary); border-color: var(--vf-primary); }
.btn-primary:hover { background: var(--vf-primary-dark); border-color: var(--vf-primary-dark); }
.text-vf { color: var(--vf-primary); }
.bg-vf { background: var(--vf-primary); }

.badge.bg-pendiente   { background: #ffc107; color: #000; }
.badge.bg-confirmado  { background: #0dcaf0; }
.badge.bg-en_curso    { background: #6610f2; }
.badge.bg-atendido    { background: #198754; }
.badge.bg-cancelado   { background: #dc3545; }
.badge.bg-ausente     { background: #6c757d; }

/* ====== Auth ====== */
.auth-body {
  margin: 0;
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  background: #11253b;
  position: relative;
  overflow: hidden;
}
.auth-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(circle at 20% 30%, rgba(30,126,140,.5) 0, transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(244,162,97,.4) 0, transparent 40%);
}
.auth-container {
  position: relative;
  width: 100%; max-width: 420px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0,0,0,.3);
  padding: 2rem 2rem 1.5rem;
}
.auth-brand {
  text-align: center; margin-bottom: 1.25rem;
}
.auth-brand i { font-size: 3rem; color: var(--vf-primary); }
.auth-brand h1 { font-size: 1.5rem; margin: .25rem 0 0; color: #11253b; font-weight: 700; }
.auth-brand p { color: #6c757d; font-size: .9rem; margin: 0; }

/* ====== Calendario simple ====== */
.calendar { width: 100%; border-collapse: collapse; }
.calendar th { background: #f3f6fa; padding: .5rem; text-align: center; font-size: .85rem; }
.calendar td { border: 1px solid #eef2f7; vertical-align: top; height: 90px; padding: .35rem; width: 14.28%; }
.calendar td.other-month { background: #fafbfc; color: #aab3bf; }
.calendar td.today { background: #eef9ff; }
.calendar .day-num { font-weight: 600; font-size: .85rem; }
.calendar .event {
  background: var(--vf-primary); color: #fff; font-size: .7rem;
  padding: .1rem .35rem; border-radius: 4px; margin-top: 3px; display: block;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ====== Backdrop del menu (moviles) ====== */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
  display: none;
}
.sidebar-backdrop.show { display: block; }

/* ====== Responsive: menu lateral (tablets y moviles, <= 992px) ====== */
@media (max-width: 992px) {
  /* Oculto por defecto mediante CSS (no depende de JavaScript) */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 1000;
    margin-left: 0 !important;
    transform: translateX(-100%);
    transition: transform .25s ease;
  }
  /* Se muestra solo cuando el JS agrega la clase .show */
  .sidebar.show {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.4);
  }
}
@media (min-width: 993px) {
  /* Escritorio: nunca mostrar el backdrop ni desplazar el menu */
  .sidebar-backdrop { display: none !important; }
  .sidebar { transform: none !important; }
}

@media (max-width: 768px) {
  .content { padding: 1rem; }

  /* Scroll horizontal en tablas anchas en lugar de romper el layout */
  .content .table:not(.dataTable) {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .card-body.p-0 {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* El calendario mantiene un ancho legible y se desplaza horizontalmente */
  .calendar { min-width: 640px; }
  .calendar td { height: 70px; }

  /* KPIs y titulos un poco mas compactos */
  .kpi-card .kpi-value { font-size: 1.5rem; }
  .topbar-title { font-size: .95rem; }
}
