/* ============================================================
   GDTI – Gestión de Archivo  |  styles.css v2
   Fuente: DM Sans (display) + JetBrains Mono (códigos)
   Tema: Institucional azul marino / papel blanco
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,700;0,9..40,800;1,9..40,400&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── Variables ─────────────────────────────────────────── */
:root {
  --bg:         #f0f4f9;
  --panel:      #ffffff;
  --text:       #1a2535;
  --muted:      #64748b;
  --border:     #dde4ee;
  --primary:    #1e3a5f;
  --primary-h:  #162d4a;
  --accent:     #2563eb;
  --accent-h:   #1d4ed8;
  --ok:         #16a34a;
  --ok-bg:      #dcfce7;
  --warn:       #d97706;
  --warn-bg:    #fef3c7;
  --bad:        #dc2626;
  --bad-bg:     #fee2e2;
  --shadow-sm:  0 1px 3px rgba(15,23,42,.07), 0 1px 2px rgba(15,23,42,.05);
  --shadow:     0 4px 16px rgba(15,23,42,.09), 0 1px 4px rgba(15,23,42,.06);
  --shadow-lg:  0 12px 40px rgba(15,23,42,.14), 0 2px 8px rgba(15,23,42,.06);
  --radius:     12px;
  --sidebar-w:  256px;
  --font:       'DM Sans', system-ui, sans-serif;
  --mono:       'JetBrains Mono', monospace;
}

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

/* ── Layout shell ──────────────────────────────────────── */
.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  transition: grid-template-columns .25s ease;
}
.shell.collapsed { grid-template-columns: 64px 1fr; }

/* ── Sidebar ───────────────────────────────────────────── */
.sidebar {
  background: linear-gradient(175deg, var(--primary) 0%, #0f2236 100%);
  color: #e8eef7;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow: hidden;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width .25s ease;
  z-index: 20;
}

.sidebar-header {
  padding: 20px 18px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 72px;
}

.sidebar-logo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(255,255,255,.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 18px;
}

.brand-text {
  overflow: hidden;
  transition: opacity .2s;
}
.shell.collapsed .brand-text { opacity: 0; width: 0; }

.brand-name {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}
.brand-sub {
  font-size: 11px;
  color: #8ba6c7;
  white-space: nowrap;
}

.nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-btn {
  border: 0;
  background: transparent;
  color: #b8cde6;
  padding: 10px 12px;
  border-radius: 9px;
  text-align: left;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  font-weight: 500;
  transition: background .15s, color .15s;
  white-space: nowrap;
  overflow: hidden;
}
.nav-btn .nav-icon { flex-shrink: 0; width: 18px; text-align: center; font-size: 15px; }
.nav-btn .nav-label { overflow: hidden; }
.shell.collapsed .nav-label { display: none; }

.nav-btn:hover  { background: rgba(255,255,255,.08); color: #fff; }
.nav-btn.active { background: rgba(255,255,255,.14); color: #fff; font-weight: 700; }

.sidebar-footer {
  padding: 12px 10px;
  border-top: 1px solid rgba(255,255,255,.08);
}

.collapse-btn {
  border: 0;
  background: rgba(255,255,255,.07);
  color: #8ba6c7;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  transition: background .15s;
}
.collapse-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.collapse-icon { transition: transform .25s; flex-shrink: 0; }
.shell.collapsed .collapse-icon { transform: rotate(180deg); }
.shell.collapsed .collapse-label { display: none; }

/* ── Main ──────────────────────────────────────────────── */
.main {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
  overflow-x: hidden;
}

/* ── Topbar ────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 14px 18px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.topbar-title { font-size: 15px; font-weight: 700; }
.topbar-sub   { font-size: 12px; color: var(--muted); margin-top: 1px; }

/* ── Cards KPI ─────────────────────────────────────────── */
.grid-cards {
  display: grid;
  grid-template-columns: repeat(4, minmax(0,1fr));
  gap: 16px;
}
.kpi-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--accent);
  border-radius: 3px 3px 0 0;
}
.kpi-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 30px; font-weight: 800; color: var(--text); font-family: var(--font); line-height: 1; }
.kpi-icon  { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 28px; opacity: .08; }

