/* ============================================
   PLANTILLA WEB MODULAR - ESTILOS GLOBALES
   Usa variables CSS inyectadas desde config/site.js
   ============================================ */

/* ── Reset & Base ── */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--color-bg);
  color: #1e293b;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: color 0.2s;
}

a:hover {
  color: var(--color-primary-hover);
}

img {
  max-width: 100%;
  height: auto;
}

code {
  background: #e2e8f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ── Utilities ── */
.container {
  width: 100%;
  max-width: 1140px;
  margin: 0 auto;
  padding: 0 1rem;
}

.text-center { text-align: center; }
.text-muted { color: var(--color-secondary); font-size: 0.875rem; }

/* ── Navbar (Público) ── */
.navbar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 100;
}

.navbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}

.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-primary) !important;
}

.navbar-nav {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  list-style: none;
}

.navbar-nav a {
  font-size: 0.9rem;
  font-weight: 500;
  color: #475569;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  transition: background 0.2s, color 0.2s;
}

.navbar-nav a:hover,
.navbar-nav a.active {
  color: var(--color-primary);
  background: #eff6ff;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-user-name {
  font-size: 0.85rem;
  color: var(--color-secondary);
}

/* ── Logout Form (inline in navbar) ── */
.logout-form {
  margin: 0;
  display: inline-flex;
}

.logout-form .btn {
  font-size: 0.9rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
}

.logout-form .btn:hover {
  color: var(--color-primary);
  background: #eff6ff;
  border-color: var(--color-primary);
}

.navbar-admin {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 1.5rem;
}

/* ── Sidebar (Admin) ── */
.admin-layout {
  display: flex;
  flex-direction: row;
  min-height: 100vh;
  align-items: stretch;
}

.sidebar {
  width: 250px;
  min-width: 250px;
  background: var(--color-sidebar-bg);
  color: var(--color-sidebar-text);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-header h3 {
  font-size: 1.1rem;
  color: #fff;
  margin-bottom: 0.25rem;
}

.sidebar-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  background: var(--color-primary);
  color: #fff;
  padding: 2px 8px;
  border-radius: 4px;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  color: var(--color-sidebar-text);
  font-size: 0.9rem;
  transition: background 0.2s, color 0.2s;
}

.sidebar-nav a:hover,
.sidebar-nav a.active {
  background: var(--color-sidebar-hover);
  color: #fff;
}

.sidebar-icon {
  font-size: 1.1rem;
}

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  font-size: 0.75rem;
}

/* ── Admin Main Area ── */
.admin-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.admin-content {
  padding: 1.5rem 2rem 2rem;
}

/* ── Alerts ── */
.alert {
  padding: 0.85rem 1.25rem;
  margin: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  animation: slideDown 0.3s ease;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.alert-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-danger {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.6rem 1.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.1s;
  line-height: 1.4;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-outline {
  background: transparent;
  border-color: #cbd5e1;
  color: #475569;
}

.btn-outline:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.btn-success {
  background: var(--color-success);
  color: #fff;
}

.btn-success:hover {
  background: #16a34a;
}

.btn-danger {
  background: var(--color-danger);
  color: #fff;
}

.btn-danger:hover {
  background: #dc2626;
}

.btn-warning {
  background: var(--color-warning);
  color: #fff;
}

.btn-warning:hover {
  background: #d97706;
}

.btn-sm {
  padding: 0.4rem 0.85rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.8rem 2rem;
  font-size: 1.05rem;
}

.btn-block {
  width: 100%;
}

/* ── Forms ── */
.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 0.4rem;
  color: #334155;
}

.form-control {
  width: 100%;
  padding: 0.65rem 0.85rem;
  font-size: 0.95rem;
  border: 1.5px solid #cbd5e1;
  border-radius: 8px;
  background: #fff;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

select.form-control {
  cursor: pointer;
}

.form-check label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 400;
  cursor: pointer;
}

.form-check input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  accent-color: var(--color-primary);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

/* ── Auth Pages ── */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 160px);
  padding: 2rem 1rem;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: #fff;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
}

.auth-card h1,
.auth-card h2 {
  font-size: 1.5rem;
  color: #1e293b;
  margin-bottom: 0.25rem;
}

.page-auth .auth-container {
  flex: 1;
  min-height: 0;
}

.page-auth .alert {
  align-self: center;
  width: calc(100% - 2rem);
  max-width: 420px;
  margin: 1rem auto 0;
}

.auth-form .btn-block {
  min-height: 44px;
}

.auth-subtitle {
  color: var(--color-secondary);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.auth-footer {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--color-secondary);
}

.auth-footer.admin-link-footer {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid #e2e8f0;
}

/* ── Admin Login Badge ── */
.auth-card-admin {
  border-top: 4px solid var(--color-primary);
}

