/* =========================================================
   CENESTUR INFORMA - ESTILOS DEL PANEL ADMINISTRATIVO
   Diseño Profesional Estilo Linear / Stripe / Vercel
   Soporte Completo Modo Claro y Modo Oscuro (#0E1116 / #171A21)
   ========================================================= */

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

:root {
  --font-main: 'Inter', -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, sans-serif;
  color-scheme: light;
}

/* 1. Fondo General y Base (Modo Claro Sólido) */
body {
  background-color: #f8fafc;
  background-image: none;
  color: #0f172a;
  font-family: var(--font-main);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* 2. Header / Barra Superior */
header.app-header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
  position: sticky;
  top: 0;
  z-index: 1030 !important;
}

.brand-logo-img {
  height: 34px;
  width: auto;
  max-width: 210px;
  object-fit: contain;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 9px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.btn-header-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid #e2e8f0;
  color: #475569;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 150ms ease;
}

.btn-header-secondary:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #0f172a;
}

.btn-logout {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: #dc2626;
  border-radius: 8px;
  padding: 5px 12px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 150ms ease;
}

.btn-logout:hover {
  background: #dc2626;
  color: #ffffff;
  border-color: #dc2626;
}

/* 3. Tarjetas del Panel (Dashboard y Login) */
.admin-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.03);
  color: #0f172a;
}

.admin-card h2,
.admin-card h3 {
  color: #0f172a;
  font-weight: 600;
  letter-spacing: -0.015em;
}

/* 4. Pestañas de Navegación (Tabs Superiores) */
.nav-pills {
  border-bottom: 1px solid #e2e8f0;
  gap: 6px;
  margin-bottom: 24px;
  padding-bottom: 0;
}

body .nav-pills .nav-link {
  background: transparent !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  color: #64748b !important;
  border-radius: 0 !important;
  padding: 10px 16px;
  font-weight: 500;
  font-size: 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 150ms ease;
  margin-bottom: -1px;
}

body .nav-pills .nav-link:hover {
  color: #0f172a !important;
  background: transparent !important;
  border-bottom-color: #cbd5e1 !important;
}

body .nav-pills .nav-link.active,
body .nav-pills .nav-link.active:hover {
  color: #0f172a !important;
  background: transparent !important;
  border-bottom: 2px solid #2563eb !important;
  font-weight: 600 !important;
  box-shadow: none !important;
}

/* 5. Etiquetas de Formulario (Labels) */
.form-label,
label {
  display: inline-block;
  color: #334155;
  font-size: 0.84rem;
  font-weight: 600;
  margin-bottom: 6px;
}

/* 6. Inputs, Selects y Textareas */
body .form-control,
body .form-select,
textarea.form-control {
  background-color: #f8fafc;
  border: 1px solid #cbd5e1;
  color: #0f172a;
  border-radius: 8px;
  padding: 9px 13px;
  font-size: 0.92rem;
  transition: border-color 150ms ease, box-shadow 150ms ease, background-color 150ms ease;
}

body .form-control:focus,
body .form-select:focus,
textarea.form-control:focus {
  background-color: #ffffff;
  border-color: #2563eb;
  color: #0f172a;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.14);
  outline: none;
}

body .form-control::placeholder,
textarea.form-control::placeholder {
  color: #94a3b8;
  opacity: 1;
  font-weight: 400;
  font-size: 0.88rem;
}

.input-group-text {
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #64748b;
  border-top-left-radius: 8px;
  border-bottom-left-radius: 8px;
}

input[type="file"].form-control {
  background-color: #f8fafc;
  color: #475569;
  border: 1px solid #cbd5e1;
  padding: 6px 10px;
}

input[type="file"]::file-selector-button {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #1e293b;
  border-radius: 6px;
  padding: 5px 12px;
  margin-right: 12px;
  font-weight: 600;
  font-size: 0.84rem;
  cursor: pointer;
  transition: all 150ms ease;
}

input[type="file"]::file-selector-button:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

/* 7. Tablas de Gestión */
.table-custom {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  overflow: hidden;
}

