/* ============================================================
   DepoCon — Estilos
   ============================================================ */

/* ── Variables ────────────────────────────────────────────── */
:root {
  --primary:        #1a56db;
  --primary-light:  #e8f0fe;
  --primary-dark:   #1341b0;
  --success:        #0e9f6e;
  --success-light:  #def7ec;
  --warning:        #c27803;
  --warning-light:  #fdf6b2;
  --danger:         #e02424;
  --danger-light:   #fde8e8;
  --gray-50:  #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --sidebar-w: 230px;
  --sidebar-collapsed-w: 52px;
  --header-h:  56px;
  --radius:    8px;
  --shadow:    0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Fix: [hidden] must override .screen { display: flex } */
[hidden] { display: none !important; }

/* ── Screens (login / setup) ──────────────────────────────── */
.screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}
.card-center {
  background: #fff;
  border-radius: 12px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-md);
}
.card-center h1 { font-size: 22px; font-weight: 700; color: var(--gray-900); margin-bottom: 4px; }
.card-center .subtitle { color: var(--gray-500); margin-bottom: 28px; font-size: 13px; }
.logo-wrap { display: flex; align-items: center; gap: 10px; margin-bottom: 24px; }
.logo-text { font-size: 18px; font-weight: 800; color: var(--gray-900); }
.logo-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 18px; font-weight: 800;
  flex-shrink: 0;
}
.logo-icon.sm { width: 28px; height: 28px; font-size: 14px; border-radius: 6px; }
.link-small { text-align: center; margin-top: 16px; font-size: 12px; color: var(--gray-400); }

/* ── Forms ────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
label {
  display: block;
  font-size: 13px; font-weight: 600;
  color: var(--gray-700);
  margin-bottom: 5px;
}
input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=date],
select,
textarea {
  width: 100%;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-size: 14px;
  color: var(--gray-800);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}
textarea { resize: vertical; min-height: 70px; }
.input-hint { font-size: 11px; color: var(--gray-400); margin-top: 4px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 500px) { .two-col { grid-template-columns: 1fr; } }

/* ── Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border-radius: var(--radius);
  font-size: 13px; font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
  font-family: inherit;
  white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary);  color: #fff; }
.btn-primary:hover:not(:disabled)  { background: var(--primary-dark); }
.btn-success  { background: var(--success);  color: #fff; }
.btn-success:hover:not(:disabled)  { background: #097a56; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-danger:hover:not(:disabled)   { background: #b91c1c; }
.btn-ghost    { background: transparent; color: var(--gray-600); border: 1px solid var(--gray-300); }
.btn-ghost:hover:not(:disabled)    { background: var(--gray-100); }
.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── App layout ───────────────────────────────────────────── */
#app { height: 100vh; overflow: hidden; }

#app-header {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center;
  padding: 0 20px; gap: 10px;
  z-index: 100;
}
.header-title  { font-size: 16px; font-weight: 700; color: var(--gray-900); }
.header-env    { background: var(--primary-light); color: var(--primary); font-size: 11px; padding: 2px 8px; border-radius: 12px; font-weight: 600; }
.header-spacer { flex: 1; }
.header-user   { font-size: 12px; color: var(--gray-500); }

#app-sidebar {
  position: fixed; top: var(--header-h); left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--gray-200);
  overflow-x: hidden;
  padding: 16px 0 0;
  z-index: 90;
  transition: width .2s ease;
  display: flex; flex-direction: column;
}
#sidebar-nav {
  flex: 1;
  overflow-y: auto; overflow-x: hidden;
}
.nav-section {
  padding: 4px 12px;
  font-size: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em;
  color: var(--gray-400);
  margin: 12px 0 4px;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .15s, height .15s;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px;
  color: var(--gray-600);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all .15s;
  font-size: 13px; font-weight: 500;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
}
.nav-item:hover { background: var(--gray-50); color: var(--gray-900); text-decoration: none; }
.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}
.nav-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.nav-label { transition: opacity .15s; }
.nav-badge {
  margin-left: auto;
  background: var(--danger); color: #fff;
  font-size: 10px; padding: 1px 6px; border-radius: 10px;
  transition: opacity .15s;
}

/* ── Sidebar collapsed ────────────────────────────────────── */
#app-sidebar.collapsed {
  width: var(--sidebar-collapsed-w);
}
#app-sidebar.collapsed .nav-section {
  opacity: 0;
  height: 0;
  margin: 0;
  padding: 0;
  pointer-events: none;
}
#app-sidebar.collapsed .nav-label { opacity: 0; width: 0; overflow: hidden; }
#app-sidebar.collapsed .nav-badge { opacity: 0; width: 0; overflow: hidden; }
#app-sidebar.collapsed .nav-item {
  padding: 10px 0;
  justify-content: center;
  gap: 0;
  border-left-color: transparent;
}
#app-sidebar.collapsed .nav-item.active {
  border-left-color: transparent;
  border-right: 3px solid var(--primary);
}
#app-sidebar.collapsed .nav-item:hover { background: var(--gray-100); }
#app-sidebar.collapsed .nav-icon { font-size: 18px; width: auto; }

