/* PanelWEB2 · Visual Refresh v3.04
   SOLO PRESENTACION. No altera rutas, datos, CheckUser, APK ni motores. */

:root {
  --vr-mobile-sidebar: min(86vw, 320px);
  --vr-radius: 18px;
  --vr-gap: 14px;
  --vr-border: rgba(255, 255, 255, .13);
  --vr-surface: rgba(11, 24, 42, .94);
  --vr-surface-soft: rgba(255, 255, 255, .045);
  --vr-shadow: 0 18px 46px rgba(0, 0, 0, .28);
}

[data-bs-theme="light"] {
  --vr-border: rgba(20, 34, 52, .16);
  --vr-surface: rgba(250, 252, 255, .97);
  --vr-surface-soft: rgba(15, 40, 75, .035);
  --vr-shadow: 0 14px 34px rgba(18, 35, 57, .12);
}

html,
body {
  min-width: 0;
  max-width: 100%;
}

body.panel-page {
  overflow-x: hidden;
}

body.panel-page main.d-flex,
body.panel-page main.d-flex > .container-fluid,
body.panel-page .main-content-wrapper,
body.panel-page .content,
body.panel-page .card,
body.panel-page .card-body {
  min-width: 0;
}

/* Color de navegacion coherente en todas las paginas, no azul electrico. */
body.panel-page .sidebar {
  background: #0b1d33 !important;
  border-right: 1px solid var(--panel-border, var(--vr-border));
}

body.panel-page .sidebar-header {
  flex: 0 0 auto;
}

body.panel-page .sidebar-nav {
  min-height: 0;
}

/* Desktop: mas ancho util y menos efecto de panel dentro de panel. */
@media (min-width: 992px) {
  body.panel-page .main-content-wrapper {
    margin: 12px 14px 14px !important;
    border-radius: 24px !important;
    min-width: 0;
  }

  body.panel-page .header {
    min-height: 64px;
    padding: 14px 18px !important;
    align-items: center;
  }

  body.panel-page .content {
    padding: 18px !important;
  }

  body.panel-page .content > .card {
    border-radius: var(--vr-radius) !important;
  }

  body.panel-page .table-responsive,
  body.panel-page .table-responsive-md {
    border-radius: 14px;
  }
}

body.panel-page .btn,
body.panel-page .form-control,
body.panel-page .form-select,
body.panel-page .input-group-text {
  min-height: 42px;
}

body.panel-page .btn-sm {
  min-height: 34px;
}

body.panel-page .modal-content {
  border-radius: 18px;
  overflow: hidden;
}

body.panel-page .modal-body {
  overscroll-behavior: contain;
}

