/* ============================================================
   assets/css/admin.css — Panel Administración Yo Apoyo a Construir RD
   Basado en el dashboard mostrado en la imagen de referencia
   ============================================================ */

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

:root {
  --a-verde:        #2d7a2d;
  --a-verde-claro:  #4CAF50;
  --a-verde-dark:   #1a4a1a;
  --a-bg:           #0d1f0d;
  --a-sidebar-bg:   #0f2a0f;
  --a-card-bg:      #162916;
  --a-border:       rgba(76,175,80,0.2);
  --a-text:         #e8f5e9;
  --a-text-muted:   rgba(232,245,233,0.6);
  --a-accent:       #66BB6A;
  --a-active:       #4CAF50;
  --a-danger:       #ef4444;
  --a-warning:      #f59e0b;
  --a-info:         #3b82f6;
  --a-white:        #fff;
  --a-shadow:       0 4px 20px rgba(0,0,0,0.4);
  --a-radius:       10px;
  --a-radius-lg:    16px;
  --sidebar-width:  240px;
  --topbar-height:  64px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--a-bg);
  color: var(--a-text);
  display: flex;
  min-height: 100vh;
}

/* -------- SIDEBAR -------- */
.admin-sidebar {
  width: var(--sidebar-width);
  background: var(--a-sidebar-bg);
  border-right: 1px solid var(--a-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  padding: 1.2rem 1.4rem;
  border-bottom: 1px solid var(--a-border);
  display: flex;
  align-items: center;
  gap: 0.8rem;
  text-decoration: none;
}
.sidebar-brand img {
  width: 38px; height: 38px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--a-verde-claro);
}
.sidebar-brand-text { line-height: 1.2; }
.sidebar-brand-text .brand-top { font-size: 0.62rem; color: var(--a-text-muted); text-transform: uppercase; letter-spacing: 1px; }
.sidebar-brand-text .brand-name { font-family: 'Outfit', sans-serif; font-size: 0.95rem; font-weight: 800; color: var(--a-white); }

.sidebar-nav { flex: 1; padding: 1rem 0; }
.sidebar-section-label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--a-text-muted);
  padding: 0.8rem 1.4rem 0.3rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 1.4rem;
  color: var(--a-text-muted);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.2s;
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-link:hover {
  background: rgba(76,175,80,0.08);
  color: var(--a-text);
  border-left-color: rgba(76,175,80,0.4);
}
.sidebar-link.active {
  background: rgba(76,175,80,0.15);
  color: var(--a-verde-claro);
  border-left-color: var(--a-verde-claro);
  font-weight: 700;
}
.sidebar-link .link-icon { font-size: 1rem; width: 20px; text-align: center; flex-shrink: 0; }

.sidebar-footer {
  padding: 1rem 1.4rem;
  border-top: 1px solid var(--a-border);
  font-size: 0.72rem;
  color: var(--a-text-muted);
  line-height: 1.5;
}
.sidebar-footer .sf-brand { font-family: 'Outfit', sans-serif; font-weight: 800; color: var(--a-verde-claro); font-size: 0.85rem; }

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

/* -------- TOPBAR -------- */
.admin-topbar {
  position: sticky;
  top: 0;
  z-index: 90;
  height: var(--topbar-height);
  background: rgba(13,31,13,0.98);
  border-bottom: 1px solid var(--a-border);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  padding: 0 1.8rem;
  gap: 1rem;
}

.topbar-title { flex: 1; }
.topbar-title h1 { font-size: 1.1rem; font-weight: 700; color: var(--a-white); }
.topbar-title p  { font-size: 0.72rem; color: var(--a-text-muted); margin-top: 1px; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.topbar-bell {
  position: relative;
  background: none;
  border: none;
  color: var(--a-text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  transition: all 0.2s;
}
.topbar-bell:hover { background: rgba(76,175,80,0.1); color: var(--a-text); }
.topbar-bell .badge {
  position: absolute;
  top: 2px; right: 2px;
  width: 16px; height: 16px;
  background: var(--a-danger);
  border-radius: 50%;
  font-size: 0.6rem;
  font-weight: 700;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s;
}
.topbar-user:hover { background: rgba(76,175,80,0.08); }
.topbar-user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--a-verde-claro);
}
.topbar-user-name { font-size: 0.83rem; font-weight: 600; color: var(--a-text); }
.topbar-user-role { font-size: 0.68rem; color: var(--a-text-muted); }

/* -------- PAGE CONTENT -------- */
.admin-content {
  flex: 1;
  padding: 1.8rem;
  overflow-x: hidden;
}

/* -------- STAT CARDS (Dashboard) -------- */
.stat-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.2rem;
  margin-bottom: 1.8rem;
}

.stat-card {
  background: var(--a-card-bg);
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius-lg);
  padding: 1.4rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: all 0.2s;
}
.stat-card:hover { border-color: rgba(76,175,80,0.4); transform: translateY(-2px); box-shadow: var(--a-shadow); }

