/* ============================================================
   MAX FINANZAS — Design System
   Representaciones Max C.A.
   ============================================================ */

/* ── DESIGN TOKENS ── */
:root {
  /* Colores */
  --mf-primary: #0C4A6E;
  --mf-primary-dark: #082F49;
  --mf-primary-light: #0E7490;
  --mf-accent: #C2790A;
  --mf-accent-hover: #A56800;
  --mf-accent-light: #FFF8ED;
  --mf-surface: #F5F5F0;
  --mf-surface-alt: #FAFAF7;
  --mf-white: #FFFFFF;
  --mf-text: #334155;
  --mf-text-muted: #94A3B8;
  --mf-text-light: #CBD5E1;
  --mf-border: #E2E1DB;
  --mf-border-light: #F1F0EB;
  --mf-success: #15803D;
  --mf-success-bg: #F0FDF4;
  --mf-danger: #B91C1C;
  --mf-danger-bg: #FEF2F2;
  --mf-info: #0C4A6E;
  --mf-info-bg: #EFF6FF;
  --mf-warning-bg: #FFF8ED;

  /* Espaciado */
  --mf-space-xs: 4px;
  --mf-space-sm: 8px;
  --mf-space-md: 16px;
  --mf-space-lg: 24px;
  --mf-space-xl: 32px;
  --mf-space-2xl: 48px;

  /* Bordes */
  --mf-radius: 8px;
  --mf-radius-lg: 12px;
  --mf-radius-sm: 6px;

  /* Sombras */
  --mf-shadow-sm: 0 1px 3px rgba(0,0,0,0.04);
  --mf-shadow: 0 2px 8px rgba(0,0,0,0.06);
  --mf-shadow-lg: 0 4px 24px rgba(0,0,0,0.08);
  --mf-shadow-hover: 0 4px 24px rgba(0,0,0,0.10);

  /* Sidebar */
  --mf-sidebar-width: 260px;
  --mf-sidebar-collapsed: 70px;

  /* Transiciones */
  --mf-transition: all 0.2s ease;
}

/* ── RESET & BASE ── */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  line-height: 1.6;
  color: var(--mf-text);
  background: var(--mf-surface);
  margin: 0;
  padding: 0;
}

/* ── TIPOGRAFÍA ── */
h1, h2, h3, h4, h5, h6 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  color: var(--mf-primary-dark);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }

.text-accent { color: var(--mf-accent) !important; }
.text-primary-dark { color: var(--mf-primary-dark) !important; }
.text-muted-custom { color: var(--mf-text-muted) !important; }

.font-mono {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 600;
}

/* ── MARBETE (Elemento Firmador) ── */
.marbete {
  position: relative;
  overflow: hidden;
}

.marbete::after {
  content: '';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 3px;
  background: var(--mf-accent);
  transform: rotate(45deg);
  border-radius: 2px;
}

.section-accent::before {
  content: '';
  display: block;
  width: 24px;
  height: 3px;
  background: var(--mf-accent);
  margin-bottom: 8px;
  border-radius: 2px;
}

/* ── CARDS ── */
.card {
  background: var(--mf-white);
  border: 1px solid var(--mf-border);
  border-radius: var(--mf-radius-lg);
  transition: var(--mf-transition);
}

.card:hover {
  box-shadow: var(--mf-shadow-hover);
}

.card-header {
  background: var(--mf-white);
  border-bottom: 1px solid var(--mf-border-light);
  padding: var(--mf-space-md) var(--mf-space-lg);
}

.card-body {
  padding: var(--mf-space-lg);
}

/* Card con borde izquierdo */
.card-accent-left {
  border-left: 4px solid var(--mf-accent);
}

.card-primary-left {
  border-left: 4px solid var(--mf-primary);
}

.card-success-left {
  border-left: 4px solid var(--mf-success);
}

.card-danger-left {
  border-left: 4px solid var(--mf-danger);
}

/* ── STAT CARDS ── */
.stat-card {
  background: var(--mf-white);
  border: 1px solid var(--mf-border);
  border-radius: var(--mf-radius-lg);
  padding: var(--mf-space-lg) var(--mf-space-xl);
  transition: var(--mf-transition);
  position: relative;
  overflow: hidden;
}

.stat-card:hover {
  box-shadow: var(--mf-shadow-hover);
  transform: translateY(-2px);
}

.stat-card .stat-label {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mf-text-muted);
  margin-bottom: var(--mf-space-sm);
}

.stat-card .stat-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--mf-primary-dark);
  line-height: 1;
  margin-bottom: var(--mf-space-sm);
}

.stat-card .stat-trend {
  font-size: 0.75rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
}

.stat-trend.up { color: var(--mf-success); }
.stat-trend.down { color: var(--mf-danger); }

