/* ===================================================
   WebSoft Solutions - Admin Panel CSS
   Versión: 2.0 - Totalmente Responsive
   =================================================== */

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

/* ---- CSS Variables ---- */
:root {
  --primary:        #2563eb;
  --primary-dark:   #1d4ed8;
  --primary-light:  #dbeafe;
  --sidebar-bg:     #0f172a;
  --sidebar-w:      260px;
  --topbar-h:       60px;
  --success:  #10b981;
  --warning:  #f59e0b;
  --danger:   #ef4444;
  --info:     #06b6d4;
  --purple:   #8b5cf6;
  --gray-50:  #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-700: #334155;
  --gray-900: #0f172a;
  --white:    #ffffff;
  --shadow-sm: 0 1px 3px rgba(0,0,0,.07);
  --shadow:    0 4px 12px rgba(0,0,0,.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.12);
  --radius:    10px;
  --radius-lg: 16px;
  --tr: all .25s ease;
}

/* ---- Reset ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--gray-100);
  color: var(--gray-700);
  line-height: 1.6;
  overflow-x: hidden;
}
h1,h2,h3,h4,h5,h6 { font-family: 'Outfit', sans-serif; color: var(--gray-900); }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; display: block; }

/* ============================================================
   LAYOUT PRINCIPAL
   ============================================================ */

/* ---- Sidebar ---- */
.admin-sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 300;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .3s ease, box-shadow .3s ease;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}
.admin-sidebar::-webkit-scrollbar { width: 4px; }
.admin-sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

/* Overlay para mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 299;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.active { display: block; }

/* Brand */
.sidebar-brand {
  padding: 1.25rem 1.25rem .9rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}
