/* =========================================================
   Fluent Design estilo Outlook / Hotmail - Tema Naranja
   Fuente: IBM Plex Sans · Fondo blanco
   Responsive: desktop / tablet / smartphone
   ========================================================= */

@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal; font-weight: 400; font-display: swap;
  src: url("../fonts/ibm-plex-sans-400.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal; font-weight: 500; font-display: swap;
  src: url("../fonts/ibm-plex-sans-500.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal; font-weight: 600; font-display: swap;
  src: url("../fonts/ibm-plex-sans-600.woff2") format("woff2");
}
@font-face {
  font-family: "IBM Plex Sans";
  font-style: normal; font-weight: 700; font-display: swap;
  src: url("../fonts/ibm-plex-sans-700.woff2") format("woff2");
}

:root {
  --orange:        #FF8C00;
  --orange-600:    #E67E00;
  --orange-700:    #C96C00;
  --orange-tint:   #FFF3E6;
  --orange-glow:   rgba(255, 140, 0, 0.28);

  --bg:            #FFFFFF;   /* fondo blanco estilo Hotmail */
  --bg-rail:       #FAF9F8;   /* riel/nav lateral (Outlook usa gris muy suave) */
  --surface:       #FFFFFF;
  --surface-solid: #FFFFFF;
  --stroke:        #EDEBE9;   /* neutralLight de Fluent */
  --stroke-strong: #D2D0CE;

  --text:          #201F1E;   /* neutralPrimary */
  --text-soft:     #605E5C;   /* neutralSecondary */
  --text-faint:    #8A8886;   /* neutralTertiary */

  --ok:            #107C10;
  --ok-bg:         #DFF6DD;
  --warn:          #9D5D00;
  --warn-bg:       #FFF4CE;
  --err:           #A80000;
  --err-bg:        #FDE7E9;

  --radius:        8px;
  --radius-sm:     4px;       /* Outlook usa esquinas mas sobrias */
  --shadow:        0 1.6px 3.6px rgba(0,0,0,.10), 0 0.3px 0.9px rgba(0,0,0,.07);
  --shadow-lg:     0 6.4px 14.4px rgba(0,0,0,.13), 0 1.2px 3.6px rgba(0,0,0,.10);
  --font:          "IBM Plex Sans", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}

/* Se fuerza el tema claro (fondo blanco) en todos los dispositivos. */
:root { color-scheme: light; }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--orange-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Layout con sidebar ---------- */
.app {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 100vh;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-rail);
  border-right: 1px solid var(--stroke);
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 16px;
}
.brand .logo {
  width: 40px; height: 40px; border-radius: 10px;
  background: #fff; border: 1px solid var(--stroke);
  display: grid; place-items: center; overflow: hidden;
  flex: 0 0 auto;
}
.logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.brand b { font-size: 15px; line-height: 1.15; }
.brand small { color: var(--text-faint); font-size: 11px; }

.nav-group { font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--text-faint); padding: 12px 12px 4px; }

.nav a {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--radius-sm);
  color: var(--text); font-weight: 500; position: relative;
  transition: background .15s ease;
}
.nav a .ico { width: 20px; text-align: center; opacity: .9; }
.nav a:hover { background: rgba(255,140,0,.10); text-decoration: none; }
.nav a.active { background: var(--orange-tint); color: var(--orange-700); }
.nav a.active::before {
  content: ""; position: absolute; left: 3px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 18px; border-radius: 3px; background: var(--orange);
}

.sidebar .spacer { flex: 1; }
.userbox {
  border-top: 1px solid var(--stroke); padding-top: 12px; margin-top: 8px;
  font-size: 13px;
}
.userbox .who { display:flex; align-items:center; gap:10px; padding: 4px 8px;}
.userbox .avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg,var(--orange),var(--orange-700));
  color:#fff; display:grid; place-items:center; font-weight:600; flex:0 0 auto;
}