.admin-login-badge {
  display: inline-block;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  background: var(--color-primary);
  color: #fff;
  padding: 4px 12px;
  border-radius: 4px;
  margin-bottom: 0.75rem;
}

/* ── Hero (Home) ── */
.hero {
  background: linear-gradient(135deg, var(--color-primary) 0%, #7c3aed 100%);
  color: #fff;
  padding: 5rem 1rem;
  text-align: center;
}

.hero h1 {
  font-size: 2.75rem;
  font-weight: 800;
  margin-bottom: 0.75rem;
}

.hero-subtitle {
  font-size: 1.15rem;
  opacity: 0.9;
  margin-bottom: 2rem;
}

.hero-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-welcome {
  margin-top: 1rem;
}

.hero-welcome h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.hero .btn-outline {
  border-color: rgba(255,255,255,0.5);
  color: #fff;
}

.hero .btn-outline:hover {
  border-color: #fff;
  background: rgba(255,255,255,0.1);
}

/* ── Features ── */
.features {
  padding: 4rem 1rem;
}

.features h2 {
  text-align: center;
  font-size: 1.75rem;
  margin-bottom: 2.5rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.5rem;
}

.feature-card {
  background: #fff;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
}

.feature-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.feature-icon {
  font-size: 2.5rem;
  display: block;
  margin-bottom: 0.75rem;
}

.feature-card h3 {
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
  color: #1e293b;
}

.feature-card p {
  font-size: 0.9rem;
  color: var(--color-secondary);
}

/* ── Cards ── */
.card {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

.card h2 {
  margin-bottom: 1rem;
}

.card-form {
  max-width: 640px;
}

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.page-header h1 {
  font-size: 1.5rem;
  color: #1e293b;
}

/* ── Stats Grid ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: #fff;
  padding: 1.5rem;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.05);
  text-align: center;
  border-left: 4px solid transparent;
}

.stat-card h3 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.stat-card p {
  font-size: 0.85rem;
  color: var(--color-secondary);
}

.stat-primary { border-left-color: var(--color-primary); }
.stat-primary h3 { color: var(--color-primary); }

.stat-success { border-left-color: var(--color-success); }
.stat-success h3 { color: var(--color-success); }

.stat-warning { border-left-color: var(--color-warning); }
.stat-warning h3 { color: var(--color-warning); }

/* ── Quick Actions ── */
.quick-actions {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* ── Tables ── */
.table-responsive {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  padding: 0.85rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
  font-size: 0.9rem;
}

.table th {
  background: #f8fafc;
  font-weight: 600;
  color: var(--color-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.table tbody tr:hover {
  background: #f8fafc;
}

.actions-cell {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

/* ── Badges ── */
.badge {
  display: inline-block;
  padding: 3px 10px;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: 20px;
  text-transform: uppercase;
}

.badge-primary {
  background: #dbeafe;
  color: #1e40af;
}

.badge-secondary {
  background: #e2e8f0;
  color: #475569;
}

.badge-success {
  background: #dcfce7;
  color: #166534;
}

.badge-danger {
  background: #fee2e2;
  color: #991b1b;
}

.badge-published {
  background: #dcfce7;
  color: #166534;
}

.badge-hidden {
  background: #fef3c7;
  color: #92400e;
}

.badge-archived {
  background: #e2e8f0;
  color: #475569;
}

/* ── Footer ── */
.footer {
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 2rem 1rem;
  text-align: center;
  margin-top: auto;
}

.footer p {
  font-size: 0.85rem;
  color: var(--color-secondary);
}

.footer-tagline {
  margin-top: 0.25rem;
  font-style: italic;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .admin-layout {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    position: relative;
  }

  .sidebar-nav {
    display: flex;
    overflow-x: auto;
  }

  .sidebar-nav a {
    white-space: nowrap;
  }

  .sidebar-footer {
    display: none;
  }

  .admin-content {
    padding: 1rem;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .hero h1 {
    font-size: 2rem;
  }

  .navbar-nav {
    gap: 0.5rem;
  }

  .navbar-nav a {
    font-size: 0.8rem;
    padding: 0.3rem 0.5rem;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .page-auth .auth-container {
    align-items: flex-start;
    padding: 1.25rem 1rem;
  }

  .auth-card {
    padding: 1.5rem;
  }
}

/* ══════════════════════════════════════
   ADMIN CATALOG STYLES
   ══════════════════════════════════════ */

/* Form sections */
.form-section {
  border: 1px solid var(--color-sidebar-hover, #334155);
  border-radius: 6px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}

.form-section legend {
  font-weight: 600;
  font-size: 1rem;
  padding: 0 0.5rem;
  color: var(--color-primary, #2563eb);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
}

.form-hint {
  font-size: 0.8rem;
  color: #94a3b8;
  margin-top: 0.25rem;
}

.required {
  color: #ef4444;
}

/* Checkbox groups */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.5rem;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  cursor: pointer;
  font-size: 0.9rem;
}

/* Image grids */
.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
}

.image-card {
  border: 2px solid var(--color-sidebar-hover, #334155);
  border-radius: 6px;
  padding: 0.5rem;
  text-align: center;
  position: relative;
}

.image-card.is-primary {
  border-color: var(--color-primary, #2563eb);
}

.image-preview {
  width: 100%;
  height: auto;
  max-height: 160px;
  object-fit: contain;
  border-radius: 4px;
  display: block;
  margin-bottom: 0.4rem;
}

.current-images {
  margin-bottom: 1.5rem;
}

.current-images h4 {
  margin: 0 0 0.5rem;
  font-size: 0.95rem;
}

/* Inline filters */
.inline-filters {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  flex-wrap: wrap;
}

.inline-filters .form-group {
  margin-bottom: 0;
}

/* Pagination */
.pagination {
  display: flex;
  gap: 0.35rem;
  margin-top: 1.5rem;
  flex-wrap: wrap;
}

.page-link,
.page-current {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.25rem;
  height: 2.25rem;
  padding: 0 0.5rem;
  border-radius: 4px;
  font-size: 0.88rem;
  text-decoration: none;
}

.page-link {
  border: 1px solid var(--color-sidebar-hover, #334155);
  color: var(--color-sidebar-text, #cbd5e1);
}

.page-link:hover {
  background: var(--color-sidebar-hover, #334155);
}

.page-current {
  background: var(--color-primary, #2563eb);
  color: #fff;
  font-weight: 600;
}

/* Thumbnails in tables */
.thumb-sm {
  width: 48px;
  height: 48px;
  object-fit: contain;
  border-radius: 4px;
  background: #1e293b;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #94a3b8;
}

.empty-state p {
  margin-bottom: 1rem;
  font-size: 1rem;
}

/* Back link */
.back-link {
  margin-top: 1rem;
}

.back-link a {
  color: #94a3b8;
  text-decoration: none;
  font-size: 0.88rem;
}

.back-link a:hover {
  color: var(--color-primary, #2563eb);
}

/* Responsive table */
.admin-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.inline-form {
  display: inline;
  margin: 0;
}

.btn-xs {
  padding: 0.2rem 0.5rem;
  font-size: 0.7rem;
}

/* Order administration */
.order-filters { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: .8rem; padding: 1rem; margin: 1rem 0; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; }
.order-filters label, .order-card label { display: grid; gap: .35rem; color: #475569; font-size: .82rem; font-weight: 600; }
.order-filters input, .order-filters select, .order-card input, .order-card select, .order-card textarea { width: 100%; padding: .6rem .7rem; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; color: #0f172a; }
.order-table td small { display: block; color: #64748b; margin-top: .2rem; }
.order-count { color: #64748b; margin: .75rem 0; }
.status-pill { display: inline-block; padding: .25rem .55rem; border-radius: 999px; background: #e0f2fe; color: #075985; font-size: .75rem; font-weight: 700; }
.order-pagination { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-top: 1.25rem; }
.order-detail-grid, .order-actions-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 1rem 0; }
.order-card { padding: 1.1rem; background: #fff; border: 1px solid #e2e8f0; border-radius: 10px; }
.order-card h2 { font-size: 1rem; margin-bottom: .85rem; }
.order-card .btn { margin-top: .8rem; }
.order-card--danger { border-color: #fecaca; background: #fff7f7; }
.order-data { display: grid; grid-template-columns: minmax(100px, .45fr) 1fr; gap: .55rem .8rem; }
.order-data dt { color: #64748b; font-weight: 600; }
.order-data dd { overflow-wrap: anywhere; }
.order-timeline { list-style: none; margin: 0; padding: 0; }
.order-timeline li { padding: .8rem 0 .8rem 1rem; border-left: 3px solid #cbd5e1; border-bottom: 1px solid #f1f5f9; }
.order-timeline li > div { display: flex; justify-content: space-between; gap: 1rem; }
.order-timeline span, .order-timeline p { color: #64748b; font-size: .82rem; }
.order-timeline blockquote { margin: .5rem 0 0; padding: .6rem; background: #f8fafc; white-space: pre-wrap; overflow-wrap: anywhere; }

@media (max-width: 768px) {
  .table {
    font-size: 0.82rem;
  }
  .form-row {
    grid-template-columns: 1fr;
  }
  .inline-filters {
    flex-direction: column;
  }
  .admin-content {
    padding: 1rem;
  }
  .order-filters, .order-detail-grid, .order-actions-grid { grid-template-columns: 1fr; }
  .order-timeline li > div { display: block; }
}