.sidebar-logo {
  width: 38px; height: 38px; min-width: 38px;
  background: linear-gradient(135deg, #2563eb, #06b6d4);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-size: 1.05rem;
  font-weight: 800;
  font-family: 'Outfit', sans-serif;
}
.sidebar-brand-name  { font-family: 'Outfit', sans-serif; font-size: .95rem; font-weight: 800; color: white; line-height: 1.2; }
.sidebar-brand-sub   { font-size: .68rem; color: rgba(255,255,255,.35); font-family: 'Inter', sans-serif; }

/* Admin info */
.sidebar-admin {
  padding: 1rem 1.25rem;
  display: flex; align-items: center; gap: .75rem;
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.sidebar-admin-avatar {
  width: 36px; height: 36px; min-width: 36px;
  background: linear-gradient(135deg, #2563eb, #8b5cf6);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: white; font-weight: 700; font-size: .95rem;
  font-family: 'Outfit', sans-serif;
}
.sidebar-admin-name { font-size: .84rem; font-weight: 600; color: white; }
.sidebar-admin-role { font-size: .7rem; color: rgba(255,255,255,.35); }

/* Nav sections */
.sidebar-nav { padding: .75rem 0; flex: 1; }
.sidebar-nav-section {
  padding: .5rem 1.25rem .2rem;
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: rgba(255,255,255,.22);
  margin-top: .4rem;
}
.sidebar-nav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .6rem 1rem;
  color: rgba(255,255,255,.52);
  font-size: .855rem;
  font-weight: 500;
  transition: var(--tr);
  position: relative;
  margin: .1rem .65rem;
  border-radius: 8px;
  white-space: nowrap;
}
.sidebar-nav-item i { font-size: 1rem; width: 18px; text-align: center; flex-shrink: 0; }
.sidebar-nav-item:hover  { color: white; background: rgba(255,255,255,.07); }
.sidebar-nav-item.active {
  color: white;
  background: linear-gradient(135deg,rgba(37,99,235,.45),rgba(6,182,212,.25));
  border: 1px solid rgba(37,99,235,.25);
}

/* Sidebar footer */
.sidebar-footer {
  padding: .75rem .65rem;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

/* ---- Main content ---- */
.admin-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .3s ease;
}

/* ---- Topbar ---- */
.admin-topbar {
  background: var(--white);
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.5rem;
  box-shadow: var(--shadow-sm);
  position: sticky;
  top: 0; z-index: 200;
  border-bottom: 1px solid var(--gray-200);
  gap: 1rem;
}
.topbar-left {
  display: flex; align-items: center; gap: .75rem;
  min-width: 0; /* permite truncar */
}
.topbar-hamburger {
  display: none;                   /* visible en mobile */
  background: none; border: none; cursor: pointer;
  padding: .4rem;
  border-radius: 8px;
  transition: var(--tr);
  flex-shrink: 0;
}
.topbar-hamburger:hover { background: var(--gray-100); }
.topbar-hamburger i { font-size: 1.35rem; color: var(--gray-700); display: block; }

.topbar-page-title {
  font-family: 'Outfit', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--gray-900);
  display: flex; align-items: center; gap: .6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-page-title i { color: var(--primary); flex-shrink: 0; }

.topbar-actions {
  display: flex; align-items: center; gap: .65rem;
  flex-shrink: 0;
}
.topbar-site-link {
  display: flex; align-items: center; gap: .35rem;
  font-size: .82rem;
  color: var(--gray-500);
  padding: .4rem .85rem;
  background: var(--gray-100);
  border-radius: 8px;
  transition: var(--tr);
  white-space: nowrap;
}
.topbar-site-link:hover { background: var(--primary-light); color: var(--primary); }
.topbar-site-link .label { display: inline; }

.topbar-logout {
  display: flex; align-items: center; gap: .35rem;
  font-size: .82rem;
  color: var(--danger);
  padding: .4rem .85rem;
  background: #fef2f2;
  border-radius: 8px;
  border: none; cursor: pointer;
  font-family: 'Inter', sans-serif;
  transition: var(--tr);
  white-space: nowrap;
}
.topbar-logout:hover { background: #fecaca; }
.topbar-logout .label { display: inline; }

/* ---- Content Area ---- */
.admin-content {
  padding: 1.75rem;
  flex: 1;
}

/* ============================================================
   COMPONENTES
   ============================================================ */

/* ---- Cards ---- */
.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}
.card-header {
  padding: 1.1rem 1.4rem;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
}
.card-title {
  font-size: .95rem; font-weight: 700; color: var(--gray-900);
  display: flex; align-items: center; gap: .5rem;
}
.card-title i { color: var(--primary); }
.card-body { padding: 1.4rem; }

/* ---- Stats Cards ---- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: 1.1rem;
  transition: var(--tr);
}
.stat-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-card-icon {
  width: 50px; height: 50px; min-width: 50px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.stat-card-num {
  font-family: 'Outfit', sans-serif; font-size: 1.9rem;
  font-weight: 800; line-height: 1; color: var(--gray-900);
}
.stat-card-label { font-size: .8rem; color: var(--gray-500); margin-top: .2rem; }

/* ---- Dashboard bottom grid ---- */
.dashboard-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

/* ---- Page Header ---- */
.page-header {
  display: flex; align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  gap: 1rem;
  flex-wrap: wrap;
}
.page-header-left h1 {
  font-size: 1.4rem; font-weight: 800; color: var(--gray-900);
  display: flex; align-items: center; gap: .55rem;
  flex-wrap: wrap;
}
.page-header-left h1 i { color: var(--primary); }
.breadcrumb {
  font-size: .78rem; color: var(--gray-400);
  display: flex; align-items: center; gap: .35rem;
  margin-top: .2rem; flex-wrap: wrap;
}
.breadcrumb a { color: var(--primary); }
.breadcrumb-sep { color: var(--gray-300); }

/* ---- Table ---- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.admin-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .855rem;
  min-width: 500px; /* fuerza scroll horizontal antes de romperse */
}
.admin-table th {
  background: var(--gray-50);
  color: var(--gray-500);
  font-weight: 600;
  font-size: .72rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: .8rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--gray-200);
  white-space: nowrap;
}
.admin-table td {
  padding: .8rem 1rem;
  border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
  color: var(--gray-700);
}
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: var(--gray-50); }
.admin-table img { width: 50px; height: 40px; object-fit: cover; border-radius: 6px; }

