/* ═══════════════════════════════════════════════════════════
   SICO v2 — Design System
   sico.granjareal.com
═══════════════════════════════════════════════════════════ */

/* ── Variables ─────────────────────────────────────────── */
:root {
  --red:      #C0392B;
  --red-d:    #962d22;
  --red-l:    #FDECEA;
  --green:    #1E7E34;
  --green-l:  #EAF3DE;
  --amber:    #856404;
  --amber-l:  #FFF3CD;
  --blue:     #185FA5;
  --blue-l:   #E6F1FB;

  --bg:       #F5F4F1;
  --surface:  #FFFFFF;
  --border:   #E4E2DC;
  --border-s: #F0EEE8;

  --text-1:   #1A1A1A;
  --text-2:   #555555;
  --text-3:   #888780;
  --text-4:   #B4B2A9;

  --sidebar-w:    240px;
  --sidebar-bg:   #141412;
  --sidebar-text: rgba(255,255,255,.75);
  --sidebar-hover: rgba(255,255,255,.07);
  --sidebar-active: rgba(192,57,43,.85);

  --topbar-h:  58px;
  --radius:    10px;
  --radius-sm: 6px;
  --shadow:    0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);

  --font: 'Inter', 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-head: 'Oswald', var(--font);
}

/* ── Reset ──────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text-1);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
}

/* ── Shell ──────────────────────────────────────────────── */
.shell {
  display: flex;
  min-height: 100dvh;
}

/* ── Sidebar ────────────────────────────────────────────── */
.sb {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
  transition: transform .25s ease;
}
.sb::-webkit-scrollbar { width: 4px; }
.sb::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

