/* ── Reset & Variables ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --c-primary: #4F46E5;
  --c-primary-dark: #3730A3;
  --c-primary-light: #EEF2FF;
  --c-accent: #06B6D4;
  --c-success: #10B981;
  --c-warning: #F59E0B;
  --c-danger: #EF4444;
  --c-gray-50: #F9FAFB;
  --c-gray-100: #F3F4F6;
  --c-gray-200: #E5E7EB;
  --c-gray-300: #D1D5DB;
  --c-gray-400: #9CA3AF;
  --c-gray-500: #6B7280;
  --c-gray-600: #4B5563;
  --c-gray-700: #374151;
  --c-gray-800: #1F2937;
  --c-gray-900: #111827;
  --c-bg: #FFFFFF;
  --c-surface: #F9FAFB;
  --c-border: #E5E7EB;
  --c-text: #111827;
  --c-text-muted: #6B7280;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.14);
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --font: 'Inter', system-ui, sans-serif;
}

html { font-size: 16px; scroll-behavior: smooth; }
body { font-family: var(--font); color: var(--c-text); background: var(--c-bg);
       line-height: 1.6; -webkit-font-smoothing: antialiased; }

/* ── Typography ────────────────────────────────────────────── */
h1 { font-size: 2rem; font-weight: 700; }
h2 { font-size: 1.5rem; font-weight: 700; }
h3 { font-size: 1.125rem; font-weight: 600; }
h4 { font-size: 1rem; font-weight: 600; }
p  { color: var(--c-text-muted); }
a  { color: var(--c-primary); text-decoration: none; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .5rem;
  padding: .6rem 1.2rem; border-radius: var(--radius-md);
  font-size: .9rem; font-weight: 500; border: none; cursor: pointer;
  transition: all .18s ease; text-decoration: none; white-space: nowrap;
}
.btn-primary { background: var(--c-primary); color: #fff; }
.btn-primary:hover { background: var(--c-primary-dark); transform: translateY(-1px);
                     box-shadow: 0 4px 12px rgba(79,70,229,.35); }
.btn-secondary { background: var(--c-gray-100); color: var(--c-gray-700); }
.btn-secondary:hover { background: var(--c-gray-200); }
.btn-success { background: var(--c-success); color: #fff; }
.btn-danger  { background: var(--c-danger);  color: #fff; }
.btn-outline { background: transparent; border: 1.5px solid var(--c-border);
               color: var(--c-gray-700); }
.btn-outline:hover { border-color: var(--c-primary); color: var(--c-primary); }
.btn-sm { padding: .4rem .85rem; font-size: .82rem; }
.btn-lg { padding: .85rem 1.8rem; font-size: 1rem; }
.btn-icon { padding: .5rem; border-radius: 50%; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--c-bg); border: 1px solid var(--c-border);
  border-radius: var(--radius-lg); padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}
.card-header { display: flex; align-items: center; justify-content: space-between;
               margin-bottom: 1.25rem; }
.card-title { font-size: 1rem; font-weight: 600; color: var(--c-text); }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: .875rem; font-weight: 500;
              color: var(--c-gray-700); margin-bottom: .4rem; }
.form-control {
  width: 100%; padding: .6rem .875rem;
  border: 1.5px solid var(--c-border); border-radius: var(--radius-md);
  font-size: .9rem; font-family: var(--font); transition: border .15s;
  background: var(--c-bg); color: var(--c-text);
}
.form-control:focus { outline: none; border-color: var(--c-primary);
                      box-shadow: 0 0 0 3px rgba(79,70,229,.12); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: .3rem;
  padding: .25rem .65rem; border-radius: 999px;
  font-size: .75rem; font-weight: 600;
}
.badge-primary   { background: var(--c-primary-light); color: var(--c-primary); }
.badge-success   { background: #D1FAE5; color: #065F46; }
.badge-warning   { background: #FEF3C7; color: #92400E; }
.badge-danger    { background: #FEE2E2; color: #991B1B; }
.badge-gray      { background: var(--c-gray-100); color: var(--c-gray-600); }
.badge-info      { background: #E0F2FE; color: #0369A1; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert { padding: .85rem 1rem; border-radius: var(--radius-md);
         border-left: 4px solid; margin-bottom: 1rem; font-size: .9rem; }
.alert-success { background: #D1FAE5; border-color: var(--c-success); color: #065F46; }
.alert-danger  { background: #FEE2E2; border-color: var(--c-danger);  color: #991B1B; }
.alert-warning { background: #FEF3C7; border-color: var(--c-warning); color: #92400E; }
.alert-info    { background: #E0F2FE; border-color: var(--c-accent);  color: #0369A1; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius-lg);
                 border: 1px solid var(--c-border); }
table { width: 100%; border-collapse: collapse; }
thead { background: var(--c-gray-50); }
th { padding: .75rem 1rem; font-size: .8rem; font-weight: 600;
     text-transform: uppercase; letter-spacing: .04em;
     color: var(--c-gray-500); border-bottom: 1px solid var(--c-border); text-align: left; }
td { padding: .8rem 1rem; font-size: .9rem; border-bottom: 1px solid var(--c-gray-100); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--c-gray-50); }

/* ── Modals ─────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 1000; display: none; align-items: center; justify-content: center;
  padding: 1rem;
}
.modal-overlay.active { display: flex; }
.modal {
  background: var(--c-bg); border-radius: var(--radius-xl);
  padding: 2rem; width: 100%; max-width: 540px;
  box-shadow: var(--shadow-lg); position: relative;
  animation: slideUp .25s ease;
}
.modal-header { display: flex; justify-content: space-between;
                align-items: center; margin-bottom: 1.5rem; }
.modal-close { background: none; border: none; font-size: 1.5rem;
               cursor: pointer; color: var(--c-gray-400); padding: 0 .25rem; }
.modal-close:hover { color: var(--c-gray-700); }
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Sidebar Layout ─────────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); background: var(--c-gray-900);
  position: fixed; top: 0; left: 0; height: 100vh;
  display: flex; flex-direction: column; z-index: 100;
  transition: transform .25s ease;
}
.sidebar-logo {
  padding: 1.5rem; border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: .75rem;
}
.sidebar-logo-icon {
  width: 36px; height: 36px; background: var(--c-primary);
  border-radius: var(--radius-md); display: flex; align-items: center;
  justify-content: center; font-size: 1.1rem; color: #fff; font-weight: 700;
}
.sidebar-logo-text { font-weight: 700; font-size: 1rem; color: #fff; }
.sidebar-logo-sub  { font-size: .7rem; color: var(--c-gray-400); }
.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.nav-section { padding: .25rem 1rem; margin-bottom: .25rem; }
.nav-section-label { font-size: .65rem; font-weight: 700; text-transform: uppercase;
                     letter-spacing: .08em; color: var(--c-gray-500);
                     padding: .75rem .5rem .25rem; }
.nav-item {
  display: flex; align-items: center; gap: .75rem;
  padding: .6rem 1rem; border-radius: var(--radius-md); margin: .1rem .5rem;
  color: var(--c-gray-400); font-size: .875rem; font-weight: 500;
  transition: all .15s; cursor: pointer; text-decoration: none;
}
.nav-item:hover  { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: var(--c-primary); color: #fff; }
.nav-item .nav-icon { font-size: 1rem; width: 20px; text-align: center; }
.nav-badge { margin-left: auto; background: var(--c-danger); color: #fff;
             font-size: .65rem; font-weight: 700; padding: .15rem .45rem;
             border-radius: 999px; }
.sidebar-footer { padding: 1rem; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-user { display: flex; align-items: center; gap: .75rem; }
.sidebar-avatar { width: 36px; height: 36px; border-radius: 50%;
                  background: var(--c-primary); display: flex;
                  align-items: center; justify-content: center;
                  color: #fff; font-weight: 700; font-size: .9rem; }
.sidebar-user-info p { font-size: .875rem; font-weight: 500; color: #fff; }
.sidebar-user-info span { font-size: .75rem; color: var(--c-gray-400); }

/* ── Main Content ────────────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh;
                background: var(--c-surface); }
.topbar {
  height: var(--topbar-h); background: var(--c-bg);
  border-bottom: 1px solid var(--c-border);
  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; }
.topbar-title { font-weight: 600; font-size: 1.05rem; }
.topbar-right { display: flex; align-items: center; gap: .75rem; }
.page-content { padding: 1.75rem; }

/* ── Stat Cards ─────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
              gap: 1rem; margin-bottom: 1.75rem; }
.stat-card { background: var(--c-bg); border: 1px solid var(--c-border);
             border-radius: var(--radius-lg); padding: 1.25rem; display: flex;
             align-items: flex-start; gap: 1rem; box-shadow: var(--shadow-sm); }
.stat-icon { width: 48px; height: 48px; border-radius: var(--radius-md);
             display: flex; align-items: center; justify-content: center;
             font-size: 1.35rem; flex-shrink: 0; }
.stat-icon-blue   { background: var(--c-primary-light); }
.stat-icon-green  { background: #D1FAE5; }
.stat-icon-yellow { background: #FEF3C7; }
.stat-icon-red    { background: #FEE2E2; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--c-text); line-height: 1; }
.stat-label { font-size: .82rem; color: var(--c-text-muted); margin-top: .25rem; }

/* ── Priority / Status Colors ───────────────────────────────── */
.priority-alta   .badge, .badge-alta   { background: #FEE2E2; color: #991B1B; }
.priority-media  .badge, .badge-media  { background: #FEF3C7; color: #92400E; }
.priority-baja   .badge, .badge-baja   { background: #D1FAE5; color: #065F46; }
.priority-urgente .badge, .badge-urgente { background: #4F46E5; color: #fff; }

/* ── Toast ──────────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 1.5rem; right: 1.5rem;
                   z-index: 9999; display: flex; flex-direction: column; gap: .5rem; }
.toast {
  background: var(--c-gray-900); color: #fff; padding: .85rem 1.25rem;
  border-radius: var(--radius-md); font-size: .875rem; box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: .75rem;
  animation: toastIn .25s ease; min-width: 260px; max-width: 380px;
}
.toast.success { border-left: 4px solid var(--c-success); }
.toast.error   { border-left: 4px solid var(--c-danger); }
.toast.info    { border-left: 4px solid var(--c-accent); }
@keyframes toastIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Utils ──────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-1 { gap: .5rem; } .gap-2 { gap: 1rem; } .gap-3 { gap: 1.5rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
.mt-1 { margin-top: .5rem; } .mt-2 { margin-top: 1rem; } .mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; } .mb-2 { margin-bottom: 1rem; }
.text-sm { font-size: .875rem; } .text-xs { font-size: .75rem; }
.text-muted { color: var(--c-text-muted); }
.text-right { text-align: right; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.divider { height: 1px; background: var(--c-border); margin: 1.25rem 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