/* Action buttons en tablas */
.table-actions { display: flex; gap: .4rem; flex-wrap: nowrap; }

/* ---- Badges ---- */
.badge {
  display: inline-flex; align-items: center; gap: .25rem;
  padding: .22rem .6rem;
  border-radius: 50px;
  font-size: .7rem; font-weight: 700; letter-spacing: .04em;
  white-space: nowrap;
}
.badge-success { background: #d1fae5; color: #059669; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-warning { background: #fef3c7; color: #d97706; }
.badge-info    { background: #e0f2fe; color: #0284c7; }
.badge-primary { background: #dbeafe; color: #2563eb; }
.badge-purple  { background: #ede9fe; color: #7c3aed; }

/* ---- Buttons ---- */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .5rem 1rem;
  border-radius: 8px;
  font-size: .855rem; font-weight: 600;
  cursor: pointer; border: 1px solid transparent;
  transition: var(--tr);
  font-family: 'Inter', sans-serif;
  text-decoration: none; white-space: nowrap;
  line-height: 1.4;
}
.btn-primary        { background: var(--primary);  color: white; border-color: var(--primary); }
.btn-primary:hover  { background: var(--primary-dark); }
.btn-success        { background: var(--success);  color: white; border-color: var(--success); }
.btn-success:hover  { background: #059669; }
.btn-danger         { background: var(--danger);   color: white; border-color: var(--danger); }
.btn-danger:hover   { background: #dc2626; }
.btn-warning        { background: var(--warning);  color: white; border-color: var(--warning); }
.btn-warning:hover  { background: #d97706; }
.btn-secondary      { background: var(--gray-200); color: var(--gray-700); border-color: var(--gray-200); }
.btn-secondary:hover{ background: var(--gray-300); }
.btn-outline-primary{ background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline-primary:hover { background: var(--primary); color: white; }
.btn-sm  { padding: .32rem .68rem; font-size: .78rem; border-radius: 7px; }
.btn-lg  { padding: .72rem 1.45rem; font-size: .97rem; border-radius: 10px; }
.btn-block { width: 100%; justify-content: center; }

/* ---- Forms ---- */
.form-group { margin-bottom: 1.2rem; }
.form-label {
  display: block; font-size: .83rem; font-weight: 600;
  color: var(--gray-700); margin-bottom: .35rem;
}
.form-label .required { color: var(--danger); margin-left: .15rem; }
.form-control {
  width: 100%;
  padding: .6rem .9rem;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: .855rem;
  font-family: 'Inter', sans-serif;
  color: var(--gray-700);
  background: var(--white);
  transition: var(--tr);
  outline: none;
  -webkit-appearance: none;
}
.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-control::placeholder { color: var(--gray-300); }
textarea.form-control { resize: vertical; min-height: 90px; }
select.form-control { cursor: pointer; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right .5rem center; background-size: 1.2em; padding-right: 2.5rem; }
.form-hint  { font-size: .76rem; color: var(--gray-400); margin-top: .28rem; }
.form-error { font-size: .76rem; color: var(--danger);   margin-top: .28rem; }

.form-check {
  display: flex; align-items: center; gap: .55rem;
  cursor: pointer; font-size: .855rem; color: var(--gray-700);
}
.form-check input[type="checkbox"] {
  width: 17px; height: 17px; border-radius: 5px;
  accent-color: var(--primary); cursor: pointer; flex-shrink: 0;
}

/* Grid de formularios - adaptativo */
.form-row   { display: grid; grid-template-columns: 1fr 1fr;     gap: 1.2rem; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.2rem; }
.col-full   { grid-column: 1 / -1; }

/* Form footer con botones */
.form-footer {
  display: flex; align-items: center; justify-content: flex-end;
  gap: .75rem; margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--gray-200);
  flex-wrap: wrap;
}

/* ---- Alerts ---- */
.alert {
  padding: .8rem 1.15rem;
  border-radius: 10px; margin-bottom: 1.4rem;
  display: flex; align-items: flex-start; gap: .7rem;
  font-size: .875rem;
}
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger  { background: #fee2e2; color: #7f1d1d; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #78350f; border: 1px solid #fcd34d; }
.alert i { font-size: 1.05rem; flex-shrink: 0; margin-top: .1rem; }

/* Validation errors */
.validation-errors {
  background: #fee2e2; border: 1px solid #fca5a5;
  border-radius: 10px; padding: .9rem 1.15rem; margin-bottom: 1.4rem;
}
.validation-errors ul { padding-left: 1.2rem; }
.validation-errors li { font-size: .855rem; color: #7f1d1d; margin-bottom: .2rem; }

/* ---- Image preview ---- */
.img-preview-wrap {
  border: 2px dashed var(--gray-300); border-radius: 10px;
  padding: 1rem; text-align: center; color: var(--gray-400);
  cursor: pointer; transition: var(--tr);
}
.img-preview-wrap:hover { border-color: var(--primary); background: var(--primary-light); }
.img-preview { max-height: 150px; border-radius: 8px; object-fit: cover; margin: 0 auto .6rem; }

/* ============================================================
   BREAKPOINTS RESPONSIVE
   ============================================================ */

/* --- Tablet grande: ≤ 1280px --- */
@media (max-width: 1280px) {
  :root { --sidebar-w: 240px; }
  .stats-grid { grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); }
}

/* --- Tablet: ≤ 1024px --- */
@media (max-width: 1024px) {
  .dashboard-bottom { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr 1fr; }
}

/* --- Mobile/Tablet: ≤ 900px --- */
@media (max-width: 900px) {
  :root { --sidebar-w: 260px; }

  /* Sidebar oculto por defecto → entra desde la izquierda */
  .admin-sidebar {
    transform: translateX(-100%);
    box-shadow: none;
  }
  .admin-sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 30px rgba(0,0,0,.35);
  }

  /* Main ocupa todo el ancho */
  .admin-main { margin-left: 0; }

  /* Topbar: mostrar hamburger */
  .topbar-hamburger { display: flex; }

  /* Texto del título más pequeño */
  .topbar-page-title { font-size: .95rem; }

  /* Acciones topbar compactas */
  .topbar-site-link .label,
  .topbar-logout .label { display: none; }
  .topbar-site-link,
  .topbar-logout { padding: .4rem .6rem; }

  /* Content padding reducido */
  .admin-content { padding: 1.25rem; }

  /* Page header vertical en mobile */
  .page-header { flex-direction: column; align-items: flex-start; }
  .page-header .btn { width: 100%; justify-content: center; }

  /* Forms en 1 columna */
  .form-row   { grid-template-columns: 1fr; }
  .form-row-3 { grid-template-columns: 1fr; }

  /* Form footer */
  .form-footer { flex-direction: column-reverse; }
  .form-footer .btn { width: 100%; justify-content: center; }

  /* Stats grid: 2 columnas */
  .stats-grid { grid-template-columns: 1fr 1fr; gap: 1rem; }
}

/* --- Móvil: ≤ 580px --- */
@media (max-width: 580px) {
  /* Stats: 1 columna */
  .stats-grid { grid-template-columns: 1fr; }

  .admin-content { padding: 1rem; }
  .topbar-h: 56px;
  .admin-topbar { padding: 0 1rem; }

  /* Card header puede envolver */
  .card-header { flex-direction: column; align-items: flex-start; }
  .card-header .btn { align-self: flex-start; }

  /* Stat cards más compactos */
  .stat-card { padding: 1rem; }
  .stat-card-num { font-size: 1.6rem; }
  .stat-card-icon { width: 42px; height: 42px; min-width: 42px; font-size: 1.2rem; }

  /* Page title más pequeño */
  .page-header-left h1 { font-size: 1.15rem; }

  /* Topbar acciones solo iconos */
  .topbar-actions { gap: .4rem; }
}

/* --- Muy pequeño: ≤ 400px --- */
@media (max-width: 400px) {
  .admin-content { padding: .75rem; }
  .card-body { padding: 1rem; }
  .card-header { padding: .85rem 1rem; }
}
