/**
 * Estilos centralizados — Validación y Panel Admin (SEMOVI / CDMX)
 */

:root {
    --color-primary-dark: #0B1C2C;
    --color-accent: #2563EB;
    --color-vino: rgb(159, 34, 65);
    --color-gold: #b18c5b;
    --bg-page: #efefef;
    --shadow-toast: 0 8px 24px rgba(0, 0, 0, 0.2);
}

body {
    background: var(--bg-page);
}

body.page-admin {
    padding-bottom: 120px;
}

.navbar-institutional {
    border-bottom: 7px solid var(--color-vino);
}

footer.site-footer {
    border-top: 8px solid var(--color-gold) !important;
}

/* —— Vista pública —— */
.fondo {
    position: absolute;
    height: 25%;
    width: 80%;
    z-index: -2;
    top: 65%;
    left: 10%;
}

.fondo-gris {
    position: fixed;
    height: 100%;
    width: 100%;
    z-index: -1;
    background: rgba(255, 255, 255, 0.3);
}

/* —— Panel admin —— */
.admin-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    min-width: 260px;
    max-width: 360px;
    padding: 12px 16px;
    border-radius: 4px;
    font-weight: 600;
    box-shadow: var(--shadow-toast);
}

body.page-admin .admin-toast {
    animation: none;
}

body.page-admin [class*="animate__"] {
    animation: none !important;
}

.admin-toast.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.admin-toast.error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

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

.stats-bar {
    display: none;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

.stats-bar.active {
    display: flex;
}

.badge-stat {
    background: #e8f4fd;
    color: #0c5460;
    border: 1px solid #bee5eb;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.badge-stat.gold {
    background: #fff8e6;
    color: #856404;
    border-color: #ffeeba;
}

.badge-stat.license-timer {
    background: #ecfdf5;
    color: #047857;
    border-color: #6ee7b7;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.badge-stat.license-timer.urgent {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #fca5a5;
}

.view-panel {
    display: none;
}

.view-panel.active {
    display: block;
}

.table-historial {
    width: 100%;
    font-size: 0.85rem;
}

.table-historial th,
.table-historial td {
    padding: 8px 6px;
    border-bottom: 1px solid #dee2e6;
    vertical-align: middle;
}

.table-historial th {
    color: #6c757d;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.folio-link {
    color: #28a745;
    font-family: Consolas, monospace;
    cursor: pointer;
    font-weight: 600;
    word-break: break-all;
    font-size: 0.82rem;
}

.folio-link:hover {
    text-decoration: underline;
}

.font-mono {
    font-family: Consolas, "Courier New", monospace;
    font-size: 0.88rem;
}

.numlic-tag {
    color: #17a2b8;
    font-family: Consolas, monospace;
    font-weight: 600;
}

.btn-actions-row {
    display: flex;
    gap: 4px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.btn-actions-row .btn {
    padding: 4px 8px;
    font-size: 0.75rem;
}

.edit-banner {
    display: none;
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
    padding: 8px 12px;
    border-radius: 4px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    font-weight: 600;
}

.edit-banner.active {
    display: block;
}

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 10000;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.modal-overlay.active {
    display: flex;
}

/* Permisos consulta: no pisar #modalPermisoResultado (estilos en modal-resultado.css) */
body.page-permiso #modalPermisoResultado.modal-overlay {
    z-index: 10500;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.55);
}

body.page-permiso #modalPermisoResultado.modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-box {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    max-width: 360px;
    width: 100%;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.modal-box canvas {
    margin: 12px auto;
    background: #fff;
    padding: 8px;
    border: 1px solid #dee2e6;
}

.modal-url {
    font-size: 0.75rem;
    color: #6c757d;
    word-break: break-all;
    margin-top: 8px;
}

.modal-box--pdf {
    max-width: 420px;
    text-align: left;
}

.pdf-progress-message {
    font-size: 0.9rem;
    margin-bottom: 12px;
    min-height: 2.6em;
    color: #333;
}

.pdf-progress-track {
    height: 10px;
    background: #e9ecef;
    border-radius: 5px;
    overflow: hidden;
}

.pdf-progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--color-accent), #1d4ed8);
    border-radius: 5px;
    transition: width 0.35s ease;
}

.pdf-progress-percent {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--color-accent);
    margin: 8px 0 0;
    text-align: right;
}

#pdfServiceFrame {
    position: absolute;
    width: 1px;
    height: 1px;
    left: -9999px;
    top: 0;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

