@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&display=swap');

:root {
  --alegra-1: #7c3aed;
  --alegra-2: #4f46e5;
  --alegra-accent: #06b6d4;
  --surface: #ffffff;
  --bg: #f0f2fa;
  --text: #0f172a;
  --muted: #64748b;
  --border: #e2e8f0;
  --shadow: 0 8px 30px rgba(79,70,229,.10);
  --shadow-lg: 0 16px 48px rgba(79,70,229,.18);
  --radius: 18px;
  --radius-sm: 12px;
  
  /* Mapeo para compatibilidad con estilos antiguos */
  --card: var(--surface);
  --card-text: var(--text);
  --toast-success: #10b981;
  --toast-error: #ef4444;
  --toast-info: #3b82f6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  max-width: 100vw;
}

/* ── Hero / Encabezado ── */
.hero {
  background: linear-gradient(135deg, var(--alegra-1) 0%, var(--alegra-2) 55%, var(--alegra-accent) 100%);
  color: #fff;
  padding: 20px 24px;
  box-shadow: 0 4px 24px rgba(79,70,229,.25);
  position: relative;
  overflow: visible;
  margin-bottom: 20px;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.03'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  z-index: 1;
}
.hero-inner {
  width: 100%;
  max-width: 1350px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: relative;
  z-index: 2;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-logo {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: rgba(255,255,255,.20);
  backdrop-filter: blur(6px);
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 1.5px rgba(255,255,255,.30), 0 4px 10px rgba(0,0,0,.15);
}
.brand-logo svg { width: 24px; height: 24px; fill: #fff; }
.brand-info { display: flex; flex-direction: column; gap: 1px; }
.brand-title { font-size: 1.2rem; font-weight: 900; letter-spacing: -.3px; line-height: 1.2; }
.brand-sub { font-size: .78rem; opacity: .8; font-weight: 500; }

.hero-right, .userbox { display: flex; align-items: center; gap: 12px; }
.user-chip, .user-pic-container {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255,255,255,.16);
  padding: 6px 14px 6px 8px;
  border-radius: 50px;
  backdrop-filter: blur(4px);
}
.user-avatar, .user-pic {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: grid; place-items: center;
}
.user-avatar svg, .user-pic svg { width: 15px; height: 15px; fill: #fff; }
.user-name { font-weight: 700; font-size: .88rem; color: #fff; }
.btn-logout, .logout {
  color: #fff; text-decoration: none;
  font-weight: 700; font-size: .88rem;
  padding: 7px 14px;
  border-radius: 10px;
  background: rgba(255,255,255,.16);
  transition: background .2s;
}
.btn-logout:hover, .logout:hover { background: rgba(255,255,255,.26); }

/* ── Wrappers de pagina ── */
.page-wrap, .wrap {
  width: 100%;
  max-width: 1350px;
  margin: 0 auto;
  padding: 0 20px 40px;
}
.container {
  width: 100%;
  display: grid;
  gap: 16px;
}

/* ── Tarjetas ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  margin-bottom: 16px;
}

/* ── Breadcrumbs ── */
.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: .85rem; color: var(--muted);
  margin-bottom: 16px;
}
.breadcrumb a { color: var(--alegra-2); text-decoration: none; font-weight: 600; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb span { opacity: .5; }

/* ── Titulos de Seccion ── */
.block-title {
  font-size: 1.35rem;
  font-weight: 850;
  color: var(--text);
  margin-bottom: 12px;
}

/* ── Formularios e Inputs ── */
input[type="text"], input[type="password"], input[type="search"], input[type="date"], input[type="time"], input[type="number"], input[type="email"], input[type="tel"], select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: .95rem;
  background: #fff;
  color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  font-family: inherit;
}

/* Colorear iconos nativos de fecha y hora */
input[type="date"]::-webkit-calendar-picker-indicator,
input[type="time"]::-webkit-calendar-picker-indicator {
  cursor: pointer;
  filter: invert(34%) sepia(85%) saturate(2220%) hue-rotate(231deg) brightness(89%) contrast(92%); /* #4f46e5 (var(--alegra-2)) */
  opacity: 0.8;
  transition: opacity 0.15s;
}
input[type="date"]::-webkit-calendar-picker-indicator:hover,
input[type="time"]::-webkit-calendar-picker-indicator:hover {
  opacity: 1;
}
input:focus, select:focus, textarea:focus {
  border-color: #a5b4fc;
  outline: none;
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}
label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #334155;
  font-size: .9rem;
}
.form-group {
  margin-bottom: 16px;
}

/* ── Botones ── */
.btn, button.btn, a.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 18px; border: 0; border-radius: 10px; cursor: pointer;
  font-weight: 700; font-size: .92rem; text-decoration: none;
  background: linear-gradient(135deg, var(--alegra-1) 0%, var(--alegra-2) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79,70,229,.15);
  transition: transform .15s, box-shadow .15s, opacity .15s;
}
.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(79,70,229,.25); }
.btn:active { transform: translateY(0); }
.btn.secondary, button.btn.secondary, a.btn.secondary {
  background: #e2e8f0; color: #0f172a; box-shadow: none;
}
.btn.secondary:hover { background: #cbd5e1; box-shadow: none; transform: none; }
.btn.success, button.btn.success, a.btn.success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  box-shadow: 0 4px 12px rgba(16,185,129,.15);
}
.btn.success:hover { box-shadow: 0 6px 16px rgba(16,185,129,.25); }
.btn.danger, button.btn.danger, a.btn.danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 4px 12px rgba(239,68,68,.15);
}
.btn.danger:hover { box-shadow: 0 6px 16px rgba(239,68,68,.25); }
.btn.xs, button.btn.xs, a.btn.xs {
  padding: 6px 10px; font-size: .82rem; border-radius: 8px;
}

