/**
 * VITACARE — UI compacta staff (admin / supervisor / ops / profesional)
 * Mobile-first · responsive · lista para PWA
 * No altera datos ni lógica: solo presentación.
 */

/* ── Base staff shell ───────────────────────────────────────── */
body.staff-app {
  --staff-gap: 0.55rem;
  --staff-pad: 0.7rem 0.8rem;
  --staff-radius: 12px;
  --staff-btn-h: 34px;
  --staff-btn-h-touch: 40px;
  --staff-font: 0.84rem;
  --staff-table: 0.78rem;
  -webkit-tap-highlight-color: rgba(10, 61, 98, 0.12);
  overscroll-behavior-y: contain;
}

body.staff-app .container {
  width: min(1140px, calc(100% - 1.1rem));
}

/* Safe areas (notch / home indicator) */
body.staff-app {
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
}

/* ── Page hero compact ──────────────────────────────────────── */
body.staff-app .page-hero {
  padding: 0.7rem 0 0.65rem;
  margin-bottom: 0;
}
body.staff-app .page-hero h1 {
  font-size: clamp(1.15rem, 4.2vw, 1.4rem);
  margin: 0.1rem 0 0.15rem;
  line-height: 1.2;
}
body.staff-app .page-hero p {
  font-size: 0.82rem;
  line-height: 1.35;
  margin: 0;
  max-width: 42rem;
}
body.staff-app .breadcrumb {
  font-size: 0.72rem;
  margin-bottom: 0.15rem;
}
body.staff-app .staff-top {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.55rem;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0;
}
body.staff-app .staff-top > div:last-child,
body.staff-app .staff-top > div:has(.btn) {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

/* ── Sections ───────────────────────────────────────────────── */
body.staff-app .section {
  padding: 0.75rem 0 1.35rem;
}
body.staff-app .section-head {
  margin-bottom: 0.75rem;
}
body.staff-app .section-head h2 {
  font-size: 1.05rem;
}

/* ── Cards ──────────────────────────────────────────────────── */
body.staff-app .card {
  padding: var(--staff-pad);
  border-radius: var(--staff-radius);
  margin-bottom: 0;
}
body.staff-app .card h2,
body.staff-app .card h3 {
  font-size: 0.95rem;
  margin: 0 0 0.45rem;
  line-height: 1.25;
}
body.staff-app .card > p {
  font-size: 0.82rem;
  line-height: 1.35;
  margin: 0 0 0.45rem;
}
body.staff-app .note-info,
body.staff-app .note-clinical,
body.staff-app .future-note {
  font-size: 0.76rem;
  padding: 0.45rem 0.6rem;
  margin: 0.4rem 0;
  line-height: 1.35;
  border-radius: 10px;
}

/* ── Metrics / KPIs ─────────────────────────────────────────── */
body.staff-app .metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.45rem;
  margin-bottom: 0.75rem !important;
}
body.staff-app .metric {
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  min-height: 0;
}
body.staff-app .metric .m-label {
  font-size: 0.68rem;
  margin-bottom: 0.15rem;
  line-height: 1.2;
}
body.staff-app .metric .m-value {
  font-size: clamp(1rem, 4vw, 1.25rem);
  line-height: 1.15;
}
body.staff-app .metric .hint {
  font-size: 0.65rem !important;
  margin-top: 0.2rem !important;
}
body.staff-app .kpi-row {
  gap: 0.45rem;
  margin-bottom: 0.65rem;
}
body.staff-app .kpi {
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
}
body.staff-app .kpi .label {
  font-size: 0.68rem;
}
body.staff-app .kpi .value {
  font-size: 1.1rem;
}

/* ── Grids ──────────────────────────────────────────────────── */
body.staff-app .grid-2 {
  gap: 0.65rem;
  margin-bottom: 0.75rem !important;
}
body.staff-app .grid-3,
body.staff-app .grid-4 {
  gap: 0.55rem;
}