/* —— Páginas públicas: layout columna (footer al final, sin solapar contenido) —— */
body.page-hub,
body.page-licencia,
body.page-permiso {
    overflow-x: hidden;
}

body.page-hub #app.bg-gradient-cyan,
body.page-licencia #app.bg-gradient-cyan,
body.page-permiso #app.bg-gradient-cyan {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body.page-permiso #app > .navbar.navbar-institutional {
    position: sticky;
    top: 0;
    z-index: 1030;
    flex-shrink: 0;
    width: 100%;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

body.page-hub main,
body.page-licencia main,
body.page-permiso main {
    flex: 1 1 auto;
    width: 100%;
    min-width: 0;
}

body.page-hub footer.site-footer,
body.page-licencia footer.site-footer,
body.page-permiso footer.site-footer {
    position: relative !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    height: auto !important;
    width: 100%;
    flex-shrink: 0;
    margin-top: auto;
    background: #000;
    z-index: 1;
}

body.page-hub footer.site-footer .container,
body.page-licencia footer.site-footer .container,
body.page-permiso footer.site-footer .container {
    margin-bottom: 0 !important;
    padding: 0.25rem 15px 0.5rem;
}

body.page-hub footer.site-footer img,
body.page-licencia footer.site-footer img,
body.page-permiso footer.site-footer img {
    display: block;
    max-width: min(100%, 280px);
    height: auto;
    max-height: 80px;
    width: auto;
}

body.page-hub .navbar-institutional .container,
body.page-licencia .navbar-institutional .container,
body.page-permiso .navbar-institutional .container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
}

body.page-hub .navbar-institutional .navbar-brand img,
body.page-licencia .navbar-institutional .navbar-brand img,
body.page-permiso .navbar-institutional .navbar-brand img {
    height: auto;
    max-height: 48px;
    width: auto;
}

.modal-box--wide {
    max-width: 720px;
    width: 94%;
}

.pdf-admin-track {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.pdf-admin-bar {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, #2563eb, #50358d);
    transition: width 0.25s ease;
}

.pdf-admin-iframe {
    width: 100%;
    height: 1px;
    border: 0;
    opacity: 0;
    pointer-events: none;
}

.form-section-compact,
.form-section-cdmx,
.form-section-oficial {
    transition: opacity 0.15s ease;
}

/* —— Panel admin: responsive —— */
body.page-admin {
    padding-bottom: 24px;
    overflow-x: hidden;
}

body.page-admin #app {
    min-height: 100vh;
    overflow-x: hidden;
}

body.page-admin footer.site-footer {
    position: relative !important;
    bottom: auto !important;
    height: auto !important;
    margin-top: 2rem;
}

body.page-admin .navbar-admin .container-fluid {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem 0.75rem;
}

body.page-admin .navbar-admin .navbar-brand img {
    max-height: 48px;
    width: auto;
    height: auto;
}

body.page-admin .navbar-admin > .container-fluid > .d-flex {
    flex: 1 1 280px;
    justify-content: flex-end;
    min-width: 0;
}

body.page-admin .stats-bar {
    flex: 1 1 auto;
    min-width: 0;
}

body.page-admin .stats-bar .badge-stat {
    max-width: 100%;
    white-space: normal;
    line-height: 1.3;
}

body.page-admin main .container {
    max-width: 100%;
}

body.page-admin .admin-workspace-row {
    margin-left: 0;
    margin-right: 0;
}

body.page-admin .admin-workspace-row > [class*="col-"] {
    padding-left: 12px;
    padding-right: 12px;
}

body.page-admin .card {
    overflow: hidden;
}

body.page-admin .padron-table-wrap {
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

body.page-admin .table-padron {
    min-width: 640px;
}

body.page-admin .table-padron td:nth-child(3) {
    min-width: 120px;
    max-width: 220px;
    word-break: break-word;
}

body.page-admin .table-historial {
    min-width: 0;
}

body.page-admin .modal-box {
    max-height: calc(100vh - 32px);
    overflow-y: auto;
}

body.page-admin .modal-box--wide {
    max-width: min(720px, 100%);
}

body.page-admin .input-group {
    flex-wrap: nowrap;
}

body.page-admin .input-group .form-control {
    min-width: 0;
}

@media (max-width: 991.98px) {
    body.page-admin main .container {
        margin-top: 0 !important;
        padding-left: 12px;
        padding-right: 12px;
    }

    body.page-admin .navbar-admin .navbar-brand img {
        max-height: 40px;
    }

    body.page-admin .navbar-admin > .container-fluid > .d-flex {
        flex-basis: 100%;
        justify-content: flex-start;
    }

    body.page-admin #btnLogout {
        margin-left: auto;
    }

    body.page-admin .table-padron th:last-child,
    body.page-admin .table-padron td:last-child {
        position: sticky;
        right: 0;
        z-index: 2;
        background: #fff;
        box-shadow: -6px 0 10px rgba(0, 0, 0, 0.06);
    }

    body.page-admin .table-padron thead th:last-child {
        z-index: 3;
    }
}