/* ── Tablas ── */
.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
table {
  width: 100%;
  border-collapse: collapse;
}
th {
  text-align: left;
  padding: 12px 14px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  color: #475569;
  font-weight: 700;
  font-size: .88rem;
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: .9rem;
  vertical-align: middle;
}
tr:last-child td {
  border-bottom: 0;
}
tr:hover {
  background: #f8fafc;
}

/* ── Banners de Estado ── */
.info-banner {
  background: linear-gradient(135deg, rgba(124,58,237,.07), rgba(6,182,212,.05));
  border: 1px solid #c7d2fe;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  display: flex; align-items: flex-start; gap: 12px;
  margin-bottom: 20px;
}
.info-banner svg { width: 20px; height: 20px; fill: var(--alegra-2); flex-shrink: 0; margin-top: 1px; }
.info-banner p { margin: 0; font-size: .9rem; color: #3730a3; font-weight: 500; }

.btn-back {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--alegra-2);
  font-weight: 700; font-size: .88rem;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(2,6,23,.06);
  transition: box-shadow .15s, transform .15s;
  margin-bottom: 16px;
}
.btn-back:hover { transform: translateX(-2px); box-shadow: 0 4px 14px rgba(2,6,23,.10); }
.btn-back svg { width: 16px; height: 16px; fill: currentColor; }

.notice {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #ecfdf5;
  color: #065f46;
  border: 1px solid #a7f3d0;
  font-weight: 600;
  margin-bottom: 16px;
}
.error {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  font-weight: 600;
  margin-bottom: 16px;
}

