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

:root {
    --bg-main: #006494;
    --header-bg: #043351;
    --header-text: #FFFFFF;
    --btn-primary: #F36E21;
    --btn-text: #FFFFFF;
    --text-dark: #1F2937;
    --text-muted: #6B7280;
    --card-bg: #FFFFFF;
    --border-color: #E5E7EB;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-dark);
}

body {
    display: flex;
    flex-direction: column;
}

/* ==========================================================================
   Cabecera Institucional
   ========================================================================== */
.top-nav-bar {
    background-color: var(--header-bg);
    height: auto;
    min-height: 90px;
    display: flex;
    align-items: center;
    padding: 16px 40px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
    z-index: 10;
}

.header-container {
    width: 100%;
    max-width: 1800px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: nowrap;
    gap: 24px;
}

.brand-logo {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.brand-logo img {
    display: block;
    height: 72px;
    width: auto;
    object-fit: contain;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-shrink: 0;
}

.header-badge {
    color: var(--header-text);
    font-size: 14px;
    font-weight: 500;
    background-color: rgba(0, 0, 0, 0.05);
    padding: 8px 16px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--header-text);
    opacity: 0.9;
    white-space: nowrap;
}

.badge-icon {
    display: inline-block;
    width: 16px;
    height: 18px;
    background-color: currentColor;
    -webkit-mask: url('/public/isotipo-escudo-ajustado.svg') no-repeat center / contain;
    mask: url('/public/isotipo-escudo-ajustado.svg') no-repeat center / contain;
}

/* Selector de Idioma */
.lang-selector {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
}

.lang-btn {
    background-color: transparent;
    color: var(--header-text);
    border: 1px solid var(--header-text);
    border-radius: 4px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background-color 0.2s, opacity 0.2s;
    opacity: 0.9;
}

.lang-btn:hover {
    background-color: rgba(0, 0, 0, 0.08);
    opacity: 1;
}

.dropdown-arrow {
    font-size: 8px;
    opacity: 0.8;
    transition: transform 0.2s;
}

.lang-dropdown {
    position: absolute;
    right: 0;
    top: calc(100% + 6px);
    background-color: #FFFFFF;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    list-style: none;
    padding: 4px 0;
    min-width: 125px;
    z-index: 100;
    display: none;
}

.lang-dropdown.show {
    display: block;
}

.lang-dropdown li {
    padding: 8px 14px;
    font-size: 13px;
    color: var(--text-dark);
    cursor: pointer;
    transition: background-color 0.15s;
}

.lang-dropdown li:hover {
    background-color: #F3F4F6;
}

.lang-dropdown li.active {
    font-weight: 700;
    color: var(--header-bg);
    background-color: #EFF6FF;
}

/* ==========================================================================
   Contenedor Principal y Formulario Inicial
   ========================================================================== */