/* tooltip al hacer hover en modo colapsado */
#app-sidebar.collapsed .nav-item { position: relative; }
#app-sidebar.collapsed .nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(var(--sidebar-collapsed-w) + 6px);
  top: 50%; transform: translateY(-50%);
  background: var(--gray-800); color: #fff;
  font-size: 12px; font-weight: 500;
  padding: 4px 10px; border-radius: 6px;
  white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity .12s;
  z-index: 200;
}
#app-sidebar.collapsed .nav-item:hover::after { opacity: 1; }

#sidebar-version {
  padding: 10px 0 12px;
  text-align: center;
  font-size: 10px;
  color: var(--gray-400);
  letter-spacing: .04em;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  transition: opacity .2s ease;
}
#app-sidebar.collapsed #sidebar-version { opacity: 0; }

#main-content {
  position: fixed;
  top: var(--header-h); left: var(--sidebar-w); right: 0; bottom: 0;
  overflow-y: auto;
  padding: 24px;
  transition: left .2s ease;
}
#main-content.sidebar-collapsed {
  left: var(--sidebar-collapsed-w);
}

/* ── Mobile ───────────────────────────────────────────────── */
@media (max-width: 640px) {
  /* Sidebar abierto: ancho más estrecho */
  #app-sidebar { width: 200px; }
  #main-content { left: 200px; padding: 14px; }

  /* Sidebar colapsado: completamente oculto */
  #app-sidebar.collapsed { width: 0; border-right: none; overflow: hidden; }
  #main-content.sidebar-collapsed { left: 0; }

  /* Tabla cobros: importe no se corta */
  #dep-pend-tbody td.amount { min-width: 80px; }
}

/* ── Cards ────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-body   { padding: 20px; }
.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--gray-100);
  display: flex; align-items: center; gap: 10px;
}
.card-header h2 { font-size: 15px; font-weight: 700; color: var(--gray-900); flex: 1; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--gray-100);
  background: var(--gray-50);
  border-radius: 0 0 var(--radius) var(--radius);
  display: flex; gap: 8px; justify-content: flex-end;
}

/* ── Page header ──────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 20px;
}
.page-header h2 { font-size: 20px; font-weight: 800; color: var(--gray-900); flex: 1; }

/* ── Stats ────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: #fff; border-radius: var(--radius);
  border: 1px solid var(--gray-200); padding: 20px;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-500); margin-bottom: 8px; }
.stat-value { font-size: 28px; font-weight: 800; color: var(--gray-900); }
.stat-value.blue   { color: var(--primary); }
.stat-value.green  { color: var(--success); }
.stat-value.orange { color: var(--warning); }
.stat-value.red    { color: var(--danger); }
.stat-sub { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ── Tables ───────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--gray-200); }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead { background: var(--gray-50); }
th {
  padding: 10px 14px; text-align: left;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .05em;
  color: var(--gray-500);
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
td { padding: 11px 14px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--gray-50); }
tr.row-selected td { background: var(--primary-light) !important; }
tr.row-bloqueado td { background: #fff0f0 !important; opacity: 0.7; }
tr.row-externo td  { background: #ffe4e4 !important; }
tr.row-muted td { opacity: 0.4; }
tr.row-externo:hover td { background: #ffd6d6 !important; }
tr.clickable { cursor: pointer; }

/* ── Autocomplete cliente ─────────────────────────────────── */
.cli-autocomplete { position: relative; }
.cli-autocomplete input { width: 100%; }
.cli-ac-dropdown {
  position: absolute; top: calc(100% + 2px); left: 0; right: 0;
  background: #fff;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  max-height: 220px; overflow-y: auto;
  z-index: 1000;
}
.cli-ac-item {
  padding: 9px 14px;
  cursor: pointer;
  font-size: 13px;
  border-bottom: 1px solid var(--gray-100);
}
.cli-ac-item:last-child { border-bottom: none; }
.cli-ac-item:hover, .cli-ac-item.focused { background: var(--primary-light); color: var(--primary); }
.cli-ac-item mark { background: #fde047; color: inherit; border-radius: 2px; font-style: normal; }
.cli-ac-empty { padding: 10px 14px; font-size: 13px; color: var(--gray-400); font-style: italic; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 10px; border-radius: 12px;
  font-size: 11px; font-weight: 700;
}
.badge-green  { background: var(--success-light); color: var(--success); }
.badge-blue   { background: var(--primary-light);  color: var(--primary); }
.badge-orange { background: var(--warning-light);  color: var(--warning); }
.badge-yellow { background: #fefce8; color: #854d0e; border: 1px solid #fde047; }
.badge-red    { background: var(--danger-light);   color: var(--danger); }
.badge-gray   { background: var(--gray-100);        color: var(--gray-500); }
.badge-purple { background: #f3e8ff; color: #7e22ce; }

@keyframes pulse-activa {
  0%, 100% { box-shadow: 0 0 0 3px rgba(249,115,22,.25); }
  50%       { box-shadow: 0 0 0 6px rgba(249,115,22,.08); }
}

/* ── Alerts ───────────────────────────────────────────────── */
.alert {
  padding: 12px 16px; border-radius: var(--radius);
  margin-bottom: 16px; font-size: 13px;
}
.alert-info    { background: var(--primary-light); color: var(--primary-dark); border: 1px solid #b3d0ff; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }
.alert-danger  { background: var(--danger-light);  color: #991b1b; border: 1px solid #fca5a5; }

/* ── Modal ────────────────────────────────────────────────── */
#modal-overlay, .modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
}
#modal-overlay[hidden] { display: none; }
#modal-box {
  background: #fff; border-radius: 12px;
  padding: 28px; width: 100%; max-width: 520px;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
#modal-box.modal-lg { max-width: 820px; }
#modal-box h3 { font-size: 17px; font-weight: 700; margin-bottom: 20px; color: var(--gray-900); }
/* Modales dinámicos (div.modal-overlay > div.modal) */
.modal-overlay .modal {
  background: #fff; border-radius: 12px; width: 100%;
  max-height: 90vh; overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
  display: flex; flex-direction: column;
}
.modal-overlay .modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px 14px; border-bottom: 1px solid var(--gray-200);
}
.modal-overlay .modal-header h3 { font-size: 16px; font-weight: 700; color: var(--gray-900); margin: 0; }
.modal-overlay .modal-close {
  background: none; border: none; cursor: pointer; font-size: 18px;
  color: var(--gray-400); padding: 2px 6px; border-radius: 4px;
}
.modal-overlay .modal-close:hover { background: var(--gray-100); color: var(--gray-700); }
.modal-overlay .modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-overlay .modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 14px 24px 18px; border-top: 1px solid var(--gray-200);
}
.modal-actions {
  display: flex; gap: 8px; justify-content: flex-end;
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--gray-100);
}

/* ── Toasts ───────────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: 24px; right: 24px;
  z-index: 999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 12px 18px; border-radius: var(--radius);
  color: #fff; font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideUp .25s ease;
  max-width: 340px;
}
.toast-success { background: var(--success); }
.toast-error   { background: var(--danger); }
.toast-info    { background: var(--primary); }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Loading / Spinner ────────────────────────────────────── */
.loading {
  display: flex; align-items: center; gap: 8px;
  color: var(--gray-400); padding: 32px 20px;
  justify-content: center;
}
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ──────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 20px; color: var(--gray-400); }
.empty-state .es-icon { font-size: 40px; margin-bottom: 10px; }
.empty-state p { font-size: 14px; }