.stat-card .stat-icon {
  position: absolute;
  top: var(--mf-space-md);
  right: var(--mf-space-md);
  width: 40px;
  height: 40px;
  border-radius: var(--mf-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.stat-icon.teal { background: rgba(12,74,110,0.1); color: var(--mf-primary); }
.stat-icon.copper { background: var(--mf-accent-light); color: var(--mf-accent); }
.stat-icon.green { background: var(--mf-success-bg); color: var(--mf-success); }
.stat-icon.red { background: var(--mf-danger-bg); color: var(--mf-danger); }

/* ── BOTONES ── */
.btn {
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.875rem;
  letter-spacing: 0.01em;
  border-radius: var(--mf-radius);
  padding: 10px 20px;
  transition: var(--mf-transition);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn:active {
  transform: translateY(0);
}

/* Primary: Cobre */
.btn-primary {
  background: var(--mf-accent);
  color: var(--mf-white);
  border: none;
}

.btn-primary:hover {
  background: var(--mf-accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(194,121,10,0.3);
  color: var(--mf-white);
}

/* Secondary: Teal outline */
.btn-secondary {
  background: transparent;
  border: 1.5px solid var(--mf-primary);
  color: var(--mf-primary);
}

.btn-secondary:hover {
  background: var(--mf-primary);
  color: var(--mf-white);
}

/* Success */
.btn-success-custom {
  background: var(--mf-success);
  color: var(--mf-white);
}

.btn-success-custom:hover {
  background: #14732D;
  color: var(--mf-white);
}

/* Danger */
.btn-danger-custom {
  background: var(--mf-danger);
  color: var(--mf-white);
}

.btn-danger-custom:hover {
  background: #991B1B;
  color: var(--mf-white);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--mf-text);
  border: 1px solid var(--mf-border);
}

.btn-ghost:hover {
  background: var(--mf-surface);
}

/* Outline variants */
.btn-outline-primary {
  border: 1.5px solid var(--mf-accent);
  color: var(--mf-accent);
  background: transparent;
}

.btn-outline-primary:hover {
  background: var(--mf-accent);
  color: var(--mf-white);
}

.btn-outline-success {
  border: 1.5px solid var(--mf-success);
  color: var(--mf-success);
  background: transparent;
}

.btn-outline-success:hover {
  background: var(--mf-success);
  color: var(--mf-white);
}

.btn-outline-danger {
  border: 1.5px solid var(--mf-danger);
  color: var(--mf-danger);
  background: transparent;
}

.btn-outline-danger:hover {
  background: var(--mf-danger);
  color: var(--mf-white);
}

.btn-outline-dark {
  border: 1.5px solid var(--mf-primary-dark);
  color: var(--mf-primary-dark);
  background: transparent;
}

.btn-outline-dark:hover {
  background: var(--mf-primary-dark);
  color: var(--mf-white);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 1rem;
}

/* ── BADGES / STATUS ── */
.badge-status {
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 4px 10px;
  border-radius: var(--mf-radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.badge-status.pendiente {
  background: var(--mf-warning-bg);
  color: var(--mf-accent);
}

.badge-status.pagado, .badge-status.cerrada {
  background: var(--mf-success-bg);
  color: var(--mf-success);
}

.badge-status.atrasado, .badge-status.vencido {
  background: var(--mf-danger-bg);
  color: var(--mf-danger);
}

.badge-status.anulada {
  background: var(--mf-surface);
  color: var(--mf-text-muted);
}

.badge-status.abierta {
  background: var(--mf-info-bg);
  color: var(--mf-info);
}

.badge-status i {
  font-size: 0.55rem;
}

/* ── TABLAS ── */
.table {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.85rem;
  margin-bottom: 0;
}

.table thead th {
  font-family: 'DM Sans', sans-serif;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mf-text-muted);
  background: var(--mf-surface);
  border-bottom: 2px solid var(--mf-border);
  padding: 12px 16px;
}

.table tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--mf-border-light);
  vertical-align: middle;
  color: var(--mf-text);
}

.table tbody tr:hover {
  background: var(--mf-accent-light);
}

.table tbody tr:nth-child(even) {
  background: var(--mf-surface-alt);
}

.table tbody tr:nth-child(even):hover {
  background: var(--mf-accent-light);
}

.table .text-end {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

/* ── FORMULARIOS ── */
.form-control, .form-select {
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  border: 1.5px solid var(--mf-border);
  border-radius: var(--mf-radius);
  padding: 10px 14px;
  color: var(--mf-text);
  transition: var(--mf-transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--mf-primary);
  box-shadow: 0 0 0 3px rgba(12,74,110,0.1);
  outline: none;
}

.form-control::placeholder {
  color: var(--mf-text-light);
}

.form-label {
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.75rem;
  color: var(--mf-text);
  margin-bottom: 6px;
}

.input-group-text {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85rem;
  background: var(--mf-surface);
  border: 1.5px solid var(--mf-border);
  color: var(--mf-text-muted);
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--mf-sidebar-width);
  min-height: 100vh;
  background: linear-gradient(180deg, var(--mf-primary-dark) 0%, #061E30 100%);
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  transition: width 0.3s ease;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand h3 {
  font-family: 'Space Grotesk', sans-serif;
  color: var(--mf-white);
  font-size: 1.1rem;
  font-weight: 700;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-brand .brand-icon {
  width: 36px;
  height: 36px;
  background: var(--mf-accent);
  border-radius: var(--mf-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  color: var(--mf-white);
}

.sidebar-brand small {
  display: block;
  color: rgba(255,255,255,0.4);
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 4px;
}

.sidebar-nav {
  padding: 12px 0;
}

.sidebar-section {
  padding: 8px 20px 4px;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255,255,255,0.3);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 20px;
  margin: 2px 12px;
  border-radius: var(--mf-radius);
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-family: 'DM Sans', sans-serif;
  font-weight: 500;
  font-size: 0.875rem;
  transition: var(--mf-transition);
  position: relative;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.08);
  color: var(--mf-white);
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--mf-accent);
  color: var(--mf-white);
}

.sidebar-link.active::after {
  content: '';
  position: absolute;
  top: -4px;
  right: -4px;
  width: 16px;
  height: 3px;
  background: rgba(255,255,255,0.5);
  transform: rotate(45deg);
  border-radius: 2px;
}

.sidebar-link i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
}

/* ── CONTENIDO PRINCIPAL ── */
.main-content {
  margin-left: var(--mf-sidebar-width);
  min-height: 100vh;
  background: var(--mf-surface);
  transition: margin-left 0.3s ease;
  width: calc(100% - var(--mf-sidebar-width));
}

/* ── HEADER / TOPBAR ── */
.topbar {
  background: var(--mf-white);
  border-bottom: 1px solid var(--mf-border);
  padding: 12px var(--mf-space-lg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-family: 'Space Grotesk', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  color: var(--mf-primary-dark);
  margin: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ── CONTENIDO DE PÁGINA ── */
.page-content {
  padding: var(--mf-space-lg) var(--mf-space-xl);
}

/* ── ENLACES ── */
a {
  color: var(--mf-primary);
  text-decoration: none;
  transition: var(--mf-transition);
}

a:hover {
  color: var(--mf-primary-light);
}

/* ── DIVIDERS ── */
.divider {
  height: 1px;
  background: var(--mf-border);
  margin: var(--mf-space-md) 0;
}

/* ── AVATAR ── */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--mf-primary);
  color: var(--mf-white);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.85rem;
}

.avatar-sm {
  width: 28px;
  height: 28px;
  font-size: 0.7rem;
}

.avatar-lg {
  width: 48px;
  height: 48px;
  font-size: 1rem;
}

/* ── ALERTS ── */
.alert {
  border-radius: var(--mf-radius);
  font-size: 0.85rem;
  border: none;
}

.alert-success {
  background: var(--mf-success-bg);
  color: var(--mf-success);
  border-left: 4px solid var(--mf-success);
}

.alert-danger {
  background: var(--mf-danger-bg);
  color: var(--mf-danger);
  border-left: 4px solid var(--mf-danger);
}

.alert-warning {
  background: var(--mf-warning-bg);
  color: var(--mf-accent);
  border-left: 4px solid var(--mf-accent);
}

.alert-info {
  background: var(--mf-info-bg);
  color: var(--mf-info);
  border-left: 4px solid var(--mf-info);
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--mf-border);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--mf-text-muted);
}

