/* ===================================================================
   Consultorio Psicológico - Hoja de estilos principal
   =================================================================== */

/* -------- Reset mínimo y box model consistente -------- */
*,
*::before,
*::after { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, "Noto Sans";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: #0f172a;                  /* slate-900 */
  background: #f1f5f9;             /* slate-100 */
}

/* -------- Variables de diseño -------- */
:root{
  --radius: 14px;
  --radius-sm: 10px;
  --gap: 12px;
  --primary: #2563eb;              /* azul */
  --primary-2: #06b6d4;            /* cyan */
  --primary-3: #0ea5e9;
  --surface: #ffffff;
  --border: #e2e8f0;               /* slate-200 */
  --muted: #64748b;                /* slate-500 */
  --ring: rgba(37,99,235,.15);
}

/* -------- Utilidades -------- */
.container{
  max-width: 1100px;
  margin: 20px auto;
  padding: 0 16px;
}

.muted{ color: var(--muted); }

.error{
  background: #fee2e2; color: #991b1b;
  border: 1px solid #fecaca;
  padding: 10px 12px; border-radius: var(--radius-sm);
  margin: 8px 0;
}

.success{
  background: #dcfce7; color: #166534;
  border: 1px solid #bbf7d0;
  padding: 10px 12px; border-radius: var(--radius-sm);
  margin: 8px 0;
}

.grid2{ display:grid; grid-template-columns: 1fr auto; gap: var(--gap); }
.grid3{ display:grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: var(--gap); }
.grid4{ display:grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: var(--gap); }

@media (max-width: 860px){
  .grid2,.grid3,.grid4{ grid-template-columns: 1fr; }
}

/* -------- Top bar -------- */
.topbar{
  position: sticky; top: 0; z-index: 20;
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
}
.topbar nav{
  max-width: 1100px; margin: 0 auto; padding: 10px 16px;
  display: flex; gap: 14px; align-items: center;
}
.topbar a{
  color: #0f172a; text-decoration: none; padding: 6px 8px; border-radius: 8px;
}
.topbar a:hover{ background: #f8fafc; }

/* -------- Card -------- */
.card{
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow:
    0 12px 30px rgba(2, 132, 199, 0.08),
    0 2px 10px rgba(2, 132, 199, 0.05);
}

/* -------- Títulos -------- */
h1{ font-size: 28px; margin: 0 0 8px; }
h2{ font-size: 20px; margin: 0 0 8px; }
h3{ font-size: 16px; margin: 0 0 6px; }

/* -------- Formularios -------- */
label{ display:block; font-weight: 600; margin: 8px 0 6px; }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="number"],
select,
textarea{
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
  outline: none;
  transition: box-shadow .15s, border-color .15s;
  font-size: 15px;
}

textarea{ min-height: 110px; resize: vertical; }

input:focus,
select:focus,
textarea:focus{
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--ring);
}

/* -------- Botones -------- */
button, .btn, .btn-primary, .btn-link{
  font: inherit; cursor: pointer; border: 0; background: none;
}

.btn-primary{
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-2) 100%);
  box-shadow:
    0 10px 22px rgba(37, 99, 235, .25),
    0 4px 10px rgba(6, 182, 212, .18);
  transition: transform .06s ease, filter .2s;
  text-decoration: none; display: inline-block;
}
.btn-primary:hover{ filter: brightness(1.05); }
.btn-primary:active{ transform: translateY(1px); }