/* Logo área */
.sb-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.sb-logo-mark {
  width: 34px; height: 34px;
  background: var(--red);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sb-logo-mark svg { width: 20px; height: 20px; }
.sb-app-name { font-family: var(--font-head); font-size: 17px; font-weight: 700; color: #fff; letter-spacing: .5px; }
.sb-app-sub  { font-size: 9px; color: var(--text-3); letter-spacing: .5px; text-transform: uppercase; margin-top: 1px; }

/* Nav groups */
.sb-group { padding: 8px 0; }
.sb-group + .sb-group { border-top: 1px solid rgba(255,255,255,.06); }
.sb-label {
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: .8px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 10px 18px 5px;
}
.sb-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 18px;
  color: var(--sidebar-text);
  font-size: 13px;
  border-radius: 0;
  transition: background .12s, color .12s;
  position: relative;
  white-space: nowrap;
}
.sb-link:hover { background: var(--sidebar-hover); color: #fff; }
.sb-link.active {
  background: var(--sidebar-active);
  color: #fff;
}
.sb-link.active::before {
  content: '';
  position: absolute;
  left: 0; top: 4px; bottom: 4px;
  width: 3px;
  background: #fff;
  border-radius: 0 3px 3px 0;
}
.sb-link svg { width: 17px; height: 17px; flex-shrink: 0; opacity: .7; }
.sb-link.active svg, .sb-link:hover svg { opacity: 1; }
.sb-link span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; }

/* Badge */
.nb {
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
}

/* Usuario en sidebar */
.sb-user {
  margin-top: auto;
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.sb-av {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sb-uname { font-size: 12px; font-weight: 500; color: #fff; }
.sb-urole { font-size: 10px; color: var(--text-3); }
.sb-logout {
  margin-left: auto;
  color: var(--text-3);
  padding: 4px;
  border-radius: 5px;
  transition: color .12s, background .12s;
}
.sb-logout:hover { color: #fff; background: rgba(255,255,255,.08); }
.sb-logout svg { width: 16px; height: 16px; }

/* ── Overlay móvil ──────────────────────────────────────── */
.ov {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 40;
  backdrop-filter: blur(2px);
}

/* ── Main ───────────────────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100dvh;
}

/* ── Topbar ─────────────────────────────────────────────── */
.tb {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 30;
}
.tb-menu {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--text-2);
  border-radius: var(--radius-sm);
}
.tb-menu svg { width: 20px; height: 20px; display: block; }
.tb-menu:hover { background: var(--bg); }
.tb-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-1);
  flex: 1;
}
.tb-date { font-size: 12px; color: var(--text-3); }
.tb-actions { display: flex; align-items: center; gap: 8px; }
.tb-av {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
}

/* ── Contenido ──────────────────────────────────────────── */
.cnt {
  flex: 1;
  padding: 24px 24px;
  max-width: 1400px;
  width: 100%;
}

/* ── Botones ────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all .15s;
  white-space: nowrap;
}
.btn-primary   { background: var(--red);   color: #fff; border-color: var(--red-d); }
.btn-primary:hover { background: var(--red-d); }
.btn-secondary { background: var(--surface); color: var(--text-1); border-color: var(--border); }
.btn-secondary:hover { background: var(--bg); }
.btn-ghost { background: none; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover { background: var(--bg); }
.btn-sm { padding: 5px 11px; font-size: 12px; }
.btn-lg { padding: 11px 22px; font-size: 14px; }
.btn svg { width: 15px; height: 15px; }

/* ── Cards ──────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-s);
  gap: 10px;
}
.card-title { font-size: 13px; font-weight: 600; color: var(--text-1); }
.card-body { padding: 16px 18px; }

/* ── KPIs ───────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: var(--shadow);
}
.kpi-label  { font-size: 11px; color: var(--text-3); text-transform: uppercase; letter-spacing: .4px; }
.kpi-value  { font-family: var(--font-head); font-size: 26px; font-weight: 700; color: var(--text-1); margin-top: 4px; }
.kpi-sub    { font-size: 11px; color: var(--text-3); margin-top: 2px; }
.kpi.kpi-red    { border-left: 3px solid var(--red);   }
.kpi.kpi-green  { border-left: 3px solid var(--green); }
.kpi.kpi-amber  { border-left: 3px solid #F59E0B;      }
.kpi.kpi-blue   { border-left: 3px solid var(--blue);  }

/* ── Grid layouts ───────────────────────────────────────── */
.g2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.g3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.g4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ── Tabla ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { background: var(--bg); }
th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: .4px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: 11px 14px;
  font-size: 13px;
  border-bottom: 1px solid var(--border-s);
  color: var(--text-2);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 20px;
}
.badge-red    { background: #FDECEA; color: #A32D2D; }
.badge-green  { background: #EAF3DE; color: #1E7E34; }
.badge-amber  { background: #FFF3CD; color: #856404; }
.badge-blue   { background: #E6F1FB; color: #0C447C; }
.badge-gray   { background: var(--bg); color: var(--text-3); }

/* ── Formularios ────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px;
}
.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-1);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(192,57,43,.1);
}
.form-textarea { resize: vertical; min-height: 90px; }

/* ── Flash ──────────────────────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.flash-ok    { background: #EAF3DE; color: #1E7E34; border-left: 3px solid #1E7E34; }
.flash-error { background: #FDECEA; color: #A32D2D; border-left: 3px solid #C0392B; }
.flash-warn  { background: #FFF3CD; color: #856404; border-left: 3px solid #F59E0B; }

/* ── Semáforo ───────────────────────────────────────────── */
.sem {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
}
.sem-gray   { background: #E8E7E3; }
.sem-yellow { background: #FEF3C7; }
.sem-green  { background: #D1FAE5; }

/* ── Progress ───────────────────────────────────────────── */
.progress { background: var(--border); border-radius: 10px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 10px; transition: width .3s ease; }

/* ── Divider ────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border-s); margin: 16px 0; }
.spacer-sm { height: 12px; }
.spacer-md { height: 20px; }

/* ════════════════════════════════════════════════════════
   LOGIN
════════════════════════════════════════════════════════ */
.login-shell {
  min-height: 100dvh;
  display: flex;
}

/* Panel izquierdo */
.login-left {
  flex: 1;
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 48px;
  overflow: hidden;
  min-height: 100dvh;
}
.login-bg {
  position: absolute;
  inset: 0;
  background: url('../img/login-bg.jpg') center/cover no-repeat;
  z-index: 0;
}
.login-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    160deg,
    rgba(10,10,10,.55) 0%,
    rgba(10,10,10,.75) 50%,
    rgba(10,10,10,.92) 100%
  );
  z-index: 1;
}
.login-left-content {
  position: relative;
  z-index: 2;
  max-width: 440px;
}

/* Logo placeholder */
.login-logo-wrap {
  margin-bottom: 40px;
}
.login-logo-placeholder {
  display: inline-flex;
  align-items: center;
  gap: 12px;
}
.login-logo-icon {
  width: 48px; height: 48px;
  background: var(--red);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.login-logo-icon svg { width: 28px; height: 28px; }
.login-logo-text-name {
  font-family: var(--font-head);
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
  line-height: 1;
}
.login-logo-text-sub {
  font-size: 10px;
  color: rgba(255,255,255,.55);
  letter-spacing: 1.5px;
  text-transform: uppercase;
  margin-top: 3px;
}

/* Headline */
.login-headline {
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  margin-bottom: 16px;
}
.login-headline em {
  font-style: normal;
  color: var(--red);
}
.login-tagline {
  font-size: 14px;
  color: rgba(255,255,255,.6);
  line-height: 1.6;
  margin-bottom: 40px;
  max-width: 380px;
}

/* Features row */
.login-features {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}
.login-feat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.login-feat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  display: flex; align-items: center; justify-content: center;
}
.login-feat-icon svg { width: 20px; height: 20px; color: var(--red); }
.login-feat-label {
  font-size: 9px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .8px;
  text-transform: uppercase;
}
.login-feat-sub {
  font-size: 10px;
  color: rgba(255,255,255,.45);
  line-height: 1.3;
}

/* Panel derecho */
.login-right {
  width: 460px;
  background: #FAFAF8;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  flex-shrink: 0;
}
.login-right-header {
  display: flex;
  justify-content: flex-end;
  padding: 20px 24px;
}
.login-right-header a {
  font-size: 12px;
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: 5px;
  transition: color .15s;
}
.login-right-header a:hover { color: var(--text-1); }
.login-right-header svg { width: 16px; height: 16px; }

.login-form-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 20px 52px 40px;
}

/* Avatar icon */
.login-avatar-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--red-l);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}
.login-avatar-icon svg { width: 30px; height: 30px; color: var(--red); }

.login-welcome {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-1);
  text-align: center;
  margin-bottom: 6px;
}
.login-sub {
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
  margin-bottom: 32px;
}

/* Campo con ícono */
.input-icon-wrap {
  position: relative;
}
.input-icon-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 17px; height: 17px;
  color: var(--text-4);
  pointer-events: none;
}
.input-icon-wrap input {
  padding-left: 40px;
}
.input-toggle-pw {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-4);
  padding: 2px;
}
.input-toggle-pw:hover { color: var(--text-2); }
.input-toggle-pw svg { width: 17px; height: 17px; display: block; }