/* ── Panel ─────────────────────────────────────────────── */
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-header {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.panel-title { font-size: 14px; font-weight: 700; }
.panel-body  { padding: 16px 18px; }

/* ── Toolbar / filtros ─────────────────────────────────── */
.toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.field {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.field-sm { min-width: 140px; }
.field-md { min-width: 180px; }

/* ── Botones ───────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 8px;
  border: 0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary { background: #eef2fb; color: var(--primary); border: 1px solid var(--border); }
.btn-secondary:hover { background: #e0e8f5; }
.btn-danger    { background: var(--bad); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost     { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 7px; border-radius: 7px; }

/* ── Tabla ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table th {
  padding: 10px 12px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  background: #f8fafc;
  white-space: nowrap;
}
.table td {
  padding: 11px 12px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text);
  vertical-align: middle;
}
.table tbody tr:hover td { background: #f8fafc; }
.table tbody tr:last-child td { border-bottom: 0; }

.code { font-family: var(--mono); font-size: 12px; color: var(--accent); font-weight: 600; }

/* ── Badges de estado ──────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge::before { content: ''; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .6; }
.badge-ok   { background: var(--ok-bg);   color: var(--ok); }
.badge-warn { background: var(--warn-bg); color: var(--warn); }
.badge-bad  { background: var(--bad-bg);  color: var(--bad); }

/* ── Paginación ────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: flex-end;
  padding: 12px 18px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.pagination-info { font-size: 12px; color: var(--muted); flex: 1; }
.page-btn {
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text);
  padding: 5px 10px;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.page-btn:hover    { background: var(--bg); }
.page-btn.active   { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 700; }
.page-btn:disabled { opacity: .4; cursor: default; }

/* ── Modal ─────────────────────────────────────────────── */
.backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(2px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  animation: fadeIn .15s ease;
}
.backdrop.open { display: flex; }
.modal {
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  width: min(540px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .2s ease;
}
.modal-wide { width: min(700px, 100%); }
.modal-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-title { font-size: 15px; font-weight: 700; }
.modal-body  { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.close-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background .15s;
}
.close-btn:hover { background: var(--bg); color: var(--text); }

/* ── Formularios ───────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-label { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.form-grid  { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-full  { grid-column: 1 / -1; }
.form-help  { font-size: 11px; color: var(--muted); }

/* ── Auditoría - items ─────────────────────────────────── */
.audit-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  margin-bottom: 8px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  font-size: 13px;
}
.audit-badge {
  grid-row: 1 / 3;
  align-self: center;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .05em;
  background: var(--bg);
  color: var(--muted);
  border: 1px solid var(--border);
  white-space: nowrap;
}
.audit-title  { font-weight: 600; }
.audit-meta   { color: var(--muted); font-size: 12px; }
.audit-detail { grid-column: 2; font-size: 12px; color: var(--text); }
.audit-diff   { grid-column: 2; margin-top: 4px; }
.diff-row     { display: flex; gap: 8px; font-size: 12px; margin-bottom: 3px; flex-wrap: wrap; }
.diff-key     { color: var(--muted); font-family: var(--mono); font-size: 11px; min-width: 120px; }
.diff-before  { color: var(--bad);  background: var(--bad-bg);  padding: 1px 6px; border-radius: 4px; }
.diff-after   { color: var(--ok);   background: var(--ok-bg);   padding: 1px 6px; border-radius: 4px; }

/* ── Vista detalle archivador ──────────────────────────── */
.detail-header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  flex-wrap: wrap;
}
.detail-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px,1fr));
  gap: 12px;
  margin-top: 16px;
}
.meta-item { display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.meta-value { font-size: 14px; font-weight: 500; }

.tab-row  { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.tab-btn  {
  padding: 10px 18px;
  border: 0;
  background: transparent;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: color .15s;
}
.tab-btn.active { color: var(--accent); border-bottom-color: var(--accent); }
.tab-btn:hover  { color: var(--text); }

/* ── Toast ─────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--text);
  color: #fff;
  padding: 12px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  animation: slideLeft .2s ease;
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.toast.success { background: var(--ok); }
.toast.error   { background: var(--bad); }
.toast.warn    { background: var(--warn); }

/* ── Loading spinner ───────────────────────────────────── */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
.spinner-dark {
  border-color: rgba(30,58,95,.2);
  border-top-color: var(--accent);
}
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--muted);
  gap: 10px;
  font-size: 13px;
}

/* ── Empty state ───────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-icon  { font-size: 36px; margin-bottom: 12px; opacity: .4; }
.empty-title { font-size: 15px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.empty-sub   { font-size: 13px; }

/* ── Config panel ──────────────────────────────────────── */
.logo-preview {
  width: 80px;
  height: 80px;
  border: 2px dashed var(--border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: var(--bg);
  cursor: pointer;
  transition: border-color .15s;
}
.logo-preview:hover { border-color: var(--accent); }
.logo-preview img   { width: 100%; height: 100%; object-fit: contain; }
.logo-placeholder   { font-size: 28px; opacity: .3; }

/* ── Animations ────────────────────────────────────────── */
@keyframes fadeIn  { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideLeft { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin    { to { transform: rotate(360deg); } }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 1024px) {
  .grid-cards { grid-template-columns: repeat(2,1fr); }
}
@media (max-width: 768px) {
  :root { --sidebar-w: 100%; }
  .shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .sidebar {
    height: auto;
    position: static;
    flex-direction: row;
    align-items: center;
    padding: 0 10px;
    overflow-x: auto;
  }
  .sidebar-header { border-bottom: 0; border-right: 1px solid rgba(255,255,255,.08); padding: 12px; min-height: auto; }
  .nav { flex-direction: row; padding: 8px; overflow-x: auto; overflow-y: hidden; flex: 1; }
  .nav-btn { padding: 8px 10px; font-size: 12px; }
  .sidebar-footer { display: none; }
  .grid-cards { grid-template-columns: 1fr 1fr; }
  .form-grid  { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
  .main { padding: 12px; gap: 12px; }
  .grid-cards { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; align-items: stretch; }
}
