/* =====================================================
   MANTENIMIENTO PRO — Estilos principales
   Fuente: DM Sans + Sora (Google Fonts)
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@300;400;500;600&family=Sora:wght@400;600;700&display=swap');

:root {
  --azul:        #1a56db;
  --azul-dark:   #1245b8;
  --azul-light:  #e8f0fe;
  --verde:       #057a55;
  --verde-light: #def7ec;
  --rojo:        #c81e1e;
  --rojo-light:  #fde8e8;
  --naranja:     #b45309;
  --naranja-light:#fef3c7;
  --gris-1:      #f9fafb;
  --gris-2:      #f3f4f6;
  --gris-3:      #e5e7eb;
  --gris-4:      #9ca3af;
  --gris-5:      #6b7280;
  --gris-6:      #374151;
  --negro:       #111827;
  --blanco:      #ffffff;
  --sidebar-w:   240px;
  --header-h:    64px;
  --radio:       10px;
  --sombra:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --sombra-md:   0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
}

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

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--gris-1);
  color: var(--negro);
  line-height: 1.6;
  min-height: 100vh;
}

/* ---- TIPOGRAFÍA ---- */
h1, h2, h3, h4 { font-family: 'Sora', sans-serif; font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a { color: var(--azul); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- LOGIN ---- */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 60%, #1a56db 100%);
  padding: 1rem;
}

.login-card {
  background: var(--blanco);
  border-radius: 16px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo .icono {
  width: 60px; height: 60px;
  background: var(--azul-light);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 1rem;
  font-size: 1.8rem;
}

.login-logo h1 { font-size: 1.4rem; color: var(--negro); }
.login-logo p  { color: var(--gris-5); font-size: .875rem; margin-top: .25rem; }

/* ---- LAYOUT PRINCIPAL ---- */
.app-wrapper { display: flex; min-height: 100vh; }

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-w);
  background: #0f172a;
  color: #e2e8f0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-brand .nombre {
  font-family: 'Sora', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.01em;
}

.sidebar-brand .version {
  font-size: .7rem;
  color: #64748b;
  margin-top: 2px;
}

.sidebar-menu {
  flex: 1;
  padding: .75rem 0;
  overflow-y: auto;
}

.menu-label {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .08em;
  color: #475569;
  text-transform: uppercase;
  padding: .75rem 1.25rem .25rem;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .6rem 1.25rem;
  color: #94a3b8;
  font-size: .875rem;
  cursor: pointer;
  border-radius: 0;
  transition: background .15s, color .15s;
  text-decoration: none;
  position: relative;
}

.menu-item:hover { background: rgba(255,255,255,.06); color: #e2e8f0; text-decoration: none; }

.menu-item.active {
  background: rgba(26,86,219,.2);
  color: #93c5fd;
}

.menu-item.active::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 3px;
  background: var(--azul);
  border-radius: 0 3px 3px 0;
}

.menu-item .icono { font-size: 1rem; width: 20px; text-align: center; }

.menu-badge {
  margin-left: auto;
  background: var(--rojo);
  color: #fff;
  font-size: .65rem;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
}

.sidebar-footer {
  padding: .875rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .8rem;
  color: #475569;
}

.sidebar-footer .usuario { color: #94a3b8; font-weight: 500; }

/* MAIN CONTENT */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--header-h);
  background: var(--blanco);
  border-bottom: 1px solid var(--gris-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 1rem; }

.btn-menu-mobile {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--gris-6);
  padding: .25rem;
}

.page-title { font-family: 'Sora', sans-serif; font-size: 1.1rem; font-weight: 600; }
.page-subtitle { font-size: .8rem; color: var(--gris-5); margin-top: 1px; }

.topbar-right { display: flex; align-items: center; gap: .75rem; }

.page-body { padding: 1.5rem; flex: 1; }

/* ---- COMPONENTES ---- */

/* Cards */
.card {
  background: var(--blanco);
  border-radius: var(--radio);
  border: 1px solid var(--gris-3);
  box-shadow: var(--sombra);
}

.card-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--gris-3);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.card-body { padding: 1.25rem; }

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--blanco);
  border-radius: var(--radio);
  border: 1px solid var(--gris-3);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  box-shadow: var(--sombra);
}

.stat-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

.stat-icon.rojo    { background: var(--rojo-light); }
.stat-icon.naranja { background: var(--naranja-light); }
.stat-icon.verde   { background: var(--verde-light); }
.stat-icon.azul    { background: var(--azul-light); }

.stat-valor { font-family: 'Sora', sans-serif; font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: .8rem; color: var(--gris-5); margin-top: .25rem; }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .5rem 1rem;
  border-radius: 8px;
  font-size: .875rem;
  font-weight: 500;
  font-family: 'DM Sans', sans-serif;
  border: none;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { text-decoration: none; filter: brightness(.93); }
.btn:active { transform: scale(.98); }