.stat-card-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  flex-shrink: 0;
}
.stat-card-icon.green  { background: rgba(76,175,80,0.2); }
.stat-card-icon.blue   { background: rgba(59,130,246,0.2); }
.stat-card-icon.purple { background: rgba(139,92,246,0.2); }
.stat-card-icon.orange { background: rgba(245,158,11,0.2); }

.stat-card-info { flex: 1; min-width: 0; }
.stat-card-label { font-size: 0.74rem; color: var(--a-text-muted); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 0.3rem; }
.stat-card-value { font-family: 'Outfit', sans-serif; font-size: 1.9rem; font-weight: 900; color: var(--a-white); line-height: 1; }
.stat-card-delta { font-size: 0.72rem; color: var(--a-verde-claro); margin-top: 4px; }
.stat-card-delta.neg { color: var(--a-danger); }

/* -------- GRID LAYOUTS -------- */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.4rem; margin-bottom: 1.8rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.4rem; margin-bottom: 1.8rem; }
.grid-3-1 { display: grid; grid-template-columns: 1fr 1fr 1.2fr; gap: 1.4rem; margin-bottom: 1.8rem; }

/* -------- ADMIN CARD -------- */
.a-card {
  background: var(--a-card-bg);
  border: 1px solid var(--a-border);
  border-radius: var(--a-radius-lg);
  overflow: hidden;
}
.a-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--a-border);
}
.a-card-title { font-family: 'Outfit', sans-serif; font-size: 0.95rem; font-weight: 700; color: var(--a-white); }
.a-card-action {
  font-size: 0.75rem;
  color: var(--a-verde-claro);
  text-decoration: none;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color 0.2s;
}
.a-card-action:hover { color: var(--a-accent); }
.a-card-body { padding: 1.2rem 1.4rem; }

.a-card-filter {
  background: rgba(76,175,80,0.08);
  border: 1px solid rgba(76,175,80,0.2);
  border-radius: 6px;
  color: var(--a-text-muted);
  font-size: 0.75rem;
  padding: 4px 10px;
  cursor: pointer;
  outline: none;
}
.a-card-filter option { background: #162916; }

/* -------- TABLE -------- */
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th {
  text-align: left;
  padding: 0.7rem 1rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--a-text-muted);
  border-bottom: 1px solid var(--a-border);
}
.admin-table td {
  padding: 0.8rem 1rem;
  font-size: 0.83rem;
  border-bottom: 1px solid rgba(76,175,80,0.06);
  vertical-align: middle;
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: rgba(76,175,80,0.04); }

.avatar-cell {
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
.table-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}
.avatar-name  { font-weight: 600; font-size: 0.83rem; color: var(--a-text); }
.avatar-sub   { font-size: 0.7rem; color: var(--a-text-muted); }