.table-custom th {
  background-color: #f8fafc;
  color: #475569;
  font-size: 0.76rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 11px 14px;
  border-bottom: 1px solid #e2e8f0;
}

.table-custom td {
  background-color: #ffffff;
  padding: 11px 14px;
  color: #1e293b;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
}

.table-custom tr:last-child td {
  border-bottom: none;
}

.table-custom tr:hover td {
  background-color: #f8fafc;
}

.table-custom td[colspan] {
  text-align: center;
  padding: 28px 14px;
  color: #64748b;
  font-weight: 500;
}

.alert-custom-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #b91c1c;
  border-radius: 8px;
  font-size: 0.86rem;
  font-weight: 500;
}

/* 8. Selector de Modalidad de Fechas */
.date-mode-pills .btn {
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 5px 12px;
  transition: all 150ms ease;
}

.date-mode-pills .btn.active {
  background-color: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.feria-fecha-fila {
  background-color: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 10px;
}

/* 9. Guía Interactiva y Tour Guiado del Panel Admin */
.how-it-works-step {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  text-align: left;
}

.how-it-works-icon {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
}

#modal-admin-how-it-works .modal-content {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  overflow: hidden !important;
}

#modal-admin-how-it-works .modal-header {
  flex: 0 0 auto;
  align-items: flex-start;
  gap: 12px;
}

#modal-admin-how-it-works .modal-header > .d-flex,
#modal-admin-how-it-works .modal-header > .d-flex > div:last-child,
#modal-admin-how-it-works .how-it-works-step > div:last-child {
  min-width: 0;
}

#modal-admin-how-it-works .modal-header > .d-flex {
  flex: 1 1 auto;
  overflow: hidden;
}

#modal-admin-how-it-works .modal-content,
#modal-admin-how-it-works .modal-body > .row,
#modal-admin-how-it-works .modal-body > .row > * {
  min-width: 0;
  max-width: 100%;
}

#modal-admin-how-it-works .modal-title,
#modal-admin-how-it-works .modal-header small,
#modal-admin-how-it-works .how-it-works-step span {
  overflow-wrap: anywhere;
}

#modal-admin-how-it-works .modal-body {
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

#modal-admin-how-it-works .btn-close {
  flex: 0 0 auto;
  width: 1rem;
  height: 1rem;
  padding: 0.75rem;
  margin: -0.5rem -0.5rem 0 auto;
  position: relative;
  z-index: 2;
}

@media (max-width: 575.98px) {
  header.app-header .container {
    max-width: 100%;
    padding-left: 8px;
    padding-right: 8px;
    gap: 6px;
  }

  header.app-header .brand {
    min-width: 0;
    flex: 1 1 auto;
  }

  header.app-header .brand-logo-img {
    height: 30px;
    max-width: 118px;
  }

  header.app-header .brand-badge {
    display: none;
  }

  header.app-header .container > .d-flex:last-child {
    flex: 0 0 auto;
    gap: 4px !important;
  }

  header.app-header .btn-header-secondary,
  header.app-header .btn-logout {
    width: 34px;
    height: 34px;
    min-width: 34px;
    padding: 0;
    justify-content: center;
  }

  #modal-admin-how-it-works {
    padding: 0 !important;
  }

  #modal-admin-how-it-works .modal-dialog {
    width: calc(100vw - 16px) !important;
    max-width: calc(100vw - 16px) !important;
    min-height: calc(100vh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    min-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    margin: calc(8px + env(safe-area-inset-top, 0px)) 8px calc(8px + env(safe-area-inset-bottom, 0px));
  }

  #modal-admin-how-it-works .modal-content {
    width: 100%;
    max-height: calc(100vh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    max-height: calc(100dvh - 16px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    border-radius: 14px !important;
  }

  #modal-admin-how-it-works .modal-header {
    padding: 14px 14px 8px !important;
  }

  #modal-admin-how-it-works .modal-header img {
    width: 32px !important;
    height: 32px !important;
  }

  #modal-admin-how-it-works .modal-title {
    font-size: 1rem;
    line-height: 1.25;
  }

  #modal-admin-how-it-works .modal-header small {
    display: block;
    margin-top: 2px;
    font-size: 0.74rem;
    line-height: 1.3;
  }

  #modal-admin-how-it-works .modal-body {
    padding: 10px 14px 14px !important;
  }

  #modal-admin-how-it-works .modal-body > .row {
    --bs-gutter-y: 0.65rem;
  }

  #modal-admin-how-it-works .how-it-works-step {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    gap: 10px;
    padding: 11px;
  }

  #modal-admin-how-it-works .how-it-works-icon {
    width: 36px;
    height: 36px;
    min-width: 36px;
    font-size: 1rem;
  }

  #modal-admin-how-it-works .how-it-works-step strong {
    font-size: 0.88rem;
    line-height: 1.3;
  }

  #modal-admin-how-it-works .how-it-works-step span {
    display: block;
    font-size: 0.8rem;
    line-height: 1.42;
  }

  #modal-admin-how-it-works .modal-body > .border-top {
    flex-direction: column;
    align-items: stretch !important;
    margin-top: 12px !important;
    padding-top: 12px !important;
  }

  #modal-admin-how-it-works .modal-body > .border-top .d-flex,
  #modal-admin-how-it-works .modal-body > .border-top .btn {
    width: 100%;
  }

  #modal-admin-how-it-works .modal-body > .border-top .btn {
    min-height: 42px;
    white-space: normal;
  }
}