.btn-primary  { background: var(--azul);   color: #fff; }
.btn-success  { background: var(--verde);  color: #fff; }
.btn-danger   { background: var(--rojo);   color: #fff; }
.btn-ghost    { background: var(--gris-2); color: var(--gris-6); }
.btn-outline  { background: transparent; color: var(--azul); border: 1px solid var(--azul); }
.btn-whatsapp { background: #25d366; color: #fff; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: 1rem; }
.btn-full { width: 100%; justify-content: center; }

/* Forms */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 500; color: var(--gris-6); margin-bottom: .35rem; }
.form-label .req { color: var(--rojo); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: .55rem .875rem;
  border: 1px solid var(--gris-3);
  border-radius: 8px;
  font-size: .9rem;
  font-family: 'DM Sans', sans-serif;
  color: var(--negro);
  background: var(--blanco);
  transition: border-color .15s, box-shadow .15s;
  appearance: none;
}

.form-control:focus {
  outline: none;
  border-color: var(--azul);
  box-shadow: 0 0 0 3px rgba(26,86,219,.12);
}

.form-control::placeholder { color: var(--gris-4); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right .75rem center; padding-right: 2rem; }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.form-full { grid-column: 1 / -1; }
.form-hint { font-size: .78rem; color: var(--gris-5); margin-top: .25rem; }

.form-error { font-size: .78rem; color: var(--rojo); margin-top: .25rem; }

/* Tables */
.table-wrap { overflow-x: auto; }

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.data-table th {
  background: var(--gris-1);
  color: var(--gris-5);
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .625rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gris-3);
  white-space: nowrap;
}

.data-table td {
  padding: .875rem 1rem;
  border-bottom: 1px solid var(--gris-2);
  color: var(--gris-6);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gris-1); }

.data-table .nombre-cliente { font-weight: 500; color: var(--negro); }
.data-table .sub { font-size: .78rem; color: var(--gris-5); margin-top: 1px; }

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}

.badge-rojo    { background: var(--rojo-light);    color: var(--rojo); }
.badge-naranja { background: var(--naranja-light);  color: var(--naranja); }
.badge-verde   { background: var(--verde-light);   color: var(--verde); }
.badge-azul    { background: var(--azul-light);    color: var(--azul); }
.badge-gris    { background: var(--gris-2);        color: var(--gris-5); }

/* Alert messages */
.alert {
  padding: .875rem 1rem;
  border-radius: 8px;
  font-size: .875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: .625rem;
}

.alert-success { background: var(--verde-light); color: var(--verde); }
.alert-danger  { background: var(--rojo-light);  color: var(--rojo); }
.alert-info    { background: var(--azul-light);  color: var(--azul); }
.alert-warning { background: var(--naranja-light); color: var(--naranja); }

/* Días restantes indicador */
.dias-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .75rem;
  border-radius: 20px;
  font-size: .8rem;
  font-weight: 600;
}

.dias-chip.vencido   { background: var(--rojo-light);    color: var(--rojo); }
.dias-chip.urgente   { background: var(--naranja-light);  color: var(--naranja); }
.dias-chip.proximo   { background: var(--azul-light);    color: var(--azul); }
.dias-chip.ok        { background: var(--verde-light);   color: var(--verde); }

/* Quick actions */
.quick-actions {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gris-5);
}

.empty-state .icono { font-size: 2.5rem; margin-bottom: .75rem; }
.empty-state h3 { font-size: 1rem; color: var(--gris-6); margin-bottom: .5rem; }
.empty-state p { font-size: .875rem; }

/* Overlay sidebar mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 99;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: .25rem;
  padding: .875rem 1rem;
  border-top: 1px solid var(--gris-3);
  font-size: .875rem;
  flex-wrap: wrap;
}

.pag-info { color: var(--gris-5); margin-right: auto; }

.pag-btn {
  padding: .35rem .625rem;
  border-radius: 6px;
  border: 1px solid var(--gris-3);
  background: var(--blanco);
  cursor: pointer;
  color: var(--gris-6);
  font-size: .875rem;
  text-decoration: none;
}

.pag-btn:hover { background: var(--gris-2); text-decoration: none; }
.pag-btn.active { background: var(--azul); color: #fff; border-color: var(--azul); }

/* Search */
.search-box {
  position: relative;
  max-width: 280px;
  flex: 1;
}

.search-box input { padding-left: 2.25rem; }
.search-box .icon { position: absolute; left: .75rem; top: 50%; transform: translateY(-50%); color: var(--gris-4); font-size: .875rem; pointer-events: none; }

/* Variables textarea */
.vars-list {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  margin-top: .5rem;
}

.var-chip {
  background: var(--azul-light);
  color: var(--azul);
  padding: .15rem .5rem;
  border-radius: 4px;
  font-size: .75rem;
  font-family: monospace;
  cursor: pointer;
  border: none;
  transition: background .15s;
}

.var-chip:hover { background: #d1e0fd; }

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }

  .sidebar {
    width: 260px;
    transform: translateX(-100%);
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }

  .main-content { margin-left: 0; }

  .btn-menu-mobile { display: flex; }

  .form-grid { grid-template-columns: 1fr; }
  .form-full { grid-column: 1; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .topbar { padding: 0 1rem; }
  .page-body { padding: 1rem; }

  .card-header { flex-direction: column; align-items: flex-start; }

  .data-table th, .data-table td { padding: .625rem .75rem; }

  h1 { font-size: 1.35rem; }

  .quick-actions { gap: .5rem; }
  .quick-actions .btn { flex: 1; justify-content: center; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .search-box { max-width: 100%; }
}
