/* ============================================================================
   ESPERALOYA CONTROL EMPRESARIAL — base.css  v3.0
   Variables, reset y estructura general
   ============================================================================ */

:root{
 
  /* ── Paleta principal ───────────────────────────────────────────────── */
  --navy:       #0D1B2A;
  --navy-2:     #13233A;
  --blue:       #2563EB;
  --blue-mid:   #3B82F6;
  --blue-light: #EFF4FF;
  --blue-pale:  #DBEAFE;

  --green:       #10B981;
  --green-light: #D1FAE5;
  --green-pale:  #ECFDF5;

  --red:        #EF4444;
  --red-light:  #FEE2E2;

  --orange:       #F59E0B;
  --orange-light: #FEF3C7;

  --purple:       #8B5CF6;
  --purple-light: #EDE9FE;

  --pink:       #EC4899;
  --pink-light: #FCE7F3;

  /* ── Grises ─────────────────────────────────────────────────────────── */
  --white:  #FFFFFF;
  --off:    #F4F6F9;
  --g50:    #F8FAFC;
  --g100:   #F1F5F9;
  --g200:   #E2E8F0;
  --g300:   #CBD5E1;
  --g400:   #94A3B8;
  --g500:   #64748B;
  --g600:   #475569;
  --g700:   #334155;
  --g800:   #1E293B;

  /* ── Radios ──────────────────────────────────────────────────────────── */
  --r-xs:  6px;
  --r-sm:  10px;
  --r:     14px;
  --r-md:  18px;
  --r-lg:  22px;
  --r-xl:  28px;

  /* Alias legacy (no romper JS que usa --radius) */
  --radius-sm: var(--r-sm);
  --radius:    var(--r);
  --radius-lg: var(--r-lg);

  /* ── Sombras ──────────────────────────────────────────────────────────── */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow:    0 4px 12px rgba(15,23,42,.07), 0 1px 3px rgba(15,23,42,.04);
  --shadow-md: 0 8px 24px rgba(15,23,42,.09), 0 2px 6px rgba(15,23,42,.05);
  --shadow-lg: 0 16px 48px rgba(15,23,42,.12), 0 4px 12px rgba(15,23,42,.06);

  /* Alias legacy */
  --shadow-sm: var(--shadow-sm);

  /* ── Transiciones ─────────────────────────────────────────────────────── */
  --t-fast:   0.15s ease;
  --t:        0.2s ease;
  --t-slow:   0.3s ease;

  /* ── Tipografía ──────────────────────────────────────────────────────── */
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI",
          Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  background: var(--off);
  font-family: var(--font);
  color: var(--g700);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
button { font-family: inherit; cursor: pointer; }
a { color: var(--blue); text-decoration: none; }

/* ── Inputs / Selects base ──────────────────────────────────────────────── */
input, select, textarea {
  width: 100%;
  height: 44px;
  border: 1.5px solid var(--g200);
  border-radius: var(--r-sm);
  padding: 0 14px;
  font-size: 14px;
  font-family: var(--font);
  background: var(--white);
  color: var(--g700);
  transition: border-color var(--t), box-shadow var(--t);
  appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}
input::placeholder, textarea::placeholder { color: var(--g300); }
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* ── Icons SVG ──────────────────────────────────────────────────────────── */
.icon-svg {
  width: 1em; height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
  flex-shrink: 0;
}
#topbar .brand-icon .icon-svg { width: 18px; height: 18px; }
#btn-menu-toggle .icon-svg    { width: 22px; height: 22px; }
#login-brand .brand-icon .icon-svg { width: 20px; height: 20px; }
.icon-btn .icon-svg    { width: 18px; height: 18px; }
.kpi-icon .icon-svg    { width: 18px; height: 18px; }
.field-icon .icon-svg  { width: 17px; height: 17px; }
.bn-item .icon-svg     { width: 22px; height: 22px; }
.nav-item .icon-svg    { width: 19px; height: 19px; }
.btn-submit .icon-svg  { width: 18px; height: 18px; }
.btn-outline .icon-svg, .btn-print .icon-svg { width: 16px; height: 16px; }
.summary-chip .chip-value .icon-svg { width: 14px; height: 14px; }
.ver-todas-link .icon-svg  { width: 16px; height: 16px; }
.filter-card h3 .icon-svg  { width: 17px; height: 17px; }
.dash-card h3 .icon-svg    { width: 17px; height: 17px; }

/* ── App shell ──────────────────────────────────────────────────────────── */
#app { display: none; min-height: 100vh; padding-bottom: 88px; }

/* ── Topbar ─────────────────────────────────────────────────────────────── */
#topbar {
  position: sticky; top: 0; z-index: 30;
  background: var(--navy);
  color: var(--white);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 18px;
  height: 58px;
}
#topbar .brand {
  display: flex; align-items: center; gap: 10px;
  font-size: 18px; font-weight: 700; letter-spacing: -.3px;
}
#topbar .brand-icon {
  width: 34px; height: 34px; border-radius: 10px;
  background: #BA1173;
  display: flex; align-items: center; justify-content: center;
}
#btn-menu-toggle {
  background: none; border: none;
  color: rgba(255,255,255,.8);
  width: 40px; height: 40px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  transition: background var(--t);
}
#btn-menu-toggle:hover { background: rgba(255,255,255,.08); }