@media (max-height: 600px) and (orientation: landscape) {
  #modal-admin-how-it-works .modal-dialog {
    align-items: flex-start;
  }

  #modal-admin-how-it-works .modal-header small {
    display: none;
  }
}

.tour-active-highlight {
  position: relative;
  z-index: 20 !important;
  border-color: #3b82f6 !important;
  box-shadow: 0 0 0 2px #3b82f6 !important;
  outline: 3px solid #3b82f6 !important;
  outline-offset: 3px;
  border-radius: 8px !important;
}

.tour-floating-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92%, 460px);
  background: #171A21;
  color: #F3F4F6;
  border-radius: 14px;
  padding: 16px 18px;
  z-index: 10000;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.55);
  border: 1px solid #262B36;
}

/* =========================================================
   10. MODO OSCURO PROFESIONAL (ESTILO LINEAR / STRIPE / VERCEL)
   Fondo: #0E1116 | Tarjetas: #171A21 | Bordes: #262B36
   Títulos: #F3F4F6 | Subtítulos: #9CA3AF
   ========================================================= */
html[data-theme="dark"] {
  color-scheme: dark;
}

[data-theme="dark"] body {
  background-color: #0E1116 !important;
  background-image: none !important;
  color: #E2E8F0 !important;
}

[data-theme="dark"] header.app-header {
  background: #0E1116 !important;
  border-bottom: 1px solid #262B36 !important;
  box-shadow: none !important;
}

/* Logo monocromo blanco/gris claro en Modo Oscuro */
[data-theme="dark"] .brand-logo-img {
  filter: brightness(0) invert(1) opacity(0.92);
}

[data-theme="dark"] .brand-badge {
  background: #171A21 !important;
  color: #D1D5DB !important;
  border: 1px solid #262B36 !important;
}

[data-theme="dark"] .btn-header-secondary {
  background: transparent !important;
  border: 1px solid #262B36 !important;
  color: #D1D5DB !important;
}

[data-theme="dark"] .btn-header-secondary:hover {
  background: #171A21 !important;
  border-color: #384050 !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .btn-logout {
  background: transparent !important;
  border-color: rgba(239, 68, 68, 0.4) !important;
  color: #f87171 !important;
}

[data-theme="dark"] .btn-logout:hover {
  background: #ef4444 !important;
  color: #ffffff !important;
}