/* ── UTILIDADES ── */
.bg-primary-dark { background: var(--mf-primary-dark) !important; }
.bg-accent { background: var(--mf-accent) !important; }
.bg-surface { background: var(--mf-surface) !important; }
.bg-white { background: var(--mf-white) !important; }

.border-accent { border-color: var(--mf-accent) !important; }
.border-primary { border-color: var(--mf-primary) !important; }

.rounded-custom { border-radius: var(--mf-radius) !important; }
.rounded-lg { border-radius: var(--mf-radius-lg) !important; }

.shadow-custom { box-shadow: var(--mf-shadow) !important; }
.shadow-lg { box-shadow: var(--mf-shadow-lg) !important; }

.transition { transition: var(--mf-transition); }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  
  .sidebar.show {
    transform: translateX(0);
  }
  
  .main-content {
    margin-left: 0;
  }
  
  .stat-card .stat-value {
    font-size: 1.25rem;
  }
  
  .page-content {
    padding: var(--mf-space-md);
  }
}

/* ── PRINT ── */
@media print {
  .sidebar, .topbar, .btn, .no-print {
    display: none !important;
  }
  
  .main-content {
    margin-left: 0 !important;
  }
  
  .card {
    box-shadow: none !important;
    border: 1px solid #ddd !important;
  }
}

/* ── ANIMACIONES ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease forwards;
}

.animate-slide-in {
  animation: slideIn 0.3s ease forwards;
}

/* Staggered animation for list items */
.table tbody tr {
  animation: fadeIn 0.3s ease forwards;
  opacity: 0;
}

.table tbody tr:nth-child(1) { animation-delay: 0.05s; }
.table tbody tr:nth-child(2) { animation-delay: 0.1s; }
.table tbody tr:nth-child(3) { animation-delay: 0.15s; }
.table tbody tr:nth-child(4) { animation-delay: 0.2s; }
.table tbody tr:nth-child(5) { animation-delay: 0.25s; }
.table tbody tr:nth-child(6) { animation-delay: 0.3s; }
.table tbody tr:nth-child(7) { animation-delay: 0.35s; }
.table tbody tr:nth-child(8) { animation-delay: 0.4s; }
