/* ============================================================
   ADMIN / CLIENTE — Drawer + Home grid + vistas internas
============================================================ */

.admin-body {
  padding: 0;
  display: block;
  align-items: stretch;
  min-height: 100vh;
}

.admin-panel {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============ HEADER COMPACTO ============ */
.admin-header {
  width: 100%;
  max-width: 100%;
  margin: 0;
  border-radius: 0;
  border-left: none;
  border-right: none;
  border-top: none;
  padding: 14px 16px;
  position: sticky;
  top: 0;
  z-index: 40;
  background: var(--surface);
}

.admin-header .header-inner {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.hamburger {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.hamburger svg { width: 20px; height: 20px; }
.hamburger:hover { border-color: var(--accent); background: rgba(124,92,255,0.12); }
.hamburger:active { transform: scale(0.94); }

.header-title {
  flex: 1;
  text-align: center;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 8px;
}

/* ============ DRAWER ============ */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 60;
  animation: fadeIn 0.25s ease both;
}

.drawer-overlay.hidden { display: none; }

.drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(320px, 85vw);
  background: var(--bg-1);
  border-right: 1px solid var(--border-strong);
  z-index: 61;
  transform: translateX(-105%);
  transition: transform 0.32s cubic-bezier(0.2, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  box-shadow: 40px 0 80px -20px rgba(0,0,0,0.6);
}

.drawer.open { transform: translateX(0); }

.drawer-head {
  padding: 22px 20px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
  border-bottom: 1px solid var(--border);
}

.drawer-logo {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(145deg, rgba(30,30,48,0.95), rgba(12,12,22,0.95));
  border: 1.5px solid rgba(255,255,255,0.14);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: inset 0 0 14px rgba(124,92,255,0.35);
}

.drawer-logo img { width: 74%; height: 74%; object-fit: contain; }
.drawer-logo .brand-fallback {
  font-size: 1.3rem;
  font-weight: 900;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.drawer-title {
  font-size: 1.05rem;
  font-weight: 900;
  letter-spacing: -0.03em;
  background: linear-gradient(135deg, #ffffff 0%, #a8b6ff 55%, #00e5ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

[data-theme="light"] .drawer-title {
  background: linear-gradient(135deg, #14142b 0%, #5b3cff 55%, #0088a8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.drawer-sub {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-mute);
  margin-top: 2px;
}

.drawer-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 14px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  width: 100%;
}

.drawer-item svg { width: 19px; height: 19px; flex-shrink: 0; }

.drawer-item:hover {
  background: rgba(255,255,255,0.05);
  color: var(--text);
}

.drawer-item.active {
  background: var(--grad-primary);
  color: #fff;
  box-shadow: 0 10px 26px -10px rgba(124,92,255,0.7);
}

.drawer-item.danger { color: var(--danger); }
.drawer-item.danger:hover { background: rgba(255,92,122,0.1); }

/* ============ MAIN ============ */
.admin-main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 22px 16px 100px; /* fix: 100px para que el último tile no se corte */
}

.view-section { display: none; }
.view-section.active { display: block; animation: fadeUp 0.35s ease both; }

/* ============ HOME ============ */
.home-greeting { margin-bottom: 20px; }

.home-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 22px;
}

.stat-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.stat-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 0%, rgba(124,92,255,0.18), transparent 60%);
  pointer-events: none;
}

.stat-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-mute);
  margin-bottom: 6px;
  position: relative;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  background: var(--grad-primary);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  position: relative;
  line-height: 1;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.home-tile {
  position: relative;
  padding: 20px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: all 0.25s ease;
  font-family: inherit;
  overflow: hidden;
  min-height: 130px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}

.home-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.14;
  background: var(--tile-grad);
  pointer-events: none;
}

.home-tile:hover {
  transform: translateY(-3px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.home-tile:active { transform: translateY(-1px) scale(0.98); }

.tile-icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--tile-grad);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 8px 22px -8px rgba(0,0,0,0.5);
  position: relative;
  z-index: 1;
}

.tile-icon svg { width: 22px; height: 22px; }

.tile-title {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: -0.015em;
  position: relative;
  z-index: 1;
}

.tile-sub {
  font-size: 0.72rem;
  color: var(--text-mute);
  font-weight: 500;
  position: relative;
  z-index: 1;
}

.tile-green   { --tile-grad: var(--grad-success); }
.tile-gold    { --tile-grad: var(--grad-gold); }
.tile-aqua    { --tile-grad: var(--grad-primary); }
.tile-purple  { --tile-grad: linear-gradient(135deg, #7c5cff, #b28cff); }
.tile-pink    { --tile-grad: linear-gradient(135deg, #ff5fa2, #ff8a3d); }
.tile-slate   { --tile-grad: linear-gradient(135deg, #4a4d6b, #6e7190); }
.tile-dark    { --tile-grad: linear-gradient(135deg, #14142b, #2a2a48); }

[data-theme="light"] .tile-dark { --tile-grad: linear-gradient(135deg, #2a2a48, #4a4d6b); }

/* ============ BOTÓN REGRESAR ============ */
.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 14px 9px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  margin-bottom: 18px;
}

.btn-back svg { width: 16px; height: 16px; }
.btn-back:hover { color: var(--text); border-color: var(--accent); transform: translateX(-2px); }

/* ============ SECTION HEAD ============ */
.section-head { margin-bottom: 20px; }
.section-desc {
  font-size: 0.82rem;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.5;
}

.sub-title {
  font-size: 1rem;
  margin-bottom: 12px;
}

/* ============ INPUT ROW ============ */
.input-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.input-row input { flex: 1; min-width: 0; }

.btn-icon-square {
  width: 52px;
  flex-shrink: 0;
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-icon-square svg { width: 20px; height: 20px; }
.btn-icon-square:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.btn-icon-square:active { transform: scale(0.95); }
.btn-icon-square.btn-aqua { background: var(--grad-primary); }
.btn-icon-square.btn-yellow { background: var(--grad-gold); color: #1a1200; }

.input-hint {
  font-size: 0.75rem;
  color: var(--text-mute);
  margin-top: 6px;
  font-weight: 600;
  min-height: 1em;
}

/* ============ TABLA ============ */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.table-wrap table {
  border: none;
  border-radius: 0;
  margin-top: 0;
  min-width: 340px;
}

/* ============ BOTÓN INSTALAR PWA ============ */
.pwa-install-btn {
  position: fixed;
  bottom: max(20px, env(safe-area-inset-bottom, 20px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 480px;
  z-index: 998;
  margin: 0;
  box-shadow: 0 15px 40px -10px rgba(124,92,255,0.85);
  animation: pwaBtnIn 0.4s cubic-bezier(0.2, 1, 0.3, 1) both;
}

@keyframes pwaBtnIn {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

html.pwa-standalone .pwa-install-btn { display: none !important; }

/* ============ RESPONSIVE ============ */
@media (max-width: 480px) {
  .admin-main { padding: 18px 14px 100px; }
  .home-grid { gap: 10px; }
  .home-tile { padding: 16px 14px; min-height: 118px; }
  .tile-icon { width: 38px; height: 38px; }
  .tile-icon svg { width: 20px; height: 20px; }
  .tile-title { font-size: 0.88rem; }
  .tile-sub { font-size: 0.68rem; }
  .stat-value { font-size: 1.6rem; }
}

@media (min-width: 640px) {
  .home-grid { grid-template-columns: repeat(3, 1fr); }
}