/* =============================================
   GESTION SOCIAL - Design System
   ============================================= */

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

:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #818cf8;
  --secondary: #06b6d4;
  --accent: #f59e0b;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --info: #3b82f6;

  --bg-dark: #0f0f1a;
  --bg-card: #1a1a2e;
  --bg-card2: #16213e;
  --bg-input: #0f3460;
  --border: rgba(99,102,241,0.25);
  --border-hover: rgba(99,102,241,0.6);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 25px 50px rgba(0,0,0,0.5);
  --shadow-card: 0 8px 32px rgba(0,0,0,0.4);
  --glow: 0 0 30px rgba(99,102,241,0.3);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg-dark);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Animated BG ── */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 20% -20%, rgba(99,102,241,0.15) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 110%, rgba(6,182,212,0.12) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Auth Layout ── */
.auth-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  position: relative;
  z-index: 1;
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3rem 2.5rem;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow), var(--glow);
  animation: slideUp .5s ease;
}

.auth-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.auth-logo .logo-icon {
  width: 70px; height: 70px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  border-radius: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(99,102,241,0.4);
}
.auth-logo h1 { font-size: 1.6rem; font-weight: 700; }
.auth-logo p  { color: var(--text-secondary); font-size: .9rem; margin-top: .25rem; }

.auth-title { font-size: 1.4rem; font-weight: 700; margin-bottom: .35rem; }
.auth-sub   { color: var(--text-secondary); font-size: .9rem; margin-bottom: 2rem; }

/* ── Form Elements ── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: .5rem;
}
.input-wrap { position: relative; }
.input-icon {
  position: absolute;
  left: 1rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
  pointer-events: none;
}
.form-control {
  width: 100%;
  padding: .85rem 1rem .85rem 2.8rem;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: .95rem;
  transition: border-color .25s, box-shadow .25s, background .25s;
  outline: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,0.2);
  background: rgba(99,102,241,0.05);
}
.form-control.no-icon { padding-left: 1rem; }
select.form-control { cursor: pointer; }
.input-toggle {
  position: absolute;
  right: 1rem; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer; font-size: 1rem;
  padding: 0;
  transition: color .2s;
}
.input-toggle:hover { color: var(--primary); }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* ── Radio / Checkbox ── */
.radio-group { display: flex; gap: 1rem; }
.radio-option {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.radio-option:hover   { border-color: var(--primary-light); background: rgba(99,102,241,0.06); }
.radio-option input   { accent-color: var(--primary); width: 16px; height: 16px; }
.radio-option.selected { border-color: var(--primary); background: rgba(99,102,241,0.1); }
.radio-option span    { font-size: .9rem; font-weight: 500; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .85rem 1.5rem;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .25s;
  text-decoration: none;
  white-space: nowrap;
}
.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
  width: 100%;
}
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(99,102,241,0.55);
}
.btn-secondary {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text-primary);
}
.btn-secondary:hover { background: rgba(255,255,255,0.1); border-color: var(--primary); }