/* ===== MOVIL: una sola capa, sidebar flotante y contenido al 100% ===== */
@media (max-width: 991.98px) {
  html,
  body.panel-page {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
  }

  body.panel-page::before,
  body.panel-page::after {
    opacity: .24;
  }

  body.panel-page main.d-flex {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
  }

  body.panel-page main.d-flex > .container-fluid,
  body.panel-page .main-content-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    overflow: visible !important;
    min-height: 100dvh;
  }

  body.panel-page .sidebar {
    position: fixed !important;
    inset: 0 auto 0 0 !important;
    width: var(--vr-mobile-sidebar) !important;
    max-width: 320px !important;
    height: 100dvh !important;
    min-height: 100dvh !important;
    margin: 0 !important;
    padding: max(15px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom)) !important;
    transform: translate3d(-105%, 0, 0);
    transition: transform .24s ease, box-shadow .24s ease !important;
    display: flex;
    flex-direction: column;
    overflow: hidden !important;
    z-index: 2050 !important;
    box-shadow: none !important;
  }

  body.panel-page .sidebar.active {
    transform: translate3d(0, 0, 0);
    box-shadow: 20px 0 55px rgba(0, 0, 0, .55) !important;
  }

  body.panel-page .sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding-right: 3px;
  }

  body.panel-page .nav-link {
    width: 100% !important;
    min-height: 47px;
    padding: 10px 12px;
    border-radius: 11px;
    gap: 11px;
  }

  body.panel-page .nav-item {
    width: 100% !important;
  }

  body.panel-page .nav-item a > i {
    flex: 0 0 26px;
    text-align: center;
    font-size: 1.15rem;
  }

  body.panel-page .header {
    position: sticky;
    top: 0;
    z-index: 900;
    width: 100%;
    min-height: 64px;
    padding: 9px 11px !important;
    align-items: center;
    background: rgba(8, 20, 35, .96) !important;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    border-bottom: 1px solid var(--panel-border, var(--vr-border));
  }

  [data-bs-theme="light"] body.panel-page .header,
  body.panel-page[data-bs-theme="light"] .header {
    background: rgba(250, 252, 255, .96) !important;
  }

  body.panel-page .header > .d-flex {
    min-width: 0;
    gap: 5px;
  }

  body.panel-page .header button#openNav {
    display: inline-grid !important;
    visibility: visible !important;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: 0;
    flex: 0 0 44px;
  }

  body.panel-page .header a {
    min-height: 42px;
    margin: 0 !important;
    padding: 5px 7px !important;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  body.panel-page .header [data-notifications-badge] {
    width: 42px;
    max-width: 42px;
    flex: 0 0 42px;
    justify-content: center;
    margin-right: 1px !important;
  }

  body.panel-page #toggle-theme-btn {
    flex: 0 0 38px;
    width: 38px !important;
    height: 38px !important;
    margin: 0 !important;
  }

  body.panel-page .content {
    width: 100% !important;
    height: auto !important;
    min-height: calc(100dvh - 64px);
    padding: 12px !important;
    overflow: visible !important;
    background: #07111f !important;
  }

  [data-bs-theme="light"] body.panel-page .content,
  body.panel-page[data-bs-theme="light"] .content {
    background: #f5f7fa !important;
  }

  body.panel-page .content > .card {
    width: 100%;
    min-height: calc(100dvh - 88px);
    height: auto !important;
    overflow: visible !important;
    border-radius: 15px !important;
    background: rgba(255, 255, 255, .035) !important;
  }

  body.panel-page .content > .card > .card-body {
    padding: 14px !important;
  }

  body.panel-page .content h1,
  body.panel-page .content h1.h3 {
    font-size: clamp(1.3rem, 6vw, 1.75rem) !important;
    line-height: 1.15;
    margin-bottom: 1rem !important;
  }

  body.panel-page .modal-dialog {
    width: calc(100% - 16px) !important;
    max-width: 680px !important;
    margin: 8px auto !important;
  }

  body.panel-page .modal-content {
    max-height: calc(100dvh - 16px);
  }

  body.panel-page .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  body.panel-page .row {
    --bs-gutter-x: .8rem;
  }
}

@media (max-width: 480px) {
  body.panel-page .header > .d-flex > a[href="/profile"] {
    max-width: 92px;
    font-size: .9rem;
  }

  body.panel-page .header > .d-flex > a[href="/profile"] img {
    width: 28px !important;
    height: 28px !important;
    margin-left: 4px !important;
  }
}