/* Olvidaste contraseña */
.login-forgot {
  display: block;
  text-align: right;
  font-size: 12px;
  color: var(--red);
  margin-top: -8px;
  margin-bottom: 20px;
  transition: opacity .15s;
}
.login-forgot:hover { opacity: .75; }

/* Botón de login */
.btn-login {
  width: 100%;
  padding: 13px;
  background: var(--red);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background .15s, transform .1s;
  margin-bottom: 24px;
}
.btn-login:hover { background: var(--red-d); }
.btn-login:active { transform: scale(.99); }
.btn-login svg { width: 18px; height: 18px; }
.btn-login.loading { opacity: .7; pointer-events: none; }

/* Footer del panel derecho */
.login-right-footer {
  padding: 20px 52px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.login-copy {
  font-size: 11px;
  color: var(--text-4);
  line-height: 1.5;
}
.login-brand {
  display: flex;
  align-items: center;
  gap: 7px;
}
.login-brand-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--red);
  font-family: var(--font-head);
}
.login-brand-sub {
  font-size: 9px;
  color: var(--text-4);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-top: 1px;
}

/* Security note */
.login-security {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-4);
  padding: 10px 14px;
  background: var(--border-s);
  border-radius: var(--radius-sm);
  margin-top: 20px;
}
.login-security svg { width: 16px; height: 16px; flex-shrink: 0; }

/* ── Forgot / Reset ─────────────────────────────────────── */
.auth-centered {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px 44px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-md);
}
.auth-icon {
  width: 56px; height: 56px;
  background: var(--red-l);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}
.auth-icon svg { width: 26px; height: 26px; color: var(--red); }
.auth-title { font-size: 20px; font-weight: 700; color: var(--text-1); text-align: center; margin-bottom: 6px; }
.auth-desc  { font-size: 13px; color: var(--text-3); text-align: center; margin-bottom: 28px; line-height: 1.6; }

/* ── Errores ────────────────────────────────────────────── */
.page-404 {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
}
.page-404 h1 { font-size: 80px; font-weight: 700; color: var(--border); line-height: 1; }
.page-404 h2 { font-size: 22px; font-weight: 600; color: var(--text-1); margin: 12px 0 8px; }
.page-404 p  { font-size: 14px; color: var(--text-3); margin-bottom: 24px; }

/* ════════════════════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════════════════════ */
@media (max-width: 1024px) {
  .login-left { display: none; }
  .login-right { width: 100%; }
  .login-form-wrap { padding: 20px 32px 40px; }
  .login-right-footer { padding: 20px 32px; }

  /* Mostrar logo en panel derecho cuando no hay panel izquierdo */
  .login-logo-mobile {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 28px;
  }
}

.login-logo-mobile { display: none; }

@media (max-width: 768px) {
  .sb {
    transform: translateX(-100%);
  }
  .sb.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  .ov { display: block; }
  .ov.show { display: block; }
  .ov:not(.show) { display: none; }

  .main { margin-left: 0; }
  .tb-menu { display: flex; }

  .cnt { padding: 16px; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }

  .login-form-wrap { padding: 16px 24px 32px; }
  .login-right-footer { padding: 16px 24px; flex-direction: column; align-items: flex-start; }
  .login-features { gap: 16px; }
  .auth-box { padding: 32px 24px; }
}

@media (max-width: 480px) {
  .login-form-wrap { padding: 12px 20px 28px; }
  .kpi-grid { grid-template-columns: 1fr; }
  .login-headline { font-size: 26px; }
}