/* Botón búsqueda en topbar */
.search-trigger {
  cursor: pointer;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  transition: background var(--t);
}
.search-trigger:hover { background: rgba(255,255,255,.08); }

/* ── Sidebar / Drawer ───────────────────────────────────────────────────── */
#sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(13,27,42,.5);
  z-index: 40; backdrop-filter: blur(2px);
}
#sidebar-overlay.show { display: block; }

#sidebar {
  position: fixed; top: 0; right: 0; bottom: 0; width: 280px;
  background: var(--white); z-index: 50;
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4,0,.2,1);
  display: flex; flex-direction: column; padding: 24px 0;
  box-shadow: var(--shadow-lg);
}
#sidebar.open { transform: translateX(0); }
#sidebar .drawer-header {
  padding: 0 20px 20px;
  border-bottom: 1px solid var(--g100);
  margin-bottom: 10px;
}
#sidebar .drawer-header strong { display: block; font-size: 16px; font-weight: 700; color: var(--navy); }
#sidebar .drawer-header span   { font-size: 12px; color: var(--g400); margin-top: 2px; display: block; }

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px;
  color: var(--g600); font-size: 14px; font-weight: 500;
  border: none; background: none; width: 100%; text-align: left;
  border-radius: 0;
  transition: background var(--t), color var(--t);
  cursor: pointer;
}
.nav-item:hover { background: var(--g50); color: var(--g800); }
.nav-item.active {
  background: var(--blue-light);
  color: var(--blue);
  font-weight: 600;
}

#sidebar .spacer { flex: 1; }
#sidebar .user-box {
  padding: 16px 20px;
  border-top: 1px solid var(--g100);
  font-size: 12px; color: var(--g400);
}
#sidebar .user-box strong {
  color: var(--navy);
  display: block; font-size: 14px; font-weight: 600;
  margin-bottom: 2px;
}
#sidebar .user-box small {
  display: block; font-size: 11px; color: var(--g400);
  margin-bottom: 10px;
}
#btn-logout {
  background: none; border: none;
  color: var(--red); font-size: 13px; font-weight: 600;
  padding: 0; cursor: pointer;
  transition: opacity var(--t);
}
#btn-logout:hover { opacity: .7; }

/* ── Main content ───────────────────────────────────────────────────────── */
#main { padding: 20px 16px 12px; max-width: 100%; margin: 0 auto; }

.page-header,
.mod-screen-header {
  display: flex; align-items: center;
  justify-content: space-between;
  margin-bottom: 22px; gap: 16px;
}
.page-header-text h1,
.mod-screen-header__text h1 {
  font-size: 26px; margin: 0 0 3px;
  color: var(--navy); font-weight: 800;
  letter-spacing: -.6px;
}
.page-header-text p,
.mod-screen-header__text p { font-size: 13px; color: var(--g400); margin: 0; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px;
  border: 1.5px solid var(--g200);
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  color: var(--blue); flex-shrink: 0;
  transition: box-shadow var(--t), border-color var(--t);
}
.icon-btn:hover { box-shadow: var(--shadow-sm); border-color: var(--blue); }

/* ── Bottom nav ─────────────────────────────────────────────────────────── */
#bottomnav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--g200);
  display: flex;
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.bn-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; gap: 3px;
  background: none; border: none;
  color: var(--g400); font-size: 10px; font-weight: 500;
  padding: 4px 0;
  transition: color var(--t);
}
.bn-item.active { color: var(--blue); }

/* ── Screen switching ───────────────────────────────────────────────────── */
.screen { display: none; }
.screen.active { display: block; }

/* ── Utilities ──────────────────────────────────────────────────────────── */
.text-right   { text-align: right; }
.text-green   { color: var(--green); font-weight: 600; }
.text-red     { color: var(--red); font-weight: 600; }
.confirm-msg {
  text-align: center; font-size: 13px;
  color: var(--green); background: var(--green-light);
  border-radius: var(--r-sm); padding: 12px;
  margin-top: 14px; display: none; font-weight: 500;
  animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ── Desktop ────────────────────────────────────────────────────────────── */
@media (min-width: 901px) {
  #main { max-width: 1160px; }
  #app.is-visible { padding-bottom: 0; }
  #bottomnav { display: none; }
  #sidebar {
    position: sticky; top: 0; height: 100vh;
    transform: none; width: 240px;
    box-shadow: none; border-right: 1px solid var(--g200);
  }
  #sidebar-overlay { display: none !important; }
  #btn-menu-toggle  { display: none; }
  body { display: flex; }
  #app.is-visible { display: flex; width: 100%; }
  /* La columna derecha (topbar + main) también es flex column */
  #app.is-visible > div { display: flex; flex-direction: column; }
  #main { flex: 1; padding: 28px 36px; }
}