@media (max-width: 767.98px) {
    body.page-admin {
        padding-bottom: 16px;
    }

    body.page-admin .card-body {
        padding: 1rem;
    }

    body.page-admin .card-header {
        font-size: 0.95rem;
        padding: 0.65rem 0.75rem;
    }

    body.page-admin .form-row > [class*="col-md"],
    body.page-admin .form-row > [class*="col-lg"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    body.page-admin .padron-toolbar > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    body.page-admin .padron-toolbar > .col-4,
    body.page-admin .padron-toolbar > .col-8 {
        flex: 0 0 50%;
        max-width: 50%;
    }

    body.page-admin .btn-actions-row {
        flex-wrap: nowrap;
        gap: 3px;
    }

    body.page-admin .btn-actions-row .btn {
        padding: 4px 6px;
        font-size: 0.7rem;
    }

    body.page-admin .admin-toast {
        left: 12px;
        right: 12px;
        max-width: none;
    }

    body.page-admin #loginView .col-md-5 {
        flex: 0 0 100%;
        max-width: 100%;
    }
}

@media (max-width: 575.98px) {
    body.page-admin .navbar-admin .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }

    body.page-admin .stats-bar {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }

    body.page-admin .stats-bar .badge-stat {
        width: 100%;
        text-align: center;
    }

    body.page-admin #btnLogout {
        width: 100%;
        margin-left: 0;
    }

    body.page-admin .d-flex.gap-2.flex-wrap.mb-2 .btn {
        flex: 1 1 100%;
    }

    body.page-admin .table-padron {
        min-width: 580px;
    }

    body.page-admin .folio-link {
        font-size: 0.72rem;
    }
}

/* —— Hub (index) — misma línea visual que validación de licencias —— */
body.page-hub .hub-main {
    margin-top: clamp(0.75rem, 2vw, 2%);
    padding-bottom: 1.5rem;
}

body.page-hub .hub-hero-wrap {
    max-width: 960px;
}

body.page-hub .hub-hero-title {
    font-size: clamp(1.35rem, 3.5vw, 1.85rem);
    margin-bottom: 0.5rem;
    letter-spacing: 0.02em;
}

body.page-hub .hub-hero-sub {
    font-size: 1rem;
    margin-bottom: 0.35rem;
}

body.page-hub .hub-hero-hint {
    color: #555;
    font-size: 0.95rem;
    margin: 0 0 2.5rem;
}

body.page-hub .hub-cards-row {
    margin-left: 0;
    margin-right: 0;
}

body.page-hub .hub-choice-img {
    max-width: 100%;
    height: auto;
    width: auto;
}

body.page-hub .hub-choice-link {
    text-decoration: none;
    color: inherit;
    display: block;
    height: 100%;
}