/* ---------- Main ---------- */
.main { overflow-y: auto; height: 100vh; }
.topbar {
  display: none; /* solo mobile */
}
.content { padding: 26px 32px 60px; max-width: 1200px; margin: 0 auto; }

.page-head { display:flex; align-items:flex-end; justify-content:space-between;
  gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.page-head h1 { margin: 0; font-size: 26px; font-weight: 650; letter-spacing: -.01em; }
.page-head p { margin: 4px 0 0; color: var(--text-soft); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface-solid);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
}
.card + .card { margin-top: 18px; }
.card h2, .card h3 { margin-top: 0; }

.grid { display: grid; gap: 18px; }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* ---------- Stat tiles ---------- */
.stat {
  background: var(--surface-solid);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex; flex-direction: column; gap: 6px;
  position: relative; overflow: hidden;
}
.stat .label { color: var(--text-soft); font-size: 13px; }
.stat .value { font-size: 32px; font-weight: 700; letter-spacing: -.02em; }
.stat .ico-bg {
  position: absolute; right: -6px; top: -8px; font-size: 58px; opacity: .10;
}
.stat.accent { background: linear-gradient(135deg, var(--orange), var(--orange-700)); color:#fff; border:none; }
.stat.accent .label { color: rgba(255,255,255,.85); }

.meter { height: 8px; border-radius: 6px; background: rgba(0,0,0,.08); overflow: hidden; margin-top: 6px; }
.meter > span { display:block; height:100%; background: linear-gradient(90deg,var(--orange),var(--orange-700)); border-radius:6px; }
.meter.low > span { background: linear-gradient(90deg,#e0a100,#c42b1c); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 640px; }
table.data th, table.data td { padding: 12px 14px; text-align: left; }
table.data thead th {
  background: rgba(0,0,0,.03); color: var(--text-soft);
  font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing:.04em;
  border-bottom: 1px solid var(--stroke);
}
table.data tbody tr { border-bottom: 1px solid var(--stroke); }
table.data tbody tr:hover { background: rgba(255,140,0,.06); }
table.data td.actions { white-space: nowrap; text-align: right; }

/* ---------- Badges ---------- */
.badge { display:inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight:600; }
.badge-ok   { background: var(--ok-bg);   color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-err  { background: var(--err-bg);  color: var(--err); }
.badge-role { background: var(--orange-tint); color: var(--orange-700); }

/* ---------- Forms ---------- */
.form-row { display: grid; gap: 16px; grid-template-columns: repeat(2,1fr); }
.form-row.cols-3 { grid-template-columns: repeat(3,1fr); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 4px; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-soft); }
.field .hint { font-size: 12px; color: var(--text-faint); }

input, select, textarea {
  font-family: inherit; font-size: 15px; color: var(--text);
  background: var(--surface-solid);
  border: 1px solid var(--stroke-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--orange-glow);
}
input[readonly] { background: rgba(0,0,0,.03); color: var(--text-soft); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 8px; justify-content:center;
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 10px 18px; border-radius: var(--radius-sm);
  border: 1px solid transparent; cursor: pointer;
  background: var(--surface-solid); color: var(--text);
  border-color: var(--stroke-strong);
  transition: transform .05s, box-shadow .15s, background .15s;
  text-decoration: none;
}
.btn:hover { text-decoration:none; box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--orange), var(--orange-600));
  color: #fff; border: none; box-shadow: 0 4px 14px var(--orange-glow);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--orange-600), var(--orange-700)); }
.btn-ghost { background: transparent; border-color: var(--stroke-strong); }
.btn-ok  { background: var(--ok);  color:#fff; border:none; }
.btn-err { background: var(--err); color:#fff; border:none; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.btn-row.inline-nowrap { flex-wrap: nowrap; }
.btn-row.inline-nowrap > input, .btn-row.inline-nowrap > select { min-width: 0; }

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: var(--radius-sm); margin-bottom: 18px; font-size: 14px;
  border: 1px solid transparent; }
.alert-ok  { background: var(--ok-bg);  color: var(--ok);  border-color: rgba(16,124,16,.25); }
.alert-err { background: var(--err-bg); color: var(--err); border-color: rgba(196,43,28,.25); }
.alert-info{ background: var(--orange-tint); color: var(--orange-700); border-color: rgba(255,140,0,.25); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 400px; background: var(--surface-solid);
  border: 1px solid var(--stroke); border-radius: 16px;
  box-shadow: var(--shadow-lg); padding: 34px 30px; text-align: center;
}
.login-card .logo {
  width: 76px; height: 76px; border-radius: 16px; margin: 0 auto 16px;
  background: #fff; display:grid; place-items:center; overflow:hidden;
  padding: 6px;
}
.login-card h1 { font-size: 22px; margin: 0 0 4px; }
.login-card p.sub { color: var(--text-soft); margin: 0 0 22px; }
.login-card .field { text-align: left; }
.login-card .btn { width: 100%; margin-top: 8px; }
.login-hint { margin-top:18px; font-size:12px; color:var(--text-faint); line-height:1.6; }

/* Etiquetas dentro de modales SweetAlert de edicion */
.swal-lbl { display:block; font-size:12px; font-weight:600; color:#605E5C; margin-bottom:2px; }
.swal2-popup .swal2-input, .swal2-popup .swal2-select { font-size:14px; }

.muted { color: var(--text-faint); }
.text-right { text-align: right; }
.mt { margin-top: 18px; }
.nowrap { white-space: nowrap; }

/* ---------- Mobile nav toggle ---------- */
.scrim { display: none; }

/* =========================================================
   RESPONSIVE
   ========================================================= */

/* Tablet */
@media (max-width: 1024px) {
  .app { grid-template-columns: 220px 1fr; }
  .content { padding: 22px 22px 50px; }
  .grid.cols-4 { grid-template-columns: repeat(2,1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2,1fr); }
}

/* Smartphone */
@media (max-width: 720px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto; }

  .topbar {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px; position: sticky; top: 0; z-index: 30;
    background: var(--surface); backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--stroke);
  }
  .topbar .logo {
    width: 34px; height: 34px; border-radius: 9px;
    background: #fff; border: 1px solid var(--stroke);
    display:grid; place-items:center; overflow:hidden;
  }
  .topbar b { font-size: 15px; }
  .hamburger {
    margin-left: auto; width: 42px; height: 42px; border-radius: 10px;
    border: 1px solid var(--stroke-strong); background: var(--surface-solid);
    font-size: 20px; cursor: pointer; display:grid; place-items:center;
  }

  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0; width: 82%; max-width: 300px;
    z-index: 50; transform: translateX(-105%); transition: transform .25s ease;
    box-shadow: var(--shadow-lg); height: 100vh;
  }
  body.nav-open .sidebar { transform: translateX(0); }
  body.nav-open .scrim {
    display: block; position: fixed; inset: 0; z-index: 40;
    background: rgba(0,0,0,.4);
  }

  .main { height: auto; overflow: visible; }
  .content { padding: 18px 16px 60px; }
  .grid.cols-4, .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; }
  .form-row, .form-row.cols-3 { grid-template-columns: 1fr; }
  .page-head { align-items: stretch; }
  .page-head h1 { font-size: 22px; }
  .page-head .btn-row { width: 100%; }
  .page-head .btn-row .btn { flex: 1 1 auto; justify-content: center; }
  table.data { font-size: 13px; }

  /* Inputs + boton que en desktop van en linea, en celular se apilan */
  .inline-nowrap { flex-wrap: wrap; }
  .inline-nowrap > input,
  .inline-nowrap > select { width: 100%; flex: 1 1 100%; }
  .inline-nowrap > .btn { flex: 1 1 auto; }

  /* Formularios de filtro/busqueda: botones a lo ancho */
  form.form-row .btn-row { width: 100%; }
  form.form-row .btn-row .btn { flex: 1 1 auto; }

  /* ---- Tablas de listado -> tarjetas apiladas ---- */
  table.data.responsive { min-width: 0; width: 100%; }
  table.data.responsive thead { display: none; }
  table.data.responsive tbody,
  table.data.responsive tr,
  table.data.responsive td { display: block; width: 100%; }
  table.data.responsive tr {
    border: 1px solid var(--stroke); border-radius: 10px;
    margin-bottom: 12px; padding: 4px 2px; background: var(--surface-solid);
  }
  table.data.responsive tr:hover { background: var(--surface-solid); }
  table.data.responsive td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    text-align: right; padding: 9px 14px; border: none;
    border-bottom: 1px solid var(--stroke);
  }
  table.data.responsive tr td:last-child { border-bottom: none; }
  table.data.responsive td::before {
    content: attr(data-label); font-weight: 600; color: var(--text-soft);
    text-align: left; flex: 0 0 42%; font-size: 12px;
  }
  /* Celdas de acciones o con formularios: ocupan todo el ancho */
  table.data.responsive td.actions,
  table.data.responsive td.cell-full { text-align: left; }
  table.data.responsive td.actions::before,
  table.data.responsive td.cell-full::before { display: none; }
  table.data.responsive td.actions { justify-content: stretch; }
  table.data.responsive td.actions .btn { flex: 1 1 auto; }
  table.data.responsive td.cell-full form,
  table.data.responsive td.cell-full .btn-row { width: 100%; }
  /* Fila de estado vacio ("Sin registros") sin label */
  table.data.responsive td[colspan]::before { display: none; }
  table.data.responsive td[colspan] { justify-content: center; color: var(--text-faint); }
}