/* ── Buttons compact ────────────────────────────────────────── */
body.staff-app .btn,
body.staff-app .btn-sm,
body.staff-app button.btn,
body.staff-app a.btn {
  min-height: var(--staff-btn-h-touch);
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  border-radius: 9px;
  line-height: 1.2;
  gap: 0.3rem;
}
body.staff-app .btn-block {
  width: 100%;
  justify-content: center;
}
body.staff-app .staff-top .btn,
body.staff-app .staff-top a.btn {
  min-height: var(--staff-btn-h);
  padding: 0.3rem 0.55rem;
  font-size: 0.74rem;
}
body.staff-app .btn-danger {
  min-height: var(--staff-btn-h-touch);
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  border-radius: 9px;
}
/* Mini actions in tables */
body.staff-app .table-actions .btn,
body.staff-app .table-actions a.btn,
body.staff-app .table-actions .btn-danger,
body.staff-app .row-actions .btn,
body.staff-app .btn-mini {
  min-height: 28px !important;
  height: auto;
  padding: 0.22rem 0.42rem !important;
  font-size: 0.68rem !important;
  border-radius: 6px !important;
}

/* ── Forms compact ──────────────────────────────────────────── */
body.staff-app .form-grid {
  gap: 0.5rem;
}
body.staff-app label {
  font-size: 0.76rem;
  gap: 0.18rem;
  font-weight: 700;
}
body.staff-app input,
body.staff-app select,
body.staff-app textarea {
  min-height: 36px;
  padding: 0.35rem 0.5rem;
  font-size: 0.84rem;
  border-radius: 8px;
}
body.staff-app textarea {
  min-height: 64px;
}
body.staff-app .form-row-2 {
  gap: 0.5rem;
}
body.staff-app .phone-wa-label {
  font-size: 0.76rem;
}
body.staff-app .phone-wa-row select,
body.staff-app .phone-wa-row input {
  min-height: 36px;
}
body.staff-app .perm-list {
  font-size: 0.78rem;
  line-height: 1.35;
  margin: 0.25rem 0 0;
  padding-left: 1rem;
}
body.staff-app .perm-list li {
  margin-bottom: 0.2rem;
}

/* ── Tables mobile-first ────────────────────────────────────── */
body.staff-app .table-wrap {
  border-radius: 12px;
  margin: 0;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}
