/* ============================================================
   PurrCore Admin — admin.css
   Panel de administración completo
   ============================================================ */
:root {
  --primary: #2d6a4f;
  --primary-dark: #1b4332;
  --primary-light: #52b788;
  --accent: #40916c;
  --bg: #f8faf8;
  --surface: #ffffff;
  --sidebar-bg: #1b4332;
  --sidebar-text: rgba(255,255,255,.85);
  --sidebar-active: rgba(255,255,255,.15);
  --border: #e5e7eb;
  --text: #111827;
  --text-muted: #6b7280;
  --text-light: #9ca3af;
  --danger: #dc2626;
  --warning: #d97706;
  --success: #16a34a;
  --info: #2563eb;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body.admin-body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }

/* ── Layout ─────────────────────────────────────────────── */
.admin-layout { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────────────────── */
.admin-sidebar {
  width: 240px; min-height: 100vh; background: var(--sidebar-bg);
  display: flex; flex-direction: column; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.admin-logo { padding: 20px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.1); }
.admin-logo a { color: #fff; text-decoration: none; font-size: 18px; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.admin-nav { padding: 12px 8px; flex: 1; }
.admin-nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  color: var(--sidebar-text); text-decoration: none; border-radius: 7px;
  font-size: 14px; margin-bottom: 2px; transition: all .15s;
}
.admin-nav a:hover, .admin-nav a.active { background: var(--sidebar-active); color: #fff; }
.admin-nav a.active { font-weight: 600; }
.admin-nav-section {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px;
  color: rgba(255,255,255,.35); padding: 12px 12px 4px; margin-top: 4px;
}
.admin-sidebar-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,.1); }
.admin-sidebar-footer > div { color: rgba(255,255,255,.6); font-size: 12px; margin-bottom: 8px; line-height: 1.4; }
.admin-sidebar-footer a { display: block; color: rgba(255,255,255,.5); font-size: 12px; text-decoration: none; padding: 2px 0; }
.admin-sidebar-footer a:hover { color: #fff; }

/* ── Main ────────────────────────────────────────────────── */
.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-header {
  height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow);
}
.admin-header h1 { font-size: 16px; font-weight: 600; color: var(--text); }
.admin-content { padding: 24px; flex: 1; }

/* ── Alertas ─────────────────────────────────────────────── */
.alert { padding: 12px 16px; border-radius: var(--radius); font-size: 14px; margin-bottom: 16px; border: 1px solid transparent; }
.alert-success { background: #f0fdf4; border-color: #bbf7d0; color: #15803d; }
.alert-error, .alert-danger { background: #fef2f2; border-color: #fecaca; color: var(--danger); }
.alert-warning { background: #fffbeb; border-color: #fde68a; color: var(--warning); }
.alert-info { background: #eff6ff; border-color: #bfdbfe; color: var(--info); }

/* ── Cards ───────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card h3 { font-size: 15px; font-weight: 700; margin-bottom: 16px; color: var(--text); }

/* ── Page header ─────────────────────────────────────────── */
.admin-page { }
.admin-page-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 12px; }
.admin-page-title { font-size: 20px; font-weight: 700; color: var(--text); }

/* ── Botones ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px;
  border: none; border-radius: 7px; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: #e5e7eb; color: var(--text); }
.btn-secondary:hover { background: #d1d5db; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }
.btn-icon { padding: 7px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Formularios ─────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-control {
  width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 7px;
  font-size: 14px; color: var(--text); background: var(--surface); transition: border .15s;
  font-family: inherit;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(45,106,79,.1); }
.form-control:disabled { background: #f9fafb; color: var(--text-muted); }
textarea.form-control { resize: vertical; min-height: 80px; }
select.form-control { cursor: pointer; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--danger); margin-top: 4px; }
.form-row { display: grid; gap: 16px; }
.form-row-2 { grid-template-columns: 1fr 1fr; }
.form-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }
@media(max-width:640px){.form-row-2,.form-row-3,.form-row-4{grid-template-columns:1fr}}

/* ── Tablas ──────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }
.admin-table { width: 100%; border-collapse: collapse; background: var(--surface); font-size: 14px; }
.admin-table thead tr { background: #f9fafb; border-bottom: 1px solid var(--border); }
.admin-table th { padding: 11px 16px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--text-muted); text-align: left; white-space: nowrap; }
.admin-table td { padding: 12px 16px; border-bottom: 1px solid #f3f4f6; vertical-align: middle; }
.admin-table tbody tr:last-child td { border-bottom: none; }
.admin-table tbody tr:hover td { background: #f9fafb; }
.admin-table .actions { display: flex; gap: 6px; justify-content: flex-end; }
.table-empty { text-align: center; padding: 48px 20px; color: var(--text-muted); }
.table-empty-icon { font-size: 40px; margin-bottom: 12px; }

/* ── Badges / Status ─────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-green { background: #dcfce7; color: #15803d; }
.badge-red { background: #fee2e2; color: var(--danger); }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-gray { background: #f3f4f6; color: #374151; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }
.status-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }

/* ── Stats cards ─────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.stat-card-icon { font-size: 28px; margin-bottom: 8px; }
.stat-card-value { font-size: 28px; font-weight: 800; color: var(--text); line-height: 1; }
.stat-card-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-card-change { font-size: 12px; margin-top: 6px; }
.stat-card-change.up { color: var(--success); }
.stat-card-change.down { color: var(--danger); }

/* ── Paginación ──────────────────────────────────────────── */
.pagination { display: flex; gap: 4px; align-items: center; justify-content: center; margin-top: 20px; }
.pagination a, .pagination span { padding: 7px 12px; border-radius: 6px; font-size: 14px; text-decoration: none; }
.pagination a { border: 1px solid var(--border); color: var(--text); background: var(--surface); }
.pagination a:hover { background: var(--bg); }
.pagination .current { background: var(--primary); color: #fff; border-color: var(--primary); }
.pagination .disabled { color: var(--text-light); pointer-events: none; }

/* ── Modales ─────────────────────────────────────────────── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,.45);
  z-index: 1000; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: 12px; padding: 28px; max-width: 520px; width: 100%; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal h3 { font-size: 18px; font-weight: 700; margin-bottom: 16px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── Buscador + filtros ──────────────────────────────────── */
.table-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.search-input { padding: 8px 12px 8px 36px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M11.742 10.344a6.5 6.5 0 1 0-1.397 1.398h-.001c.03.04.062.078.098.115l3.85 3.85a1 1 0 0 0 1.415-1.414l-3.85-3.85a1.007 1.007 0 0 0-.115-.099zm-5.44 1.23a5 5 0 1 1 0-10 5 5 0 0 1 0 10z'/%3E%3C/svg%3E") 10px center no-repeat; }
.search-input:focus { outline: none; border-color: var(--primary); }
.filter-select { padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px; font-size: 14px; background: var(--surface); cursor: pointer; }

/* ── Toggle / Switch ─────────────────────────────────────── */
.toggle { position: relative; display: inline-block; width: 44px; height: 24px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider { position: absolute; cursor: pointer; inset: 0; background: #d1d5db; border-radius: 24px; transition: .2s; }
.toggle-slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: .2s; }
.toggle input:checked + .toggle-slider { background: var(--primary); }
.toggle input:checked + .toggle-slider:before { transform: translateX(20px); }

/* ── Upload zona ─────────────────────────────────────────── */
.upload-zone { border: 2px dashed var(--border); border-radius: var(--radius); padding: 32px; text-align: center; cursor: pointer; transition: all .2s; }
.upload-zone:hover { border-color: var(--primary); background: #f0fdf4; }
.upload-zone-icon { font-size: 36px; margin-bottom: 8px; }

/* ── Tabs ────────────────────────────────────────────────── */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; gap: 4px; }
.tab { padding: 10px 16px; font-size: 14px; font-weight: 600; color: var(--text-muted); cursor: pointer; text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all .15s; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Breadcrumb ──────────────────────────────────────────── */
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-muted); margin-bottom: 16px; }
.breadcrumb a { color: var(--text-muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--text); }
.breadcrumb-sep { color: var(--text-light); }

/* ── Grid utiles ─────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-sidebar { display: grid; grid-template-columns: 1fr 340px; gap: 20px; }
@media(max-width:900px){.grid-2,.grid-3,.grid-sidebar{grid-template-columns:1fr}}

/* ── Responsive ──────────────────────────────────────────── */
@media(max-width:768px){
  .admin-sidebar { width: 200px; }
  .admin-content { padding: 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
@media(max-width:600px){
  .admin-sidebar { display: none; }
  .admin-sidebar.open { display: flex; position: fixed; z-index: 999; }
  .stats-grid { grid-template-columns: 1fr; }
}
