/* =========================================================
   Sistema de Registro de Atenciones de Enfermería · v2
   Estilos responsive + hamburger menu + print
   ========================================================= */

:root {
  --c-bg: #f4f6fa;
  --c-card: #ffffff;
  --c-text: #1a2233;
  --c-muted: #6b7686;
  --c-border: #e3e7ee;
  --c-primary: #0c6cf2;
  --c-primary-dark: #084fb3;
  --c-accent: #00875a;
  --c-danger: #d23030;
  --c-warn: #c47b00;
  --c-ok-bg: #e8f5ee;   --c-ok-text: #135736;
  --c-err-bg: #fdebea;  --c-err-text: #8a1c1c;
  --c-warn-bg: #fff5e2; --c-warn-text: #7a4d00;
  --c-info-bg: #eaf2fd; --c-info-text: #1c4a8a;
  --radius: 8px;
  --shadow: 0 2px 6px rgba(20,30,60,.06);
  --shadow-lg: 0 8px 24px rgba(20,30,60,.10);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px; line-height: 1.5; color: var(--c-text); background: var(--c-bg);
}
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef1f6; padding: .1rem .35rem; border-radius: 4px; font-size: .9em; }

/* ==========  Topbar + navegación  ========== */
.topbar {
  display: flex; align-items: center; gap: 1rem;
  background: #fff; padding: .8rem 1.5rem;
  border-bottom: 1px solid var(--c-border);
  box-shadow: var(--shadow); flex-wrap: wrap;
}
.brand { display: flex; flex-direction: column; line-height: 1.1; flex: 1; min-width: 0; }
.brand strong { font-size: 1.05rem; }
.brand span { font-size: .8rem; color: var(--c-muted); }