/* -------- RANK TABLE -------- */
.rank-pos { font-family: 'Outfit', sans-serif; font-weight: 900; font-size: 1rem; }
.rank-pos.gold   { color: #FFD700; }
.rank-pos.silver { color: #C0C0C0; }
.rank-pos.bronze { color: #CD7F32; }

.afiliados-count { font-family: 'Outfit', sans-serif; font-weight: 800; color: var(--a-verde-claro); }

/* -------- ACTIVITY FEED -------- */
.act-item {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid rgba(76,175,80,0.07);
}
.act-item:last-child { border-bottom: none; }
.act-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
}
.act-text { flex: 1; font-size: 0.8rem; line-height: 1.5; color: var(--a-text); }
.act-text strong { color: var(--a-white); }
.act-time { font-size: 0.68rem; color: var(--a-text-muted); white-space: nowrap; margin-top: 2px; }

/* -------- ESTRUCTURA TREE -------- */
.tree-root {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding: 1rem 0;
  font-size: 0.78rem;
}

.tree-node {
  background: var(--a-verde-dark);
  border: 1px solid rgba(76,175,80,0.4);
  border-radius: 8px;
  padding: 0.6rem 1rem;
  text-align: center;
  min-width: 100px;
  cursor: pointer;
  transition: all 0.2s;
}
.tree-node:hover { background: rgba(76,175,80,0.2); border-color: var(--a-verde-claro); }
.tree-node.root { background: #1a3a1a; border-color: var(--a-verde-claro); min-width: 160px; }
.tree-node-name { font-weight: 700; color: var(--a-white); }
.tree-node-count { font-size: 0.66rem; color: var(--a-text-muted); margin-top: 2px; }

.tree-connector {
  width: 2px;
  height: 20px;
  background: rgba(76,175,80,0.3);
  margin: 0 auto;
}
.tree-children {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
  flex-wrap: wrap;
}
.tree-branch {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* -------- BADGE -------- */
.badge-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-active   { background: rgba(76,175,80,0.2);  color: #66BB6A; }
.badge-inactive { background: rgba(244,67,54,0.15); color: #ff7961; }
.badge-pending  { background: rgba(245,158,11,0.15); color: #fbbf24; }

/* -------- FORM CONTROLS (admin) -------- */
.a-input, .a-select, .a-textarea {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(76,175,80,0.25);
  border-radius: 8px;
  color: var(--a-text);
  font-family: 'Inter', sans-serif;
  font-size: 0.84rem;
  padding: 9px 12px;
  width: 100%;
  outline: none;
  transition: border-color 0.2s;
}
.a-input:focus, .a-select:focus { border-color: var(--a-verde-claro); }
.a-select option { background: #0f2a0f; }

.a-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--a-verde);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 9px 16px;
  font-family: 'Inter', sans-serif;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}
.a-btn:hover { background: var(--a-verde-claro); transform: translateY(-1px); }
.a-btn.sm { padding: 6px 10px; font-size: 0.76rem; }
.a-btn.danger { background: rgba(239,68,68,0.2); border: 1px solid rgba(239,68,68,0.4); color: #ff7961; }
.a-btn.danger:hover { background: rgba(239,68,68,0.3); }
.a-btn.ghost { background: transparent; border: 1px solid rgba(76,175,80,0.3); color: var(--a-text-muted); }
.a-btn.ghost:hover { background: rgba(76,175,80,0.1); color: var(--a-text); }

/* -------- CHART WRAPPER -------- */
.chart-wrap { position: relative; height: 220px; }

/* -------- MAPA SVG admin -------- */
.admin-map-svg { width: 100%; height: auto; max-height: 280px; }
.admin-map-path {
  stroke: rgba(255,255,255,0.15);
  stroke-width: 0.5;
  cursor: pointer;
  transition: opacity 0.2s, filter 0.2s;
}
.admin-map-path:hover { opacity: 0.8; filter: brightness(1.3); }

/* -------- PROGRESS BAR -------- */
.progress-bar-wrap { margin: 0.4rem 0; }
.progress-bar-label { display: flex; justify-content: space-between; font-size: 0.73rem; color: var(--a-text-muted); margin-bottom: 4px; }
.progress-bar-track { height: 6px; background: rgba(255,255,255,0.08); border-radius: 3px; overflow: hidden; }
.progress-bar-fill  { height: 100%; border-radius: 3px; background: linear-gradient(90deg, var(--a-verde), var(--a-verde-claro)); transition: width 0.8s ease; }

/* -------- PAGINATION -------- */
.pagination { display: flex; gap: 0.4rem; justify-content: center; margin-top: 1rem; }
.page-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(76,175,80,0.2);
  color: var(--a-text-muted);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.2s;
}
.page-btn:hover, .page-btn.active { background: rgba(76,175,80,0.2); color: var(--a-verde-claro); border-color: rgba(76,175,80,0.4); }

/* -------- SEARCH + FILTER BAR -------- */
.filter-bar {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}
.filter-search {
  flex: 1;
  min-width: 200px;
  position: relative;
}
.filter-search input {
  width: 100%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(76,175,80,0.25);
  border-radius: 8px;
  color: var(--a-text);
  font-size: 0.84rem;
  padding: 9px 12px 9px 36px;
  outline: none;
  transition: border-color 0.2s;
}
.filter-search input:focus { border-color: var(--a-verde-claro); }
.filter-search .search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--a-text-muted);
  font-size: 0.9rem;
}

/* -------- CALENDAR -------- */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-header { text-align: center; font-size: 0.68rem; color: var(--a-text-muted); padding: 4px; font-weight: 700; text-transform: uppercase; }
.cal-day {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: background 0.2s;
  border: 1px solid transparent;
}
.cal-day:hover { background: rgba(76,175,80,0.15); }
.cal-day.today { background: rgba(76,175,80,0.2); border-color: var(--a-verde-claro); color: var(--a-verde-claro); font-weight: 700; }
.cal-day.has-event::after { content: '•'; font-size: 0.5rem; color: var(--a-verde-claro); display: block; }
.cal-day.empty { cursor: default; color: rgba(255,255,255,0.15); }

/* -------- ADMIN LOGIN -------- */
.admin-login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #0d1f0d 0%, #0f2a0f 50%, #162916 100%);
}
.admin-login-box {
  width: 100%;
  max-width: 400px;
  background: var(--a-card-bg);
  border: 1px solid var(--a-border);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.admin-login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.admin-login-logo img { width: 70px; height: 70px; border-radius: 50%; border: 3px solid var(--a-verde-claro); object-fit: cover; }
.admin-login-logo h1 { font-family: 'Outfit', sans-serif; font-size: 1.3rem; font-weight: 800; color: var(--a-white); margin-top: 0.8rem; }
.admin-login-logo p { font-size: 0.78rem; color: var(--a-text-muted); }

/* -------- FOOTER (admin) -------- */
.admin-footer {
  padding: 1rem 1.8rem;
  border-top: 1px solid var(--a-border);
  font-size: 0.73rem;
  color: var(--a-text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* -------- RESPONSIVE -------- */
@media (max-width: 1100px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-3, .grid-3-1 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .admin-sidebar { transform: translateX(-100%); }
  .admin-sidebar.open { transform: translateX(0); }
  .admin-main { margin-left: 0; }
  .stat-cards { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 480px) {
  .stat-cards { grid-template-columns: 1fr; }
}