body.staff-app table.data {
  font-size: var(--staff-table);
  min-width: 100%;
}
body.staff-app table.data th,
body.staff-app table.data td {
  padding: 0.35rem 0.4rem;
  line-height: 1.25;
  vertical-align: middle;
}
body.staff-app table.data th {
  font-size: 0.68rem;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
body.staff-app table.data code {
  font-size: 0.74rem;
}
body.staff-app table.data select,
body.staff-app table.data input {
  min-height: 30px;
  font-size: 0.74rem;
  padding: 0.15rem 0.3rem;
  border-radius: 6px;
  max-width: 100%;
}
body.staff-app .status {
  font-size: 0.65rem;
  padding: 0.12rem 0.35rem;
  white-space: nowrap;
}

/* ── Tabs ───────────────────────────────────────────────────── */
body.staff-app .tabs {
  gap: 0.3rem;
  margin-bottom: 0.7rem;
}
body.staff-app .tab {
  min-height: 34px;
  padding: 0.3rem 0.65rem;
  font-size: 0.76rem;
  border-radius: 999px;
}

/* ── Map ────────────────────────────────────────────────────── */
body.staff-app .map-box {
  height: 200px;
  min-height: 180px;
  border-radius: 12px;
}

/* ── Lists / docs ───────────────────────────────────────────── */
body.staff-app .docs-list {
  gap: 0.4rem;
}
body.staff-app .doc-card {
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  gap: 0.2rem;
}
body.staff-app .doc-card .doc-type {
  font-size: 0.65rem;
}
body.staff-app .doc-title-btn {
  font-size: 0.9rem !important;
}

/* ── Footer less air on staff ───────────────────────────────── */
body.staff-app .site-footer {
  margin-top: 1rem;
  padding-top: 1rem;
  padding-bottom: calc(1.25rem + env(safe-area-inset-bottom, 0px));
  font-size: 0.8rem;
}

/* ── Bottom spacing for mobile chrome / future PWA ──────────── */
body.staff-app {
  padding-bottom: env(safe-area-inset-bottom, 0);
}

/* ── Touch targets & density on small phones ────────────────── */
@media (max-width: 480px) {
  body.staff-app .container {
    width: calc(100% - 0.85rem);
  }
  body.staff-app .page-hero {
    padding: 0.55rem 0 0.5rem;
  }
  body.staff-app .section {
    padding: 0.55rem 0 1.1rem;
  }
  body.staff-app .metrics {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.35rem;
  }
  body.staff-app .metric {
    padding: 0.45rem 0.5rem;
  }
  body.staff-app .staff-top {
    flex-direction: column;
    align-items: stretch;
  }
  body.staff-app .staff-top > div:last-child,
  body.staff-app .staff-top > div:has(a.btn),
  body.staff-app .staff-top {
    width: 100%;
  }
  body.staff-app .staff-top a.btn,
  body.staff-app .staff-top .btn {
    flex: 1 1 auto;
    justify-content: center;
  }
  body.staff-app .grid-2 {
    grid-template-columns: 1fr !important;
  }
  body.staff-app .form-row-2 {
    grid-template-columns: 1fr !important;
  }
  /* Horizontal action chips under rows on very small screens */
  body.staff-app .table-actions,
  body.staff-app .row-actions {
    max-width: 100%;
    flex-wrap: wrap;
  }
}

/* ── Tablet+ denser multi-column metrics ────────────────────── */
@media (min-width: 640px) {
  body.staff-app .metrics {
    grid-template-columns: repeat(3, 1fr);
  }
  body.staff-app .form-row-2 {
    grid-template-columns: 1fr 1fr;
  }
}

@media (min-width: 768px) {
  body.staff-app {
    --staff-btn-h: 32px;
    --staff-btn-h-touch: 34px;
    --staff-pad: 0.75rem 0.9rem;
  }
  body.staff-app .container {
    width: min(1140px, calc(100% - 1.5rem));
  }
  body.staff-app .metrics {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
  }
  body.staff-app .staff-top {
    flex-direction: row;
    align-items: center;
  }
  body.staff-app .page-hero {
    padding: 0.85rem 0 0.7rem;
  }
  body.staff-app .section {
    padding: 0.85rem 0 1.5rem;
  }
  body.staff-app .grid-2 {
    grid-template-columns: 1fr 1fr;
  }
  body.staff-app .btn,
  body.staff-app .btn-sm,
  body.staff-app a.btn {
    min-height: var(--staff-btn-h-touch);
  }
}

@media (min-width: 1024px) {
  body.staff-app .metrics {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  }
  body.staff-app table.data {
    font-size: 0.8rem;
  }
}

/* ── PWA standalone (when installed as app) ─────────────────── */
@media (display-mode: standalone) {
  body.staff-app .page-hero {
    padding-top: max(0.7rem, env(safe-area-inset-top, 0px));
  }
  body.staff-app .site-footer {
    padding-bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
  }
}

/* ── Prefer reduced motion ──────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  body.staff-app * {
    scroll-behavior: auto !important;
  }
}

/* ── Utility: sticky filter bars on staff pages ─────────────── */
body.staff-app .staff-sticky-bar,
body.staff-app .users-toolbar,
body.staff-app .ing-toolbar,
body.staff-app .audit-toolbar {
  position: sticky;
  top: calc(var(--header-h, 64px) + env(safe-area-inset-top, 0px));
  z-index: 20;
  background: rgba(247, 250, 252, 0.92);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 0.4rem 0;
  margin-bottom: 0.55rem;
  gap: 0.4rem;
}

body.staff-app .users-toolbar input,
body.staff-app .users-toolbar select,
body.staff-app .ing-toolbar select,
body.staff-app .audit-toolbar input,
body.staff-app .audit-toolbar select {
  min-height: 34px !important;
  font-size: 0.8rem !important;
  border-radius: 8px !important;
}

/* ── Admin index audit card ─────────────────────────────────── */
body.staff-app #audit-card {
  padding: 0.7rem 0.85rem !important;
  margin-bottom: 0.75rem !important;
  border-radius: 14px !important;
}
body.staff-app #audit-card h3 {
  font-size: 0.98rem !important;
}
body.staff-app #audit-card p {
  font-size: 0.8rem !important;
}
body.staff-app #audit-card-count {
  font-size: 1.45rem !important;
}

/* ── Hide public floaters noise on staff if present ─────────── */
body.staff-app .floaters,
body.staff-app .cart-mobile-bar,
body.staff-app .ai-panel {
  display: none !important;
}

/* Bottom nav: keep for PWA mobile but more compact */
body.staff-app .bottom-nav {
  font-size: 0.65rem;
}
body.staff-app .bottom-nav a {
  min-height: 48px;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