/* ===== CONFIGURACIONES ===== */
@media (max-width: 767.98px) {
  body.page-configs .card-body > .d-md-flex.justify-content-between {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  body.page-configs .card-body > .d-md-flex.justify-content-between > * {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  body.page-configs .card-body > .d-md-flex.justify-content-between > .d-flex.flex-column:first-child .d-flex {
    display: grid !important;
    grid-template-columns: minmax(112px, .36fr) minmax(0, 1fr);
    gap: 8px;
  }

  body.page-configs .config-status,
  body.page-configs .search-config {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  body.page-configs .card-body > .d-md-flex.justify-content-between > .d-flex.flex-column:last-child > .d-flex {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    min-width: 0 !important;
    margin: 0 0 8px !important;
  }

  body.page-configs .card-body > .d-md-flex.justify-content-between > .d-flex.flex-column:last-child .btn {
    width: 100% !important;
    min-width: 0;
    margin: 0 !important;
    padding: 8px 7px;
    white-space: normal;
    line-height: 1.15;
  }

  body.page-configs #root .table-responsive-md,
  body.page-configs #root .table-responsive {
    overflow: visible !important;
    height: auto !important;
  }

  body.page-configs #root table {
    display: block;
    width: 100%;
    margin: 0;
  }

  body.page-configs #root thead {
    display: none;
  }

  body.page-configs #root tbody {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
  }

  body.page-configs #root tbody tr {
    position: relative;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 12px;
    padding: 14px 12px 12px 44px;
    border: 1px solid var(--panel-border, var(--vr-border));
    border-radius: 15px;
    background: var(--pw-surface-soft, var(--vr-surface-soft));
    box-shadow: 0 7px 20px rgba(0, 0, 0, .1);
  }

  body.page-configs #root tbody td {
    display: block !important;
    width: auto !important;
    min-width: 0;
    padding: 2px 0 !important;
    border: 0 !important;
    white-space: normal !important;
    text-align: left !important;
  }

  body.page-configs #root tbody td::before {
    display: block;
    margin-bottom: 3px;
    font-size: .67rem;
    line-height: 1.1;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--muted, var(--pw-muted, #a9b6cb));
  }

  body.page-configs #root tbody td:nth-child(1) {
    position: absolute;
    left: 14px;
    top: 16px;
  }
  body.page-configs #root tbody td:nth-child(1)::before { content: none; }
  body.page-configs #root tbody td:nth-child(2)::before { content: "ID"; }
  body.page-configs #root tbody td:nth-child(3) {
    grid-column: 1 / -1;
    font-size: 1rem;
    font-weight: 700;
  }
  body.page-configs #root tbody td:nth-child(3)::before { content: "Nombre"; }
  body.page-configs #root tbody td:nth-child(4)::before { content: "Categoría"; }
  body.page-configs #root tbody td:nth-child(5)::before { content: "Orden"; }
  body.page-configs #root tbody td:nth-child(6)::before { content: "Modo"; }
  body.page-configs #root tbody td:nth-child(7)::before { content: "Estado"; }
  body.page-configs #root tbody td:nth-child(8) {
    grid-column: 1 / -1;
    display: flex !important;
    align-items: center;
    gap: 8px;
    padding-top: 8px !important;
    border-top: 1px solid var(--panel-border, var(--vr-border)) !important;
  }
  body.page-configs #root tbody td:nth-child(8)::before {
    content: "Acciones";
    margin-right: auto;
  }
  body.page-configs #root tbody td:nth-child(8) .btn {
    width: 42px;
    min-width: 42px;
    height: 40px;
    margin: 0 !important;
  }

  body.page-configs #root tbody td:nth-child(5) > div,
  body.page-configs #root tbody td:nth-child(7) > div {
    justify-content: flex-start !important;
  }

  body.page-configs .config-not-found h4 {
    white-space: normal !important;
    text-align: center;
  }
}

/* ===== MI APLICACION ===== */
@media (max-width: 767.98px) {
  body.page-application .card-body > .d-md-flex.justify-content-between {
    display: grid !important;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  body.page-application .card-body > .d-md-flex.justify-content-between > * {
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    margin: 0 !important;
  }

  body.page-application #app_config_status {
    width: 100%;
  }

  body.page-application .card-body > .d-md-flex.justify-content-between > .d-flex.flex-column > .d-flex {
    display: grid !important;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    min-width: 0 !important;
    margin: 0 0 8px !important;
  }

  body.page-application .card-body > .d-md-flex.justify-content-between .btn {
    width: 100% !important;
    min-width: 0 !important;
    margin: 0 !important;
    padding-inline: 7px;
    white-space: normal;
    line-height: 1.2;
  }

  body.page-application .aplicar-mejoras {
    min-height: 48px;
  }

  body.page-application #app.center-column {
    width: 100%;
    max-width: 430px;
    margin: 10px auto 24px !important;
    padding: 0;
    align-items: center !important;
    overflow: visible;
  }

  body.page-application #app.center-column > * {
    max-width: 100% !important;
  }

  body.page-application .app-modal-content {
    max-width: calc(100vw - 28px) !important;
  }

  body.page-application .CodeMirror,
  body.page-application .code-editor {
    max-width: calc(100vw - 34px);
  }
}

/* ===== DISEÑOS / ADMIN / EXCEL / MANTENIMIENTO ===== */
@media (max-width: 767.98px) {
  body.page-designs .card,
  body.page-admin-clients .card,
  body.page-admin-maintenance .card {
    border-radius: 14px !important;
  }

  body.page-designs .btn,
  body.page-admin-clients .btn,
  body.page-admin-maintenance .btn {
    white-space: normal;
  }

  body.page-admin-clients .table-responsive,
  body.page-admin-maintenance .table-responsive,
  body.page-designs .table-responsive {
    max-width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
}

/* Evita el header duplicado de las paginas premium: el nav incluido es el unico header visual. */
body.panel-page .header-shell {
  width: 100%;
  min-width: 0;
}
@media (max-width: 991.98px) {
  body.panel-page .sidebar.active {
    box-shadow: 18px 0 52px rgba(0,0,0,.55), 0 0 0 100vmax rgba(0,0,0,.48) !important;
  }
}