/* ── Toast ── */
.toast {
  position: fixed; top: 16px; right: 16px; z-index: 99999;
  background: #10b981; color: #fff; padding: 12px 18px;
  border-radius: 12px; box-shadow: 0 12px 30px rgba(2,6,23,.2);
  opacity: 0; transform: translateY(-8px); pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  font-weight: 700; max-width: min(90vw, 380px);
}
.toast.show { opacity: 1; transform: translateY(0); pointer-events: auto; }
.toast.success { background: #10b981; }
.toast.error { background: #ef4444; }
.toast.info { background: #3b82f6; }

/* Compatibilidad con sidebar colapsada */
.wrapper.is-collapsed .brand-name,
.wrapper.is-collapsed .nav-label,
.wrapper.is-collapsed .logout-btn span{ display:none; }
.wrapper.is-collapsed .nav-item{ justify-content:center; }
.wrapper.is-collapsed .nav-item:hover{ transform:none }

/* ── Grid de tarjetas y baldosas ── */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-decoration: none;
  color: var(--text);
  transition: transform .18s, box-shadow .18s, border-color .18s;
  position: relative;
  overflow: hidden;
}
.tile::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  background: linear-gradient(135deg, rgba(124,58,237,.06), rgba(6,182,212,.04));
  transition: opacity .2s;
}
.tile:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: #c7d2fe; }
.tile:hover::after { opacity: 1; }

.tile-icon {
  width: 52px; height: 52px; min-width: 52px;
  border-radius: 14px;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.tile-icon svg { width: 26px; height: 26px; fill: #fff; }
.tile-icon.purple { background: linear-gradient(135deg,#7c3aed,#6d28d9); box-shadow: 0 6px 16px rgba(124,58,237,.30); }
.tile-icon.indigo { background: linear-gradient(135deg,#4f46e5,#4338ca); box-shadow: 0 6px 16px rgba(79,70,229,.30); }
.tile-icon.cyan   { background: linear-gradient(135deg,#0891b2,#06b6d4); box-shadow: 0 6px 16px rgba(6,182,212,.30); }
.tile-icon.emerald{ background: linear-gradient(135deg,#059669,#10b981); box-shadow: 0 6px 16px rgba(16,185,129,.30); }

.tile-body { flex: 1; min-width: 0; }
.tile-body h3 { margin: 0 0 5px; font-size: 1rem; font-weight: 800; color: var(--text); }
.tile-body p  { margin: 0; color: var(--muted); font-size: .88rem; line-height: 1.4; }
.tile-arrow {
  align-self: center;
  opacity: .35;
  transition: opacity .18s, transform .18s;
  flex-shrink: 0;
}
.tile:hover .tile-arrow { opacity: .8; transform: translateX(3px); }
.tile-arrow svg { width: 18px; height: 18px; fill: var(--muted); }

/* ── Estilos Adaptativos y de Responsividad Global ── */
@media (max-width: 992px) {
  /* En tablets, mejoramos el comportamiento del grid */
  .grid {
    grid-template-columns: repeat(12, 1fr) !important;
  }
  .col-6, .col-8 {
    grid-column: span 12 !important;
  }
  .col-4, .col-3, .col-2 {
    grid-column: span 6 !important;
  }
}

@media (max-width: 680px) {
  /* Diseño adaptativo para dispositivos móviles */
  .hero-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }
  .hero-right {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
  }
  .brand-logo {
    width: 36px;
    height: 36px;
  }
  .brand-logo svg {
    width: 20px;
    height: 20px;
  }
  .brand-title {
    font-size: 1.1rem;
  }
  .page-wrap, .wrap {
    padding: 0 12px 30px;
  }
  .card {
    padding: 16px;
    border-radius: 14px;
  }
}

@media (max-width: 576px) {
  /* Elementos de formulario full-width en pantallas pequeñas */
  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .contact-search-form, .search-form {
    width: 100%;
    flex-direction: column;
    align-items: stretch;
  }
  .search-input {
    width: 100%;
    flex: none;
  }
  .actions-dropdown {
    margin-left: 0;
    width: 100%;
  }
  .actions-dropdown button {
    width: 100%;
  }
  .actions-menu {
    width: 100%;
    right: auto;
    left: 0;
  }
  .bulk-actions {
    flex-direction: column;
    align-items: stretch;
  }
  .bulk-actions button {
    width: 100%;
  }
  .tbl-actions {
    flex-direction: column;
    gap: 4px;
  }
  .tbl-actions button, .tbl-actions form {
    width: 100%;
  }
  .tbl-actions button {
    width: 100% !important;
  }
  .col-6, .col-4, .col-3, .col-2, .col-8, .col-12 {
    grid-column: span 12 !important;
  }
  .grid {
    gap: 10px;
  }
}

/* ── Modal y Diálogos Globales ── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.46);
  backdrop-filter: blur(4px);
}
.modal.is-open {
  display: flex !important;
}
.modal-dialog {
  width: min(500px, 94vw);
  background: #fff;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 20px 50px rgba(0,0,0,0.15);
  overflow: hidden;
  animation: modalFadeIn 0.25s ease-out forwards;
}
.modal-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 {
  margin: 0;
  font-size: 1.2rem;
}
.modal-body {
  padding: 20px;
}
.modal-close {
  background: transparent;
  border: 0;
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
  color: var(--text-muted);
}
@keyframes modalFadeIn {
  from { transform: scale(0.95); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}