.mainnav {
  display: flex; gap: .2rem; flex-wrap: wrap; align-items: center; flex: 2;
}
.mainnav a {
  padding: .45rem .8rem; border-radius: var(--radius); color: var(--c-text);
}
.mainnav a:hover { background: #eef3fb; text-decoration: none; }
.useractions { display: flex; align-items: center; gap: .6rem; font-size: .9rem; color: var(--c-muted); margin-left: auto; }
.user-info { white-space: nowrap; }
.user-info small { color: var(--c-muted); }

/* Hamburger (oculto en escritorio) */
.nav-toggle {
  display: none; background: transparent; border: 1px solid var(--c-border);
  width: 42px; height: 42px; border-radius: var(--radius); cursor: pointer;
  padding: 0; flex-direction: column; justify-content: center; align-items: center; gap: 4px;
}
.nav-toggle span {
  display: block; width: 22px; height: 2px; background: var(--c-text); border-radius: 2px;
  transition: transform .2s, opacity .2s;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Layout */
.container { max-width: 1200px; margin: 1.5rem auto; padding: 0 1.5rem; }
.footer { text-align: center; color: var(--c-muted); padding: 2rem 1rem; }

/* Cards */
.card {
  background: var(--c-card); border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 1.25rem 1.5rem; margin-bottom: 1.25rem; box-shadow: var(--shadow);
}
.card.narrow { max-width: 480px; margin-left: auto; margin-right: auto; }
.card.narrow.login { margin-top: 4rem; }
.card h1, .card h2 { margin-top: 0; }

h1 { font-size: 1.6rem; margin: 0 0 1rem; }
h2 { font-size: 1.2rem; margin: 1.2rem 0 .8rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.muted { color: var(--c-muted); }
.small { font-size: .85rem; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.acciones-ficha { display: flex; gap: .4rem; flex-wrap: wrap; }

/* Forms */
label { display: block; margin: .6rem 0; font-weight: 500; font-size: .9rem; }
label.inline { display: inline-flex; align-items: center; gap: .35rem; font-weight: 400; margin-right: 1rem; }
input[type=text], input[type=password], input[type=email], input[type=date], input[type=time],
input[type=number], input[type=file], input:not([type]), select, textarea {
  display: block; width: 100%; padding: .6rem .7rem; margin-top: .25rem;
  border: 1px solid var(--c-border); border-radius: var(--radius);
  background: #fff; font: inherit; color: inherit;
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--c-primary);
  box-shadow: 0 0 0 3px rgba(12,108,242,.15);
}
textarea { resize: vertical; min-height: 60px; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: 1fr 1fr; }
.form-actions { display: flex; gap: .6rem; align-items: center; margin-top: 1rem; flex-wrap: wrap; }
.form-inline { display: flex; gap: .5rem; flex-wrap: wrap; align-items: end; }
.form-inline label { margin: 0; }
.form-inline input, .form-inline select { width: auto; min-width: 180px; }
.checks { padding: .5rem 0; }

button, .btn-primary, .btn-sm, .btn-danger {
  display: inline-block; cursor: pointer; padding: .6rem 1rem;
  border-radius: var(--radius); border: 1px solid var(--c-border);
  background: #fff; color: var(--c-text); font: inherit; font-weight: 500;
  text-decoration: none; transition: all .15s; min-height: 42px;
}
button:hover, .btn-sm:hover { background: #eef3fb; }
.btn-primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn-primary:hover { background: var(--c-primary-dark); border-color: var(--c-primary-dark); color:#fff; text-decoration:none; }
.btn-sm { padding: .4rem .7rem; font-size: .88rem; min-height: 36px; }
.btn-danger { background: var(--c-danger); color: #fff; border-color: var(--c-danger); }
.btn-danger:hover { background: #a72525; border-color: #a72525; color: #fff; }

/* Search */
.search-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin: .5rem 0 1rem; }
.search-form input, .search-form select { width: auto; flex: 1; min-width: 200px; margin: 0; }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; min-width: 540px; }
table.data th, table.data td {
  text-align: left; padding: .55rem .6rem;
  border-bottom: 1px solid var(--c-border); vertical-align: top;
}
table.data thead { background: #f7f9fc; }
table.data th { font-size: .82rem; text-transform: uppercase; color: var(--c-muted); letter-spacing: .03em; }
table.data tbody tr:hover { background: #f9fbff; }
table.data.small th, table.data.small td { font-size: .85rem; padding: .35rem .5rem; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: .8rem; margin-bottom: 1.5rem; }
.stat {
  background: #fff; border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: .9rem 1rem; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
}
.stat .num { font-size: 1.8rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--c-muted); font-size: .82rem; margin-top: .2rem; }
.stat.stat-accent { background: linear-gradient(135deg, #0c6cf2 0%, #084fb3 100%); border-color: transparent; }
.stat.stat-accent .num, .stat.stat-accent .lbl { color: #fff; }
.stat.stat-muted { background: #f3f5f9; }

/* Atención */
.atencion { border: 1px solid var(--c-border); border-radius: var(--radius); padding: .9rem 1.1rem; margin: 1rem 0; background: #fbfcfe; }
.atencion > header { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; border-bottom: 1px dashed var(--c-border); padding-bottom: .5rem; margin-bottom: .7rem; }
.atencion .fecha { font-weight: 600; }
.atencion .tipo { background: #e8f0fe; color: #0050b4; padding: .15rem .55rem; border-radius: 4px; font-size: .85rem; }
.atencion .por { color: var(--c-muted); font-size: .85rem; margin-left: auto; }
.atencion .acciones { display: flex; gap: .3rem; }
.atencion dl { display: grid; grid-template-columns: 200px 1fr; gap: .35rem .8rem; margin: 0; }
.atencion dt { font-weight: 600; color: var(--c-muted); font-size: .85rem; }
.atencion dd { margin: 0; }

.alumno-info { background: #eef3fb; padding: .6rem .9rem; border-radius: var(--radius); margin-bottom: 1rem; }

/* Tags & badges */
.tag { display: inline-block; padding: .15rem .55rem; border-radius: 999px; background: #e3e9f3; color: #2a3858; font-size: .78rem; font-weight: 500; }
.tag-warn { background: #fff0d4; color: #7a4d00; }
.badge { display: inline-block; min-width: 24px; text-align: center; padding: .15rem .45rem; background: #e3e9f3; color: #2a3858; border-radius: 999px; font-size: .8rem; }
.badge-on { background: var(--c-primary); color: #fff; }

/* Flash messages */
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1rem; }
.flash-ok   { background: var(--c-ok-bg);   color: var(--c-ok-text);   border: 1px solid #b9e0c8; }
.flash-err  { background: var(--c-err-bg);  color: var(--c-err-text);  border: 1px solid #f0b8b8; }
.flash-warn { background: var(--c-warn-bg); color: var(--c-warn-text); border: 1px solid #f3d599; }
.flash-info { background: var(--c-info-bg); color: var(--c-info-text); border: 1px solid #c0d6f1; }

details > summary { cursor: pointer; padding: .35rem .65rem; border-radius: var(--radius); background: #f3f5f9; display: inline-block; }
details[open] > summary { background: #eaeef5; }

.login h1 { text-align: center; }
.login .muted { text-align: center; margin-bottom: 1.2rem; }
.login button { width: 100%; padding: .75rem; margin-top: .5rem; }

.lista-colegios { list-style: none; padding: 0; }
.lista-colegios li { padding: .6rem 0; border-bottom: 1px solid var(--c-border); display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }

/* ===========  RESPONSIVE — móvil / tablet  =========== */
@media (max-width: 820px) {
  .nav-toggle { display: flex; }

  .mainnav {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    gap: .2rem;
    padding: .5rem 0;
    border-top: 1px solid var(--c-border);
    margin-top: .5rem;
  }
  .mainnav.is-open { display: flex; }
  .mainnav a {
    width: 100%;
    padding: .8rem 1rem;
    border-radius: 0;
    border-bottom: 1px solid var(--c-border);
  }
  .useractions {
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    padding: .8rem 1rem;
    margin-left: 0;
    border-top: 1px solid var(--c-border);
  }

  .container { padding: 0 1rem; margin: 1rem auto; }
  .card { padding: 1rem 1.1rem; }
  h1 { font-size: 1.35rem; }
  h2 { font-size: 1.1rem; }
}

@media (max-width: 600px) {
  .grid-2 { grid-template-columns: 1fr; }
  .form-inline input, .form-inline select { min-width: 0; width: 100%; flex: 1 1 100%; }
  .atencion dl { grid-template-columns: 1fr; gap: .15rem; }
  .atencion dt { margin-top: .4rem; font-size: .8rem; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat .num { font-size: 1.4rem; }
  .row-between { flex-direction: column; align-items: flex-start; }
  .row-between > div, .row-between > a { width: 100%; }
  .acciones-ficha { width: 100%; }
  .acciones-ficha .btn-primary, .acciones-ficha .btn-sm { flex: 1; text-align: center; }
  .atencion .por { margin-left: 0; width: 100%; }
  .atencion .acciones { width: 100%; justify-content: flex-end; }
  table.data { font-size: .85rem; }
  table.data th, table.data td { padding: .4rem .4rem; }
}

/* ===========  ESTILOS DE IMPRESIÓN  =========== */
@media print {
  body { background: #fff; }
  .topbar, .footer, .nav-toggle, .mainnav, .useractions, .form-actions,
  .search-form, .acciones-ficha, .atencion .acciones, .btn-primary,
  .btn-sm, .btn-danger { display: none !important; }
  .card { border: 0; box-shadow: none; padding: 0; margin-bottom: 1rem; }
  .container { max-width: none; padding: 0; margin: 0; }
  .atencion { border: 1px solid #ccc; page-break-inside: avoid; }
  a { color: #000; text-decoration: none; }
}