.main-container {
    flex: 1 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.card-box {
    background-color: var(--card-bg);
    border-radius: 10px;
    padding: 36px 32px 24px 32px;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
    border-top: 5px solid var(--header-bg);
}

.card-header h2 {
    color: var(--header-bg);
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
    margin-bottom: 24px;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    color: var(--header-bg);
}

input[type="text"] {
    width: 100%;
    height: 48px;
    padding: 10px 14px;
    border: 1.5px solid #D1D5DB;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-dark);
    outline: none;
}

input[type="text"]:focus {
    border-color: var(--header-bg);
    box-shadow: 0 0 0 3px rgba(4, 51, 81, 0.15);
}

.field-hint {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 6px;
}

.rgpd-notice {
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.4;
    margin-top: 14px;
    text-align: center;
}

.rgpd-notice a {
    color: var(--header-bg);
    text-decoration: underline;
    font-weight: 500;
}

/* ==========================================================================
   Estilos de Botones
   ========================================================================== */
.btn-primary {
    width: 100%;
    height: 50px;
    background-color: var(--btn-primary);
    color: var(--btn-text);
    border: none;
    border-radius: 6px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transition: filter 0.2s;
}

.btn-primary:hover {
    filter: brightness(0.9);
}

.btn-full {
    width: 100%;
}

/* BotГіn Protagonista de Descarga (Ajustado con mГЎs aire arriba/abajo) */
.btn-download {
    margin: 24px 0;
    min-height: 56px;
    padding: 16px 20px;
    font-size: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background-color: var(--btn-primary);
    color: var(--btn-text);
    border: none;
    font-weight: 700;
    cursor: pointer;
    border-radius: 6px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    transition: filter 0.2s, transform 0.1s;
}

.btn-download:hover {
    filter: brightness(0.92);
}

.btn-download:active {
    transform: translateY(1px);
}
/* BotГіn Secundario Discreto (Consultar otro CSV) */
.btn-discreet {
    background: transparent;
    color: var(--text-muted);
    border: none;
    padding: 8px 12px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
    width: 100%;
    text-align: center;
    display: block;
}

.btn-discreet:hover {
    color: var(--header-bg);
}

.btn-secondary {
    background-color: #F3F4F6;
    color: #374151;
    border: 1px solid #D1D5DB;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.btn-secondary:hover {
    background-color: #E5E7EB;
}

.error-banner {
    margin-top: 16px;
    padding: 12px;
    background-color: #FEF2F2;
    border-left: 4px solid #EF4444;
    color: #991B1B;
    border-radius: 4px;
    font-size: 13px;
}

.trust-footer {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.trust-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ==========================================================================
   Panel de Resultado y Visor PDF
   ========================================================================== */
.result-layout {
    width: 100%;
    height: 100%;
    max-width: 1800px;
    background-color: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
    overflow: hidden;
}

.pdf-pane {
    flex: 1;
    height: 100%;
    background-color: #525659;
    display: flex;
    flex-direction: column;
}

/* Garantiza que el contenedor y el iframe ocupen el 100% real del espacio */
#pdf-container {
    width: 100%;
    height: 100%;
    flex: 1;
    display: flex;
}

#pdf-container iframe,
.pdf-pane iframe {
    width: 100%;
    height: 100%;
    min-height: 100%;
    border: none;
    display: block;
    flex: 1;
}

/* Sidebar de InformaciГіn */
.info-sidebar {
    background-color: #FFFFFF;
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.public-comments-box {
    background-color: #FEF3C7;
    border-left: 4px solid #F59E0B;
    color: #78350F;
    padding: 14px 16px;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.5;
    font-weight: 500;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.sidebar-section-title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
    margin-bottom: 12px;
}

.meta-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.meta-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.meta-label {
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.meta-value {
    color: var(--text-dark);
    font-size: 14px;
    font-weight: 600;
    word-break: break-word;
}

.signers-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.signer-card {
    background-color: #F8FAFC;
    border: 1px solid #E2E8F0;
    border-radius: 6px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.signer-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dark);
}

.signer-dni {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.signer-type {
    font-size: 12px;
    color: var(--text-muted);
}

/* Etiquetas de estado de firma */
.signer-status-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    margin-top: 4px;
    padding: 3px 10px;
    border-radius: 4px;
    width: fit-content;
}

.signer-status-tag.signed {
    background-color: #ECFDF5;
    color: #065F46;
    border: 1px solid #A7F3D0;
}

.signer-status-tag.notified {
    background-color: #FFFBEB;
    color: #92400E;
    border: 1px solid #FDE68A;
}

.signer-status-tag.rejected {
    background-color: #FEF2F2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

.signer-status-tag.pending {
    background-color: #EFF6FF;
    color: #1E40AF;
    border: 1px solid #BFDBFE;
}

.signer-status-tag.expired {
    background-color: #F3F4F6;
    color: #374151;
    border: 1px solid #D1D5DB;
}

/* ==========================================================================
   Pie de PГЎgina Legal Global
   ========================================================================== */
.app-footer {
    background-color: #FFFFFF;
    border-top: 1px solid var(--border-color);
    padding: 12px 24px;
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
    z-index: 10;
    position: relative;
}

.footer-content {
    max-width: 1800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.footer-links {
    display: flex;
    gap: 16px;
}

.footer-links a {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: var(--header-bg);
    text-decoration: underline;
}

/* Overlay de carga */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(4, 51, 81, 0.85);
    backdrop-filter: blur(3px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
}

.spinner-box {
    background: #FFFFFF;
    padding: 28px 36px;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 10px 25px rgba(0,0,0,0.3);
}

.spinner {
    width: 42px;
    height: 42px;
    border: 4px solid #E5E7EB;
    border-top-color: var(--btn-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 16px auto;
}

.loading-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--header-bg);
}

.loading-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   Media Queries (DiseГ±o Adaptativo)
   ========================================================================== */

/* Escritorio (>= 1024px) */
@media (min-width: 1024px) {
    .result-layout {
        display: flex;
        flex-direction: row;
        height: calc(100vh - 140px);
        max-height: calc(100vh - 140px);
    }

    .info-sidebar {
        width: 380px;
        flex-shrink: 0;
        padding: 28px 24px;
        height: 100%;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }

    .sidebar-footer {
        margin-top: auto;
        padding-top: 24px;
    }
}

/* Tabletas y pantallas medianas (< 1024px) */
@media (max-width: 1023px) {
    .main-container {
        padding: 0;
        min-height: 0;
        align-items: flex-start;
    }

    .result-layout {
        border-radius: 0;
        display: flex;
        flex-direction: column;
        height: auto;
    }

    .info-sidebar {
        order: 1;
        width: 100%;
        padding: 20px 16px;
        border-left: none;
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
    }

    .pdf-pane {
        order: 2;
        width: 100%;
        height: 65vh;
        min-height: 450px;
        flex: none;
    }

    .sidebar-footer {
        margin-top: 20px;
    }
}

/* MГіviles (< 768px) */
@media (max-width: 768px) {
    .top-nav-bar {
        padding: 10px 16px;
        min-height: 60px;
    }

    .header-container {
        flex-wrap: wrap;
        gap: 12px;
    }

    .brand-logo img {
        height: 38px;
    }

    .header-badge {
        font-size: 11px;
        padding: 4px 8px;
        white-space: normal;
    }

    /* Espaciado para despegar la tarjeta de la cabecera en mГіvil */
    .main-container {
        padding-top: 20px;
        height: auto !important;
        min-height: calc(100vh - 60px - 42px) !important;
    }

    #search-section {
        margin-top: 10px;
    }

    /* Liberar restricciones fijas de altura en el visor PDF mГіvil */
    .pdf-pane {
        height: auto;
        min-height: auto;
    }

    .footer-content {
        justify-content: center;
        text-align: center;
    }
}

/* Dispositivos intermedios y tablets (entre 769px y 1024px / iPads) */
@media (max-width: 1024px) {
    .main-container {
        padding-top: 24px !important;
    }

    #search-section {
        margin-top: 16px;
    }

    .pdf-pane {
        height: auto;
        min-height: auto;
    }
}