.btn-sm { padding: .5rem 1rem; font-size: .85rem; border-radius: 8px; }
.btn-success { background: linear-gradient(135deg,#10b981,#059669); color:#fff; box-shadow:0 4px 16px rgba(16,185,129,.35); }
.btn-success:hover { transform:translateY(-1px); box-shadow:0 6px 22px rgba(16,185,129,.5); }
.btn-danger  { background: linear-gradient(135deg,#ef4444,#dc2626); color:#fff; box-shadow:0 4px 16px rgba(239,68,68,.35); }
.btn-danger:hover  { transform:translateY(-1px); box-shadow:0 6px 22px rgba(239,68,68,.5); }
.btn-info    { background: linear-gradient(135deg,#3b82f6,#2563eb); color:#fff; }
.btn-warning { background: linear-gradient(135deg,#f59e0b,#d97706); color:#fff; }
.btn-icon    { width:38px; height:38px; padding:0; border-radius:8px; }

/* ── Links ── */
.auth-links { text-align: center; margin-top: 1.25rem; }
.auth-links a {
  color: var(--primary-light);
  text-decoration: none;
  font-size: .88rem;
  font-weight: 500;
  transition: color .2s;
}
.auth-links a:hover { color: #fff; }
.auth-links span { color: var(--text-muted); margin: 0 .5rem; font-size: .8rem; }

/* ── Alerts ── */
.alert {
  padding: .85rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .88rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  gap: .6rem;
  display: none;
}
.alert.show { display: flex; }
.alert-danger  { background:rgba(239,68,68,.12);  border:1px solid rgba(239,68,68,.3);  color:#fca5a5; }
.alert-success { background:rgba(16,185,129,.12); border:1px solid rgba(16,185,129,.3); color:#6ee7b7; }
.alert-info    { background:rgba(59,130,246,.12); border:1px solid rgba(59,130,246,.3); color:#93c5fd; }

/* ── Role Badge ── */
.role-select { display: grid; grid-template-columns: repeat(3,1fr); gap: .75rem; }
.role-card {
  padding: .85rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.role-card .role-icon { font-size: 1.5rem; display: block; margin-bottom: .35rem; }
.role-card .role-name { font-size: .78rem; font-weight: 600; }
.role-card:hover     { border-color: var(--primary); background:rgba(99,102,241,.08); }
.role-card.selected  { border-color: var(--primary); background:rgba(99,102,241,.15); box-shadow:var(--glow); }

/* ==========================================
   DASHBOARD
   ========================================== */
.app-layout {
  display: flex;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s;
}
.sidebar-logo {
  padding: 1.5rem 1.5rem 1rem;
  display: flex;
  align-items: center;
  gap: .85rem;
  border-bottom: 1px solid var(--border);
}
.sidebar-logo .logo-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg,var(--primary),var(--secondary));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.sidebar-logo .logo-text { font-weight: 700; font-size: .95rem; line-height: 1.3; }
.sidebar-logo .logo-text small { display: block; color: var(--text-muted); font-size: .72rem; font-weight: 400; }

.sidebar-nav { flex: 1; padding: 1rem 0; overflow-y: auto; }
.nav-section { padding: .5rem 1.5rem .3rem; font-size: .7rem; font-weight: 600; color: var(--text-muted); letter-spacing: .08em; text-transform: uppercase; }
.nav-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .7rem 1.5rem;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
  border-left: 3px solid transparent;
  margin: 1px 0;
}
.nav-item:hover { color: var(--text-primary); background: rgba(99,102,241,.07); border-left-color: var(--primary-light); }
.nav-item.active { color: var(--primary-light); background: rgba(99,102,241,.12); border-left-color: var(--primary); }
.nav-item .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }
.nav-item .badge {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: .7rem;
  padding: 2px 7px;
  border-radius: 20px;
}

.sidebar-user {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: .85rem;
}
.user-avatar {
  width: 40px; height: 40px;
  background: linear-gradient(135deg,var(--primary),var(--secondary));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: .95rem;
  flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: .88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-info .role { font-size: .72rem; color: var(--primary-light); }
.logout-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.1rem; padding: .25rem; transition: color .2s; }
.logout-btn:hover { color: var(--danger); }

/* Main */
.main-content {
  margin-left: 260px;
  flex: 1;
  padding: 2rem;
  min-height: 100vh;
}

/* Topbar */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2rem;
}
.page-title h2 { font-size: 1.6rem; font-weight: 700; }
.page-title p  { color: var(--text-secondary); font-size: .88rem; margin-top: .2rem; }
.topbar-actions { display: flex; align-items: center; gap: 1rem; }
.date-chip {
  background: rgba(255,255,255,.05);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .5rem .85rem;
  font-size: .82rem;
  color: var(--text-secondary);
}

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit,minmax(200px,1fr)); gap: 1.25rem; margin-bottom: 2rem; }
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform .25s, box-shadow .25s;
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-card); }
.stat-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.stat-icon.blue   { background:rgba(99,102,241,.18); }
.stat-icon.cyan   { background:rgba(6,182,212,.18); }
.stat-icon.green  { background:rgba(16,185,129,.18); }
.stat-icon.orange { background:rgba(245,158,11,.18); }
.stat-body .value { font-size: 1.8rem; font-weight: 800; }
.stat-body .label { color: var(--text-secondary); font-size: .82rem; margin-top: .1rem; }

/* Section */
.section-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 1.5rem;
}
.section-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.section-header h3 { font-size: 1.05rem; font-weight: 600; }
.section-body { padding: 1.5rem; }

/* Search Bar */
.search-bar {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.search-input-wrap { position: relative; flex: 1; min-width: 240px; }
.search-input-wrap .search-icon {
  position: absolute;
  left: 1rem; top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
.search-input {
  width: 100%;
  padding: .8rem 1rem .8rem 2.8rem;
  background: rgba(255,255,255,.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: .95rem;
  outline: none;
  transition: border-color .25s, box-shadow .25s;
}
.search-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,.2); }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
  padding: .85rem 1rem;
  text-align: left;
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: .06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: .9rem 1rem;
  font-size: .88rem;
  border-bottom: 1px solid rgba(255,255,255,.04);
  vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(99,102,241,.04); }
.td-actions { display: flex; gap: .5rem; }

.badge-sex {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-sex.m { background:rgba(59,130,246,.18); color:#93c5fd; }
.badge-sex.f { background:rgba(236,72,153,.18); color:#f9a8d4; }

.badge-role {
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 600;
}
.badge-role.admin  { background:rgba(99,102,241,.2); color:var(--primary-light); }
.badge-role.editor { background:rgba(245,158,11,.2); color:#fcd34d; }
.badge-role.viewer { background:rgba(16,185,129,.2); color:#6ee7b7; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000;
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
  padding: 1rem;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%; max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow);
  transform: scale(.92) translateY(20px);
  transition: transform .3s;
}
.modal-overlay.open .modal { transform: scale(1) translateY(0); }
.modal-header {
  padding: 1.5rem 1.5rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0;
  background: var(--bg-card);
  z-index: 10;
}
.modal-header h3 { font-size: 1.15rem; font-weight: 700; }
.modal-close { background:none; border:none; color:var(--text-muted); cursor:pointer; font-size:1.3rem; padding:.25rem; transition:color .2s; }
.modal-close:hover { color:var(--danger); }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 1rem;
  position: sticky; bottom: 0;
  background: var(--bg-card);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .empty-icon { font-size: 3rem; margin-bottom: 1rem; opacity: .5; }
.empty-state p { font-size: .95rem; }

/* Animations */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(30px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.fade-in { animation: fadeIn .4s ease; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .role-select { grid-template-columns: 1fr 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }

/* Divider */
.divider {
  display: flex; align-items: center; gap: 1rem;
  margin: 1.25rem 0; color: var(--text-muted); font-size: .82rem;
}
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem; right: 1.5rem;
  z-index: 9999;
  display: flex; flex-direction: column; gap: .75rem;
}
.toast {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1.25rem;
  display: flex;
  align-items: center;
  gap: .75rem;
  min-width: 260px;
  box-shadow: var(--shadow-card);
  animation: slideRight .35s ease;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }
.toast .toast-icon { font-size: 1.2rem; }
.toast .toast-msg  { font-size: .88rem; }
@keyframes slideRight {
  from { opacity: 0; transform: translateX(40px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Loading Spinner */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid rgba(255,255,255,.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