/* ── Misc helpers ─────────────────────────────────────────── */
.text-muted  { color: var(--gray-400); font-size: 12px; }
.font-mono   { font-family: 'Courier New', monospace; }
.amount      { font-weight: 700; font-family: 'Courier New', monospace; }
.amount.pos  { color: var(--success); }
.amount.neg  { color: var(--danger); }
.chip {
  display: inline-block;
  background: var(--gray-100); color: var(--gray-600);
  border-radius: 12px; padding: 2px 10px;
  font-size: 11px; font-weight: 600;
}
.divider { border: none; border-top: 1px solid var(--gray-100); margin: 16px 0; }
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.search-bar input { flex: 1; min-width: 200px; max-width: 320px; }

/* ── Drop zone (carga Excel) ─────────────────────────────── */
.drop-zone {
  border: 2px dashed var(--gray-300);
  border-radius: var(--radius);
  padding: 40px 20px; text-align: center;
  cursor: pointer; transition: all .2s;
  color: var(--gray-500);
}
.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.drop-zone .dz-icon { font-size: 36px; margin-bottom: 8px; }
.drop-zone p { font-size: 14px; font-weight: 500; }
.drop-zone small { font-size: 12px; }

/* ── Mapping grid ────────────────────────────────────────── */
.mapping-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 600px) { .mapping-grid { grid-template-columns: 1fr; } }

/* ── Conciliar grid ──────────────────────────────────────── */
.conciliar-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 900px) { .conciliar-grid { grid-template-columns: 1fr; } }

/* ── Totals bar ──────────────────────────────────────────── */
.totals-bar {
  background: var(--gray-800); color: #fff;
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex; gap: 24px; align-items: center; flex-wrap: wrap;
  margin-top: 16px;
}
.totals-bar-sticky {
  position: sticky;
  bottom: 0;
  z-index: 50;
  border-radius: 0;
  margin-top: 16px;
  box-shadow: 0 -4px 12px rgba(0,0,0,.25);
}
.tot-item    { display: flex; flex-direction: column; }
.tot-label   { font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--gray-400); }
.tot-value   { font-size: 18px; font-weight: 800; }
.tot-value.ok  { color: #6ee7b7; }
.tot-value.bad { color: #fca5a5; }
.tot-spacer  { flex: 1; }