body.page-hub .hub-choice-card {
    height: 100%;
    border: 1px solid #dde4ea;
    box-shadow: 0 4px 18px rgba(11, 28, 44, 0.08);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

body.page-hub .hub-choice-link:hover .hub-choice-card,
body.page-hub .hub-choice-link:focus-visible .hub-choice-card {
    transform: translateY(-6px);
    border-color: var(--color-vino);
    box-shadow: 0 12px 28px rgba(159, 34, 65, 0.18);
}

body.page-hub .hub-choice-card .card-header {
    font-size: 0.95rem;
    letter-spacing: 0.04em;
}

body.page-hub .hub-choice-visual {
    margin: 1rem 0 1.25rem;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

body.page-hub .hub-choice-visual--permiso {
    background: linear-gradient(145deg, #e8f4fc 0%, #fff 60%);
    border-radius: 12px;
    margin-left: auto;
    margin-right: auto;
    max-width: 220px;
    width: 100%;
}

body.page-hub .hub-permiso-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: var(--color-vino);
    color: #fff;
    font-size: 3.5rem;
    font-weight: 800;
    font-family: system-ui, sans-serif;
    box-shadow: 0 8px 24px rgba(159, 34, 65, 0.35);
}

body.page-hub .hub-choice-desc {
    color: #444;
    font-size: 0.92rem;
    margin-bottom: 1.25rem;
    line-height: 1.45;
}

body.page-hub .hub-btn-cta {
    border-width: 2px;
    font-weight: 600;
    letter-spacing: 0.03em;
    pointer-events: none;
}

body.page-hub .hub-choice-link:hover .hub-btn-cta {
    background-color: var(--color-vino);
    border-color: var(--color-vino);
    color: #fff;
}

body.page-hub .hub-choice-card--static {
    cursor: default;
}

body.page-hub .hub-btn-cta--muted {
    pointer-events: none;
    opacity: 0.85;
}

/* —— Licencias (consulta pública) —— */
body.page-licencia .licencia-main {
    padding-bottom: 1.5rem;
}

body.page-licencia .licencia-intro {
    margin-top: clamp(1rem, 4vw, 3rem);
}

body.page-licencia .licencia-hero-title {
    font-size: clamp(1.15rem, 4vw, 1.65rem);
    margin-bottom: 1rem;
}

body.page-licencia .licencia-hero-visual {
    margin: 0.5rem 0 0;
}

body.page-licencia .licencia-hero-img {
    max-width: 100%;
    height: auto;
    width: auto;
}

body.page-licencia .licencia-hero-card .card-body {
    padding: 1.25rem 1rem 1.5rem;
}

/* —— Permisos consulta (misma línea que licencias + tarjetas Bootstrap) —— */
body.page-permiso .permiso-main {
    padding-top: 0.35rem;
    padding-bottom: 1.5rem;
}

body.page-permiso .permiso-consulta-wrap {
    margin-top: 0.35rem;
}

body.page-permiso .permiso-consulta-header {
    color: #e3342f;
}

body.page-permiso .permiso-consulta-header strong {
    font-weight: 700;
}

body.page-permiso .permiso-consulta-title {
    font-size: clamp(1.1rem, 4vw, 1.65rem);
}

body.page-permiso .permiso-search-card-embed {
    padding: 0.25rem 0 0;
}

body.page-permiso .permiso-search-card-embed .permiso-search-card {
    box-shadow: none;
    border: none;
    padding: 0;
    border-top: none;
    background: transparent;
}

body.page-permiso .permiso-leyenda-card {
    border: 1px solid #dde4ea;
    box-shadow: 0 4px 14px rgba(11, 28, 44, 0.06);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}

body.page-permiso .permiso-leyenda-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(159, 34, 65, 0.12);
}

body.page-permiso .permiso-leyenda-card h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--color-primary-dark);
    margin: 0.75rem 0 0.35rem;
}

body.page-permiso .hub-choice-visual--permiso {
    margin: 0 auto;
}

@media (max-width: 991.98px) {
    body.page-hub .hub-hero-wrap,
    body.page-licencia .licencia-intro,
    body.page-permiso .container {
        padding-left: 12px;
        padding-right: 12px;
    }
}

@media (max-width: 767.98px) {
    body.page-hub .hub-hero {
        margin-bottom: 0.5rem;
    }

    body.page-hub .hub-hero-hint {
        margin-bottom: 1.5rem;
    }

    body.page-hub .hub-choice-visual {
        min-height: 140px;
    }

    body.page-hub .hub-permiso-icon {
        width: 96px;
        height: 96px;
        font-size: 2.75rem;
    }

    body.page-hub .hub-choice-card .card-body,
    body.page-hub .hub-choice-card .card-header {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    body.page-licencia .licencia-hero-card .card-body {
        padding: 1rem 0.75rem 1.25rem;
    }
}

@media (max-width: 575.98px) {
    body.page-hub .navbar-institutional .container,
    body.page-licencia .navbar-institutional .container {
        padding-left: 12px;
        padding-right: 12px;
    }

    body.page-hub .navbar-institutional > .container > .d-flex,
    body.page-licencia .navbar-institutional > .container > .d-flex {
        flex-basis: 100%;
        justify-content: center;
    }

    body.page-hub .navbar-institutional .d-flex.gap-2,
    body.page-licencia .navbar-institutional .d-flex.gap-2 {
        font-size: 0.85rem;
    }

    body.page-hub .navbar-institutional .navbar-brand img,
    body.page-licencia .navbar-institutional .navbar-brand img {
        max-height: 40px;
    }

    body.page-hub footer.site-footer img,
    body.page-licencia footer.site-footer img {
        max-height: 56px;
    }
}