/* Tarjetas Administrativas */
[data-theme="dark"] .admin-card {
  background: #171A21 !important;
  border: 1px solid #262B36 !important;
  box-shadow: none !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .admin-card h2,
[data-theme="dark"] .admin-card h3,
[data-theme="dark"] .text-dark {
  color: #F3F4F6 !important;
}

[data-theme="dark"] .text-muted,
[data-theme="dark"] .text-secondary,
[data-theme="dark"] .form-label,
[data-theme="dark"] label {
  color: #9CA3AF !important;
}

/* Pestañas (Tabs) en Modo Oscuro */
[data-theme="dark"] .nav-pills {
  border-bottom: 1px solid #262B36 !important;
}

[data-theme="dark"] body .nav-pills .nav-link {
  color: #9CA3AF !important;
}

[data-theme="dark"] body .nav-pills .nav-link:hover {
  color: #F3F4F6 !important;
  border-bottom-color: #384050 !important;
}

[data-theme="dark"] body .nav-pills .nav-link.active,
[data-theme="dark"] body .nav-pills .nav-link.active:hover {
  color: #F3F4F6 !important;
  border-bottom: 2px solid #3B82F6 !important;
}

/* Formularios e Inputs en Modo Oscuro */
[data-theme="dark"] body .form-control,
[data-theme="dark"] body .form-select,
[data-theme="dark"] textarea.form-control {
  background-color: #0E1116 !important;
  border: 1px solid #262B36 !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] body .form-control:focus,
[data-theme="dark"] body .form-select:focus,
[data-theme="dark"] textarea.form-control:focus {
  background-color: #0E1116 !important;
  border-color: #4B5563 !important;
  color: #F3F4F6 !important;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.06) !important;
}

[data-theme="dark"] body .form-control::placeholder,
[data-theme="dark"] textarea.form-control::placeholder {
  color: #6B7280 !important;
}

[data-theme="dark"] body .form-select option {
  background-color: #171A21 !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .input-group-text {
  background-color: #171A21 !important;
  border-color: #262B36 !important;
  color: #9CA3AF !important;
}

[data-theme="dark"] input[type="file"]::file-selector-button {
  background: #202530 !important;
  border: 1px solid #2E3442 !important;
  color: #E5E7EB !important;
}

[data-theme="dark"] input[type="file"]::file-selector-button:hover {
  background: #2A303D !important;
  color: #FFFFFF !important;
}

/* Tablas en Modo Oscuro */
[data-theme="dark"] .table-custom,
[data-theme="dark"] .table {
  border-color: #262B36 !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .table-custom th,
[data-theme="dark"] .table thead th {
  background-color: #0E1116 !important;
  color: #9CA3AF !important;
  border-bottom: 1px solid #262B36 !important;
}

[data-theme="dark"] .table-custom td,
[data-theme="dark"] .table tbody td {
  background-color: #171A21 !important;
  color: #E5E7EB !important;
  border-bottom: 1px solid #262B36 !important;
}

[data-theme="dark"] .table-custom tr:hover td,
[data-theme="dark"] .table tbody tr:hover td {
  background-color: #1D212A !important;
}

[data-theme="dark"] .border-bottom,
[data-theme="dark"] .border-top,
[data-theme="dark"] .border-light-subtle {
  border-color: #262B36 !important;
}

[data-theme="dark"] .bg-primary-subtle,
[data-theme="dark"] .bg-success-subtle,
[data-theme="dark"] .bg-warning-subtle,
[data-theme="dark"] .bg-info-subtle,
[data-theme="dark"] .bg-secondary-subtle {
  background-color: #202530 !important;
  border-color: #2E3442 !important;
  color: #D1D5DB !important;
}

/* Modales en Modo Oscuro */
[data-theme="dark"] .modal-content,
[data-theme="dark"] .swal2-popup {
  background-color: #171A21 !important;
  color: #F3F4F6 !important;
  border: 1px solid #262B36 !important;
}

[data-theme="dark"] .how-it-works-step,
[data-theme="dark"] .feria-fecha-fila {
  background-color: #0E1116 !important;
  border-color: #262B36 !important;
  color: #F3F4F6 !important;
}

[data-theme="dark"] .modal-content .btn-close:not(.btn-close-white) {
  filter: invert(1) grayscale(100%) brightness(200%);
}

/* Mantiene visible el elemento activo de la guía sobre tarjetas oscuras. */
[data-theme="dark"] .tour-active-highlight {
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 2px rgba(96, 165, 250, 0.4),
              0 0 22px rgba(59, 130, 246, 0.42) !important;
  outline-color: #93c5fd !important;
}
