/* ============================================================
   Caissa CRM — Hoja de estilos principal
   Paleta e identidad basadas en caissa.digital
   (azul eléctrico #2034e8 · ink #1b1d24 · tipografía Nunito)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;500;600;700;800&display=swap');

:root {
  /* Marca Caissa */
  --brand:        #2034e8;   /* azul eléctrico — primario */
  --brand-strong: #1827bd;   /* hover / pressed */
  --brand-light:  #6d79ff;   /* sobre fondos oscuros */
  --brand-soft:   #ebedfd;   /* tinte para fondos / badges */
  --accent-pink:  #cc3366;
  --accent-coral: #ff4f40;

  /* Neutros */
  --ink:        #1b1d24;     /* sidebar / texto más oscuro */
  --ink-raised: #262a38;     /* item activo / hover sidebar */
  --bg:         #f5f6fb;     /* fondo de la app (tinte frío sutil) */
  --surface:    #ffffff;
  --surface-2:  #fafafb;
  --border:     #e9e9f1;
  --border-strong: #dcdce8;
  --text:       #1b1d24;
  --muted:      #5d6070;
  --hint:       #8a8d9c;

  /* Semánticos */
  --primary:    var(--brand);
  --primary-h:  var(--brand-strong);
  --danger:     #dc2626;
  --danger-bg:  #fdecec;
  --success:    #16a34a;
  --success-bg: #e8f6ee;
  --warning:    #b45309;
  --warning-bg: #fbf0dd;
  --info:       var(--brand);
  --info-bg:    var(--brand-soft);

  /* Layout */
  --sidebar-w:  248px;
  --radius:     12px;
  --radius-sm:  9px;
  --radius-pill: 999px;
  --shadow-sm:  0 1px 2px rgba(20,22,45,.04), 0 1px 3px rgba(20,22,45,.05);
  --shadow:     0 1px 3px rgba(20,22,45,.05), 0 12px 28px -12px rgba(20,22,45,.14);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Nunito', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--brand); text-decoration: none; transition: color .15s; }
a:hover { color: var(--brand-strong); text-decoration: none; }

::selection { background: var(--brand-soft); color: var(--brand-strong); }

/* ── Layout ─────────────────────────────────────────── */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--ink);
  color: #c7cad6;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: #34384a; border-radius: 8px; }

.sidebar-logo {
  padding: 1.5rem 1.4rem 1.25rem;
  font-size: 1.3rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -.6px;
}
.sidebar-logo span { color: var(--brand-light); }

.sidebar-nav { flex: 1; padding: .5rem .65rem 1rem; }

.nav-section {
  padding: 1rem .85rem .35rem;
  font-size: .68rem;
  font-weight: 700;
  color: #6a6e82;
  text-transform: uppercase;
  letter-spacing: .09em;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .6rem .85rem;
  margin: .12rem 0;
  border-radius: var(--radius-sm);
  color: #aab0c0;
  font-size: .875rem;
  font-weight: 600;
  transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.055); color: #fff; }