.btn-link{
  color: var(--primary);
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
}
.btn-link:hover{ background: #eef2ff; }

/* -------- Login (página auth) -------- */
body.auth{
  min-height: 100%;
  display: grid; place-items: center;
  background:
    radial-gradient(1200px 600px at 80% 10%, rgba(14,165,233,.10), transparent 60%),
    radial-gradient(900px 500px at 20% 90%, rgba(6,182,212,.12), transparent 55%),
    linear-gradient(180deg, #f8fafc 0%, #eef2ff 100%);
}
body.auth::before{
  content:"";
  position: fixed; inset: 0;
  background: url('../img/login-bg.jpg') center/cover no-repeat;
  opacity: .12; pointer-events: none; /* si no existe la imagen, no pasa nada */
}
.auth .card{
  width: min(420px, 92vw);
  padding: 22px 18px;
}
.auth h1{ margin-bottom: 8px; }
.auth .legal{ font-size: 12px; color: var(--muted); }

/* -------- Tablas genéricas -------- */
.table-responsive{ max-width:100%; overflow-x:auto; }

.table{
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;             /* fijo por defecto; cambia si lo necesitas */
}

.table th,
.table td{
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  vertical-align: top;
}

/* Encabezados genéricos: no partir palabras por defecto */
.table th{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.table td{
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Modo móvil (genérico): apilar si se desea aplicando data-label
   Puedes limitar esto a tablas específicas si prefieres. */
@media (max-width: 860px){
  .table.stack-mobile thead{ display:none; }
  .table.stack-mobile,
  .table.stack-mobile tbody,
  .table.stack-mobile tr,
  .table.stack-mobile td{ display:block; width:100%; }
  .table.stack-mobile tr{
    border:1px solid var(--border);
    border-radius: 12px;
    padding: 10px; margin-bottom: 10px;
    background: #fff;
  }
  .table.stack-mobile td{ border:0; padding:6px 0; }
  .table.stack-mobile td::before{
    content: attr(data-label) ": ";
    font-weight: 600; color: var(--muted);
    display: inline-block; min-width: 120px;
  }
}

/* ===================================================================
   LISTA DE PACIENTES - tabla específica (evita encabezados “verticales”)
   =================================================================== */
.table-pacientes{
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;            /* fija el layout (las columnas respetan colgroup) */
}

/* Anchos por columna (deben coincidir con 5 columnas) */
.table-pacientes col:nth-child(1){ width: 11rem; } /* Documento */
.table-pacientes col:nth-child(2){ width: 18rem; } /* Nombre */
.table-pacientes col:nth-child(3){ width: auto;  } /* Contacto */
.table-pacientes col:nth-child(4){ width: 10rem; } /* Ciudad */
.table-pacientes col:nth-child(5){ width: 8rem;  } /* Acciones */

.table-pacientes th,
.table-pacientes td{
  border-bottom: 1px solid var(--border);
  padding: 10px 8px;
  vertical-align: top;
}

/* Encabezados: una sola línea, sin cortes */
.table-pacientes th{
  white-space: nowrap !important;
  overflow-wrap: normal !important;
  word-break: normal !important;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* Celdas: sí envuelven */
.table-pacientes td{
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.table-pacientes td a{
  text-decoration: none;
  color: #0f172a;
}
.table-pacientes td a:hover{ color: var(--primary); }

/* Móvil: tarjetas apiladas para pacientes */
@media (max-width: 860px){
  .table-pacientes{ table-layout: auto; }
  .table-pacientes thead{ display:none; }
  .table-pacientes,
  .table-pacientes tbody,
  .table-pacientes tr,
  .table-pacientes td{ display:block; width:100%; }
  .table-pacientes tr{
    border:1px solid var(--border);
    border-radius: 12px;
    padding: 10px; margin-bottom: 10px;
    background: #fff;
  }
  .table-pacientes td{ border:0; padding:6px 0; }
  .table-pacientes td::before{
    content: attr(data-label) ": ";
    font-weight: 600; color: var(--muted);
    display: inline-block; min-width: 120px;
  }
}

/* -------- Tablas compactas (si deseas aplicarlas en panel/agenda) -------- */
.table-compact th, .table-compact td{ padding: 8px 6px; }

/* -------- Logo en encabezados -------- */
.logo{ height: 28px; vertical-align: middle; }

/* -------- Enlaces -------- */
a{ color: var(--primary); }
a:hover{ color: var(--primary-3); }

/* -------- Inputs pequeños para tablas/acciones -------- */
.input-inline{
  display:inline-block; width:auto; min-width: 220px;
}

/* -------- Sombras sutiles para bloques flotantes -------- */
.shadow-lg{
  box-shadow:
    0 25px 60px rgba(2, 132, 199, .12),
    0 10px 20px rgba(2, 132, 199, .10);
}

/* -------- Pequeños helpers visuales -------- */
.badge{
  display:inline-block; padding: 2px 8px; border-radius: 999px;
  background: #eff6ff; color:#1d4ed8; font-size: 12px; border: 1px solid #dbeafe;
}

/* Ajuste compacto de filas de tabla en fichas */
.table-tight th, .table-tight td{ padding:8px 6px; }
