/* ═══════════════════════════════════════════════════════════════
   Panel Operativo de Conciliación de Guías (apps/guias)
   Inspirado en el sistema de diseño de apps/web
   ═══════════════════════════════════════════════════════════════ */

:root {
  --c-bg: #0c1222;
  --c-surface: #141c30;
  --c-surface-2: #1b2640;
  --c-border: #263554;
  --c-text: #f1f5f9;
  --c-text-muted: #94a3b8;
  --c-primary: #6366f1;
  --c-primary-hover: #4f46e5;
  --c-primary-soft: rgba(99, 102, 241, 0.15);
  --c-danger: #ef4444;
  --c-danger-soft: rgba(239, 68, 68, 0.15);
  --c-warn: #f59e0b;
  --c-warn-soft: rgba(245, 158, 11, 0.15);
  --c-ok: #10b981;
  --c-ok-soft: rgba(16, 185, 129, 0.15);
  --c-info: #0ea5e9;
  --c-info-soft: rgba(14, 165, 233, 0.15);
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  --sidebar-w: 240px;
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background-color: var(--c-bg);
  color: var(--c-text);
  min-height: 100vh;
  display: flex;
}

/* ---------------- LAYOUT ---------------- */

.app-container {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--c-surface);
  border-right: 1px solid var(--c-border);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  flex-shrink: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 2rem;
  font-weight: 700;
  font-size: 1.1rem;
  color: #fff;
}

.brand svg {
  width: 28px;
  height: 28px;
  color: var(--c-primary);
}

.nav-links {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1rem;
  color: var(--c-text-muted);
  text-decoration: none;
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-weight: 500;
  transition: all 0.2s ease;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}

.nav-link:hover {
  background: var(--c-surface-2);
  color: var(--c-text);
}

.nav-link.active {
  background: var(--c-primary);
  color: #fff;
}

.user-profile {
  border-top: 1px solid var(--c-border);
  padding-top: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.user-info {
  overflow: hidden;
}

.user-name {
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 0.75rem;
  color: var(--c-text-muted);
  text-transform: uppercase;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  background: var(--c-bg);
}

/* ---------------- LOGIN SCREEN ---------------- */

.login-screen {
  position: fixed;
  inset: 0;
  background: var(--c-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.login-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}

.login-card h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.login-card p {
  color: var(--c-text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* ---------------- FORMS & CONTROLS ---------------- */

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.4rem;
  color: var(--c-text-muted);
}

.form-control, .form-select {
  width: 100%;
  padding: 0.65rem 0.85rem;
  background: var(--c-surface-2);
  border: 1px solid var(--c-border);
  border-radius: var(--radius);
  color: var(--c-text);
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--c-primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.25rem;
  border-radius: var(--radius);
  font-weight: 500;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--c-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--c-primary-hover);
}

.btn-secondary {
  background: var(--c-surface-2);
  color: var(--c-text);
  border: 1px solid var(--c-border);
}

.btn-secondary:hover {
  background: var(--c-border);
}

.btn-danger {
  background: var(--c-danger);
  color: #fff;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.8rem;
}

/* ---------------- CARDS & METRICS ---------------- */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1.25rem;
  margin-bottom: 2rem;
}

.metric-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
}

.metric-card .label {
  font-size: 0.8rem;
  color: var(--c-text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.metric-card .value {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
}

.metric-card.ok { border-left: 4px solid var(--c-ok); }
.metric-card.warn { border-left: 4px solid var(--c-warn); }
.metric-card.danger { border-left: 4px solid var(--c-danger); }
.metric-card.primary { border-left: 4px solid var(--c-primary); }

/* ---------------- TABLES ---------------- */

.panel-card {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.panel-header h3 {
  font-size: 1.25rem;
  font-weight: 600;
}

.filters-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.table-responsive {
  overflow-x: auto;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  text-align: left;
}

table.data-table th {
  background: var(--c-surface-2);
  color: var(--c-text-muted);
  font-weight: 600;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
}

table.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--c-border);
  color: var(--c-text);
  white-space: nowrap;
}

table.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* ---------------- BADGES ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-pagada { background: var(--c-ok-soft); color: var(--c-ok); }
.badge-pagada_con_diferencias { background: var(--c-warn-soft); color: var(--c-warn); }
.badge-no_pagada { background: var(--c-danger-soft); color: var(--c-danger); }
.badge-pendiente { background: var(--c-surface-2); color: var(--c-text-muted); }

.badge-alta { background: var(--c-danger-soft); color: var(--c-danger); }
.badge-media { background: var(--c-warn-soft); color: var(--c-warn); }
.badge-baja { background: var(--c-info-soft); color: var(--c-info); }

.badge-processed { background: var(--c-ok-soft); color: var(--c-ok); }
.badge-needs_review { background: var(--c-warn-soft); color: var(--c-warn); }
.badge-error { background: var(--c-danger-soft); color: var(--c-danger); }

/* ---------------- MODALS ---------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 1.5rem;
}

.modal-dialog {
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 650px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--c-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--c-border);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--c-text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}

/* ---------------- ALERTS & TOASTS ---------------- */

.alert {
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
  font-size: 0.9rem;
}

.alert-danger {
  background: var(--c-danger-soft);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert-success {
  background: var(--c-ok-soft);
  color: #6ee7b7;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Responsive */
@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid var(--c-border);
    padding: 1rem;
  }
  .main-content {
    padding: 1rem;
  }
}