.nav-link.active { background: var(--ink-raised); color: #fff; }
.nav-link.active .icon { color: var(--brand-light); }
.nav-link .icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  flex-shrink: 0;
  color: #888ea3;
  transition: color .15s;
}
.nav-link:hover .icon { color: #c7cad6; }
.nav-link .icon svg { width: 19px; height: 19px; }

.sidebar-footer {
  padding: 1rem 1.4rem;
  border-top: 1px solid rgba(255,255,255,.07);
  font-size: .8rem;
  color: #7a7e92;
}
.sidebar-footer strong { color: #e4e6ee; display: block; font-weight: 700; margin-bottom: .1rem; }
.sidebar-footer span { font-size: .74rem; }
.sidebar-footer a { color: #8a8fa3; font-size: .78rem; display: inline-block; margin-top: .35rem; }
.sidebar-footer a:hover { color: var(--brand-light); }

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

.topbar {
  background: rgba(255,255,255,.85);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
  padding: .95rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar h1 { font-size: 1.2rem; font-weight: 800; color: var(--text); letter-spacing: -.3px; }
.topbar-actions { display: flex; gap: .55rem; align-items: center; }

.page-content { padding: 1.75rem; flex: 1; }

/* ── Cards ──────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  padding: 1rem 1.35rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.card-header h2 { font-size: 1rem; font-weight: 800; letter-spacing: -.2px; }
.card-body { padding: 1.35rem; }

/* ── Stats grid ──────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}
.stat-card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .18s, transform .18s;
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.stat-card .label { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stat-card .value { font-size: 2.1rem; font-weight: 800; color: var(--text); line-height: 1.05; margin-top: .35rem; letter-spacing: -1px; }
.stat-card .sub   { font-size: .78rem; color: var(--hint); margin-top: .25rem; font-weight: 500; }

/* Chip de icono (opcional, esquina sup. derecha) */
.stat-ic {
  position: absolute;
  top: 1.15rem; right: 1.15rem;
  width: 38px; height: 38px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
}
.stat-ic svg { width: 20px; height: 20px; }

.stat-card.blue   .stat-ic { background: var(--brand-soft);  color: var(--brand); }
.stat-card.green  .stat-ic { background: var(--success-bg);  color: var(--success); }
.stat-card.orange .stat-ic { background: var(--warning-bg);  color: var(--warning); }
.stat-card.red    .stat-ic { background: var(--danger-bg);   color: var(--danger); }
.stat-card.blue   { border-top: 3px solid var(--brand); }
.stat-card.green  { border-top: 3px solid var(--success); }
.stat-card.orange { border-top: 3px solid var(--warning); }
.stat-card.red    { border-top: 3px solid var(--danger); }

/* ── Table ───────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .875rem; }
th {
  padding: .7rem 1rem;
  text-align: left;
  font-size: .7rem;
  font-weight: 700;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: .06em;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
td {
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr { transition: background .12s; }
tbody tr:hover td { background: #f7f8fe; }

/* Estados de fila (importación CSV) */
tr.row-warn td { background: var(--warning-bg); }
tr.row-warn:hover td { background: #f8ead0; }
tr.row-skip { opacity: .45; }
tr.row-skip:hover td { background: transparent; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  padding: .55rem 1.05rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .85rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .15s, box-shadow .15s, border-color .15s, transform .08s;
  line-height: 1.1;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn:active { transform: scale(.975); }
.btn-primary  { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(32,52,232,.25); }
.btn-primary:hover { background: var(--brand-strong); color: #fff; }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover { background: #138a3e; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: #f3f3f8; border-color: #cdcedd; }
.btn-sm { padding: .35rem .7rem; font-size: .78rem; }
.btn-icon { padding: .35rem .45rem; }
.btn svg { width: 16px; height: 16px; }

/* ── Forms ───────────────────────────────────────────── */
.form-group { margin-bottom: 1.1rem; }
.form-group label { display: block; font-size: .82rem; font-weight: 700; color: var(--text); margin-bottom: .4rem; }
.form-control {
  width: 100%;
  padding: .6rem .8rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .875rem;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
}
.form-control::placeholder { color: var(--hint); }
.form-control:hover { border-color: #cdcedd; }
.form-control:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(32,52,232,.14); }
textarea.form-control { resize: vertical; min-height: 84px; line-height: 1.55; }
select.form-control { cursor: pointer; }

.form-check { display: inline-flex; align-items: center; gap: .5rem; cursor: pointer; font-weight: 600; }
.form-check input[type=checkbox] { width: 17px; height: 17px; cursor: pointer; accent-color: var(--brand); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
@media (max-width: 640px) { .form-row { grid-template-columns: 1fr; } }

.form-actions {
  display: flex;
  gap: .7rem;
  align-items: center;
  padding-top: 1.1rem;
  margin-top: .5rem;
  border-top: 1px solid var(--border);
}

/* Checkboxes multi-servicio */
.checks-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .55rem;
  padding: .9rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

/* ── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .25rem .6rem;
  border-radius: var(--radius-pill);
  font-size: .72rem;
  font-weight: 700;
  line-height: 1.4;
  white-space: nowrap;
}
.badge-blue   { background: var(--brand-soft); color: var(--brand-strong); }
.badge-green  { background: var(--success-bg); color: #166534; }
.badge-orange { background: var(--warning-bg); color: #9a3412; }
.badge-purple { background: #ede9fe; color: #6b21a8; }
.badge-pink   { background: #fce7f1; color: var(--accent-pink); }
.badge-gray   { background: #eef0f4; color: #4b5060; }
.badge-red    { background: var(--danger-bg); color: #b91c1c; }

/* ── Alerts / Flash ──────────────────────────────────── */
.alert {
  padding: .8rem 1.05rem;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  margin-bottom: 1.1rem;
  border: 1px solid transparent;
}
.alert-success { background: var(--success-bg); border-color: #b6e6c8; color: #15803d; }
.alert-danger  { background: var(--danger-bg);  border-color: #f4c4c4; color: #b91c1c; }
.alert-warning { background: var(--warning-bg); border-color: #f0d49a; color: #92400e; }
.alert-info    { background: var(--info-bg);    border-color: #c9cffb; color: var(--brand-strong); }

/* ── Login page ──────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(155deg, #14152b 0%, #1b1d24 52%, #221a3d 100%);
  padding: 1.25rem;
}
.login-card {
  background: #fff;
  border-radius: 18px;
  padding: 2.75rem 2.25rem;
  width: 100%;
  max-width: 392px;
  box-shadow: 0 20px 60px -12px rgba(0,0,0,.45);
}
.login-logo { text-align: center; margin-bottom: 1.9rem; }
.login-logo h1 { font-size: 1.7rem; font-weight: 800; color: var(--ink); letter-spacing: -.6px; }
.login-logo span { color: var(--brand); }
.login-logo p { color: var(--muted); font-size: .85rem; margin-top: .35rem; font-weight: 500; }

/* ── Seguimiento table ───────────────────────────────── */
.seg-num { font-weight: 700; color: var(--muted); font-size: .82rem; }
.seg-firma { text-align: center; }
.check-yes { color: var(--success); font-size: 1.15rem; }
.check-no  { color: #cfd2db; font-size: 1.15rem; }

/* ── Search / filter bar ──────────────────────────────── */
.filter-bar {
  display: flex;
  gap: .65rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.25rem;
}
.filter-bar.card-body { padding: 1rem 1.1rem; }
.filter-bar .form-control { max-width: 280px; }
.filter-bar select.form-control { max-width: 210px; }

/* ── Pagination ──────────────────────────────────────── */
.pagination { display: flex; gap: .35rem; align-items: center; margin-top: 1.25rem; flex-wrap: wrap; }
.page-btn {
  padding: .4rem .72rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: .82rem;
  font-weight: 700;
  color: var(--text);
  background: var(--surface);
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.page-btn:hover { background: #f3f3f8; }
.page-btn.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ── Empty state ─────────────────────────────────────── */
.empty-state { text-align: center; padding: 3.25rem 1rem; color: var(--muted); }
.empty-state .icon { font-size: 2.75rem; margin-bottom: .75rem; opacity: .7; }
.empty-state p { font-size: .92rem; font-weight: 500; }

/* ── Tags list ────────────────────────────────────────── */
.tags { display: flex; flex-wrap: wrap; gap: .35rem; }

/* ── Divider ─────────────────────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 1.4rem 0; }

/* ── File input ──────────────────────────────────────── */
.file-current { font-size: .82rem; color: var(--muted); margin-top: .4rem; font-weight: 600; }
.file-current a { color: var(--brand); }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 860px) {
  :root { --sidebar-w: 76px; }
  .sidebar-logo { font-size: 1.1rem; padding: 1.2rem .9rem; text-align: center; }
  .sidebar-logo span { display: none; }
  .nav-section { display: none; }
  .nav-link { justify-content: center; padding: .7rem; gap: 0; }
  .nav-link .txt { display: none; }
  .sidebar-footer { display: none; }
  .page-content { padding: 1.1rem; }
}