/* =========================================================
   MODO WEB APP (roles veterinario y protectora)
   App-bar superior + navegacion inferior, botones grandes.
   ========================================================= */
body.appmode {
  background: var(--bg-rail);
  padding: 0; margin: 0;
}

/* --- Barra superior --- */
.appbar {
  position: fixed; top: 0; left: 0; right: 0; height: 56px; z-index: 50;
  display: flex; align-items: center; gap: 12px; padding: 0 14px;
  background: #fff; border-bottom: 1px solid var(--stroke);
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}
.appbar-logo { width: 36px; height: 36px; border-radius: 9px; overflow: hidden;
  border: 1px solid var(--stroke); background:#fff; flex:0 0 auto; display:grid; place-items:center; }
.appbar-logo img { width: 100%; height: 100%; object-fit: contain; }
.appbar-title { font-size: 18px; font-weight: 650; flex: 1; letter-spacing: -.01em;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar-btn { width: 42px; height: 42px; border-radius: 10px; flex:0 0 auto;
  display: grid; place-items: center; color: var(--text-soft); font-size: 18px;
  border: 1px solid var(--stroke); background: #fff; }
.appbar-btn:hover { background: var(--orange-tint); color: var(--orange-700); text-decoration: none; }

/* --- Contenido --- */
.app-main { padding-top: 56px; padding-bottom: 82px; min-height: 100vh; }
.app-content { max-width: 620px; margin: 0 auto; padding: 18px 16px 24px; }

/* Titulo de pagina ya va en la barra: evitar duplicado */
.appmode .page-head { display: block; margin-bottom: 16px; }
.appmode .page-head h1 { display: none; }
.appmode .page-head p { margin: 0 0 12px; }
.appmode .page-head .btn-row { width: 100%; }
.appmode .page-head .btn-row .btn { flex: 1 1 auto; justify-content: center; }
.appmode .page-head > a.btn { width: 100%; justify-content: center; }

/* Tarjetas y controles mas grandes / tactiles */
.appmode .card { padding: 16px; border-radius: 14px; }
.appmode .card + .card { margin-top: 14px; }
.appmode .btn { padding: 13px 18px; font-size: 15px; border-radius: 10px; }
.appmode .btn-sm { padding: 9px 14px; font-size: 14px; }
.appmode input, .appmode select, .appmode textarea { padding: 12px 14px; font-size: 16px; border-radius: 10px; }
.appmode .grid.cols-2, .appmode .grid.cols-3, .appmode .grid.cols-4 { grid-template-columns: 1fr; }
.appmode .form-row, .appmode .form-row.cols-3 { grid-template-columns: 1fr; }
.appmode .stat .value { font-size: 30px; }

/* Botones grandes de accion (home de la app) */
.appmode .btn-primary { box-shadow: 0 4px 14px var(--orange-glow); }

/* Filas input+boton apiladas en la app */
.appmode .inline-nowrap { flex-wrap: wrap; }
.appmode .inline-nowrap > input, .appmode .inline-nowrap > select { width: 100%; flex: 1 1 100%; }
.appmode .inline-nowrap > .btn { flex: 1 1 auto; }

/* Tablas de listado -> tarjetas (siempre, no solo en celular) */
.appmode table.data.responsive { min-width: 0; width: 100%; }
.appmode table.data.responsive thead { display: none; }
.appmode table.data.responsive tbody,
.appmode table.data.responsive tr,
.appmode table.data.responsive td { display: block; width: 100%; }
.appmode table.data.responsive tr {
  border: 1px solid var(--stroke); border-radius: 12px;
  margin-bottom: 12px; padding: 4px 2px; background: #fff;
}
.appmode table.data.responsive tr:hover { background: #fff; }
.appmode table.data.responsive td {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  text-align: right; padding: 10px 14px; border: none; border-bottom: 1px solid var(--stroke);
}
.appmode table.data.responsive tr td:last-child { border-bottom: none; }
.appmode table.data.responsive td::before {
  content: attr(data-label); font-weight: 600; color: var(--text-soft);
  text-align: left; flex: 0 0 42%; font-size: 12px;
}
.appmode table.data.responsive td.actions { justify-content: stretch; text-align: left; }
.appmode table.data.responsive td.actions::before { display: none; }
.appmode table.data.responsive td.actions .btn { flex: 1 1 auto; }
.appmode table.data.responsive td[colspan]::before { display: none; }
.appmode table.data.responsive td[colspan] { justify-content: center; color: var(--text-faint); }

/* --- Navegacion inferior --- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; height: 66px;
  display: flex; justify-content: space-around; align-items: center;
  background: #fff; border-top: 1px solid var(--stroke);
  box-shadow: 0 -1px 6px rgba(0,0,0,.06); padding: 4px 4px env(safe-area-inset-bottom, 4px);
}
.bottomnav a {
  flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 3px;
  color: var(--text-faint); font-size: 11px; font-weight: 600; padding: 6px 2px;
  text-decoration: none; border-radius: 10px; min-width: 0;
}
.bottomnav a .bn-ico { font-size: 19px; line-height: 1; }
.bottomnav a .bn-lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.bottomnav a.active { color: var(--orange-700); }
.bottomnav a:hover { color: var(--orange-700); text-decoration: none; }

/* Boton central destacado (Nueva castracion) */
.bottomnav a.bn-cta { color: #fff; }
.bottomnav a.bn-cta .bn-ico {
  width: 46px; height: 46px; margin-top: -20px; border-radius: 50%;
  background: linear-gradient(135deg, var(--orange), var(--orange-700));
  color: #fff; display: grid; place-items: center; font-size: 20px;
  box-shadow: 0 4px 12px var(--orange-glow); border: 3px solid #fff;
}
.bottomnav a.bn-cta .bn-lbl { color: var(--orange-700); }

/* En pantallas anchas, centrar la app como un telefono */
@media (min-width: 760px) {
  .appbar { max-width: 620px; left: 50%; transform: translateX(-50%); border-radius: 0 0 14px 14px; }
  .bottomnav { max-width: 620px; left: 50%; transform: translateX(-50%); border-radius: 14px 14px 0 0; }
}
