/* Tribuno 1.1.80
   Ajustes globales de tipografía, navegación, módulos, documentos, SMTP y autenticación.
   Esta hoja se carga después de los estilos existentes para evitar reemplazos destructivos.
*/

/* --------------------------------------------------------------------------
   1) Tipografía global consistente
   -------------------------------------------------------------------------- */
:root {
    --tribuno-font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

html,
body,
input,
select,
textarea,
button,
optgroup,
option,
table,
.tooltip,
.modal {
    font-family: var(--tribuno-font) !important;
}

input,
select,
textarea,
button {
    font: inherit;
    letter-spacing: inherit;
}

input::placeholder,
textarea::placeholder {
    font-family: var(--tribuno-font) !important;
}

/* --------------------------------------------------------------------------
   2) Sidebar: un único lenguaje visual para el partial global
   -------------------------------------------------------------------------- */
.sidebar .nav-submenu {
    padding-left: 0 !important;
}

.sidebar .nav-submenu::before,
.sidebar .nav-submenu .nav-subitem::before,
.sidebar .nav-submenu .nav-subitem::after {
    content: none !important;
    display: none !important;
}

.sidebar .nav-submenu .nav-subitem {
    position: relative !important;
    display: flex !important;
    align-items: center !important;
    width: auto !important;
    min-height: 36px !important;
    margin: 2px .55rem 2px 2.75rem !important;
    padding: .5rem .72rem !important;
    border: 0 !important;
    border-radius: 8px !important;
    background: transparent !important;
    box-shadow: none !important;
    color: #9eb1c3 !important;
    font-size: .82rem !important;
    font-weight: 500 !important;
    line-height: 1.25 !important;
    text-decoration: none !important;
    transform: none !important;
    cursor: pointer !important;
    pointer-events: auto !important;
    isolation: isolate;
}

.sidebar .nav-submenu .nav-subitem:hover {
    background: rgba(255, 255, 255, .055) !important;
    color: #f7fbfd !important;
    transform: none !important;
}

.sidebar .nav-submenu .nav-subitem.active {
    background: rgba(14, 165, 183, .14) !important;
    color: #fff !important;
    box-shadow: inset 2px 0 0 var(--fp-teal, #0ea5b7) !important;
}

.sidebar .nav-submenu .nav-subitem-label {
    position: relative;
    z-index: 1;
    display: block !important;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    color: inherit !important;
    font: inherit !important;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
}

.sidebar .nav-group-toggle,
.sidebar .nav-group-toggle * {
    pointer-events: auto;
}

/* --------------------------------------------------------------------------
   3) Recuperación de contraseña
   -------------------------------------------------------------------------- */
.auth-wrapper {
    max-width: 460px;
}

.auth-card {
    border-radius: 18px;
}

.auth-recovery-form,
.auth-recovery-success {
    padding: 2rem;
}

.auth-recovery-form .auth-form-heading {
    margin-bottom: 1.55rem;
}

.auth-recovery-form .auth-form-heading > .material-symbols-rounded,
.auth-success-icon {
    background: linear-gradient(135deg, rgba(14, 165, 183, .13), rgba(37, 99, 235, .1));
    color: var(--fp-teal, #0ea5b7);
}

.auth-recovery-form .form-group {
    margin-bottom: 1.15rem;
}

.auth-recovery-form label {
    display: block;
    margin-bottom: .48rem;
    color: #334155;
    font-size: .83rem;
    font-weight: 650;
}

.auth-recovery-form .auth-input-wrap {
    min-height: 50px;
    border-radius: 12px;
    background: #fff;
}

.auth-recovery-form .auth-input-wrap:focus-within {
    border-color: var(--fp-teal, #0ea5b7);
    box-shadow: 0 0 0 4px rgba(14, 165, 183, .12);
}

.auth-recovery-success {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: center;
}

.auth-success-icon {
    width: 66px;
    height: 66px;
    margin: 0 auto 1rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 18px;
}

.auth-success-icon .material-symbols-rounded {
    font-size: 34px;
}

.auth-recovery-copy h2 {
    margin: 0 0 .55rem;
    color: #172033;
    font-size: 1.25rem;
}

.auth-recovery-copy p {
    margin: 0 0 1.35rem;
    color: #64748b;
    font-size: .9rem;
    line-height: 1.65;
}

.auth-recovery-expired .auth-success-icon {
    background: #fff3e8;
    color: #d97706;
}

/* --------------------------------------------------------------------------
   4) Marketplace de módulos
   -------------------------------------------------------------------------- */
.module-market-summary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.module-summary-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-height: 104px;
    padding: 1.1rem 1.2rem;
    border: 1px solid #e2e8f0;
    border-radius: 15px;
    background: #fff;
    box-shadow: 0 6px 20px rgba(15, 23, 42, .045);
}

.module-summary-card-total {
    background: linear-gradient(135deg, #f8fdfe, #f7faff);
    border-color: rgba(14, 165, 183, .22);
}

.module-summary-icon {
    width: 48px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 48px;
    border-radius: 13px;
    background: rgba(14, 165, 183, .1);
    color: var(--fp-teal, #0ea5b7);
}

.module-summary-card > div {
    display: flex;
    flex-direction: column;
    gap: .08rem;
}

.module-summary-label,
.module-summary-card small {
    color: #64748b;
    font-size: .76rem;
}

.module-summary-card strong {
    color: #172033;
    font-size: 1.45rem;
    line-height: 1.15;
}

.module-market-intro {
    display: flex;
    align-items: flex-start;
    gap: .72rem;
    margin-bottom: 1.6rem;
    padding: .9rem 1rem;
    border: 1px solid rgba(14, 165, 183, .18);
    border-radius: 12px;
    background: rgba(14, 165, 183, .055);
    color: #395266;
}

.module-market-intro > span {
    color: var(--fp-teal, #0ea5b7);
}

.module-market-intro p {
    margin: 0;
    font-size: .86rem;
    line-height: 1.55;
}

.module-market-group {
    margin-top: 1.8rem;
}

.module-market-group-heading {
    margin-bottom: .8rem;
}

.module-market-group-kicker {
    display: block;
    margin-bottom: .12rem;
    color: var(--fp-teal, #0ea5b7);
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
}

.module-market-group-heading h2 {
    margin: 0;
    color: #172033;
    font-size: 1.05rem;
}

.module-market-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
}

.module-market-card {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100%;
    padding: 1.15rem;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 7px 24px rgba(15, 23, 42, .045);
    transition: transform .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.module-market-card:hover {
    transform: translateY(-2px);
    border-color: #cbd5e1;
    box-shadow: 0 12px 28px rgba(15, 23, 42, .075);
}

.module-market-card.is-active {
    border-color: rgba(14, 165, 183, .28);
}

.module-market-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .9rem;
}

.module-market-icon {
    width: 42px;
    height: 42px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: #f1f5f9;
    color: #52647a;
}

.module-market-card.is-active .module-market-icon {
    background: rgba(14, 165, 183, .1);
    color: var(--fp-teal, #0ea5b7);
}

.module-status {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: .25rem .55rem;
    border-radius: 999px;
    background: #f1f5f9;
    color: #64748b;
    font-size: .7rem;
    font-weight: 700;
}

.module-status.active {
    background: #e8f8f5;
    color: #15836f;
}

.module-market-card-copy {
    min-height: 88px;
}

.module-market-card-copy h3 {
    margin: 0 0 .45rem;
    color: #172033;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.module-market-card-copy p {
    display: -webkit-box;
    margin: 0;
    overflow: hidden;
    color: #64748b;
    font-size: .82rem;
    line-height: 1.55;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 3;
}

.module-feature-list {
    display: flex;
    flex-direction: column;
    gap: .45rem;
    margin: .9rem 0 1rem;
    padding: .85rem 0 0;
    border-top: 1px solid #eef2f7;
    list-style: none;
}

.module-feature-list li {
    display: flex;
    align-items: flex-start;
    gap: .42rem;
    color: #475569;
    font-size: .76rem;
    line-height: 1.4;
}

.module-feature-list .material-symbols-rounded {
    margin-top: .02rem;
    color: #1aa889;
    font-size: 16px;
}

.module-market-card-footer {
    display: flex;
    flex-direction: column;
    gap: .72rem;
    margin-top: auto;
    padding-top: .85rem;
}

.module-price-block {
    display: flex;
    align-items: baseline;
    gap: .35rem;
}

.module-price-block strong {
    color: #172033;
    font-size: 1.25rem;
    line-height: 1;
}

.module-price-block span {
    color: #64748b;
    font-size: .76rem;
}

.module-proration-pill {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    padding: .28rem .55rem;
    border-radius: 999px;
    background: #eef8ff;
    color: #27658e;
    font-size: .68rem;
    font-weight: 650;
    line-height: 1.25;
}

.module-proration-neutral {
    background: #f3f5f8;
    color: #64748b;
}

.module-market-card-footer > .btn,
.module-market-card-footer > a.btn {
    width: 100%;
    justify-content: center;
}

.module-gateway-panel {
    margin-top: .25rem;
    padding: .85rem;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
}

.module-gateway-panel h4 {
    margin: 0 0 .75rem;
    color: #334155;
    font-size: .82rem;
}

.module-webhook {
    margin: 0 0 .75rem;
    color: #64748b;
    font-size: .72rem;
}

.module-webhook code {
    display: block;
    margin-top: .3rem;
    padding: .45rem;
    overflow-wrap: anywhere;
    border-radius: 7px;
    background: #fff;
    color: #475569;
}

/* --------------------------------------------------------------------------
   5) Documentos: filtros horizontales y fecha/hora
   -------------------------------------------------------------------------- */
.documents-toolbar {
    align-items: flex-end;
}

.document-filters {
    display: flex !important;
    flex: 1 1 760px;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: .7rem !important;
}

.document-filters .filter-field {
    flex: 1 1 135px;
    min-width: 125px;
}

.document-filters .filter-search {
    flex: 2 1 250px;
    min-width: 220px;
}

.document-filters .filter-submit {
    flex: 0 0 auto;
    min-height: 40px;
    align-self: flex-end;
}

.document-date-stack {
    display: inline-flex;
    flex-direction: column;
    gap: .12rem;
    line-height: 1.15;
    white-space: nowrap;
}

.document-date-stack strong {
    color: inherit;
    font-size: .86rem;
    font-weight: 600;
}

.document-date-stack small,
.document-emission-time {
    display: block;
    color: #7b8a9b;
    font-size: .72rem;
    font-weight: 500;
}

/* --------------------------------------------------------------------------
   6) Módulo requerido desde un documento
   -------------------------------------------------------------------------- */
.module-required-modal-card {
    max-width: 440px;
    padding-top: 1.25rem;
    text-align: center;
}

.module-required-icon {
    width: 58px;
    height: 58px;
    margin: 0 auto .6rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(14, 165, 183, .13), rgba(37, 99, 235, .1));
    color: var(--fp-teal, #0ea5b7);
}

.module-required-icon .material-symbols-rounded {
    font-size: 31px;
}

.module-required-modal-card .modal-header {
    justify-content: center;
    position: relative;
}

.module-required-modal-card .modal-close {
    position: absolute;
    right: 0;
    top: -.25rem;
}

.module-required-modal-card > p {
    margin: .6rem auto 1.2rem;
    max-width: 340px;
    color: #64748b;
    font-size: .9rem;
    line-height: 1.55;
}

.module-required-actions {
    display: flex;
    justify-content: center;
    gap: .65rem;
    flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   7) Toasts siempre abajo a la derecha
   -------------------------------------------------------------------------- */
.toast-container {
    top: auto !important;
    right: 1rem !important;
    bottom: 1rem !important;
    left: auto !important;
}

/* --------------------------------------------------------------------------
   8) Prueba SMTP antes de guardar
   -------------------------------------------------------------------------- */
.smtp-test-panel {
    margin-top: .25rem;
    padding: 1rem;
    border: 1px solid #dbe4ed;
    border-radius: 13px;
    background: #f8fafc;
}

.smtp-test-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: .85rem;
}

.smtp-test-heading > div {
    display: flex;
    flex-direction: column;
    gap: .2rem;
}

.smtp-test-heading strong {
    color: #273449;
    font-size: .9rem;
}

.smtp-test-heading small,
.smtp-save-hint {
    color: #6b7c8f;
    font-size: .76rem;
    line-height: 1.45;
}

.smtp-verification-badge {
    display: inline-flex;
    align-items: center;
    min-height: 25px;
    padding: .28rem .58rem;
    border-radius: 999px;
    background: #eef2f6;
    color: #64748b;
    font-size: .69rem;
    font-weight: 700;
    white-space: nowrap;
}

.smtp-verification-badge.testing {
    background: #eef7ff;
    color: #2d6d9b;
}

.smtp-verification-badge.verified {
    background: #e8f8f1;
    color: #16765e;
}

.smtp-verification-badge.error {
    background: #fff0ef;
    color: #b7473d;
}

.smtp-test-actions {
    display: flex;
    align-items: center;
    gap: .7rem;
}

.smtp-test-note {
    flex: 1 1 auto;
    min-width: 220px;
    color: #526a7f;
    font-size: .88rem;
}

.smtp-test-actions .form-control {
    flex: 1 1 auto;
}

.smtp-test-actions .btn {
    flex: 0 0 auto;
    white-space: nowrap;
}

.smtp-test-status {
    display: flex;
    align-items: flex-start;
    gap: .42rem;
    min-height: 0;
    margin-top: .7rem;
    font-size: .78rem;
    line-height: 1.45;
}

.smtp-test-status:empty {
    display: none;
}

.smtp-test-status .material-symbols-rounded {
    margin-top: .02rem;
    font-size: 17px;
}

.smtp-test-status.success { color: #16765e; }
.smtp-test-status.error { color: #b7473d; }
.smtp-test-status.info { color: #526a7f; }

.smtp-save-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding-top: .25rem;
}

#btnSaveSmtp:disabled {
    opacity: .5;
    cursor: not-allowed;
    box-shadow: none;
}

@media (max-width: 1100px) {
    .module-market-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .module-market-summary,
    .module-market-grid {
        grid-template-columns: 1fr;
    }

    .document-filters {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .document-filters .filter-field,
    .document-filters .filter-search {
        min-width: 0;
    }

    .document-filters .filter-search,
    .document-filters .filter-submit {
        grid-column: 1 / -1;
    }

    .smtp-test-actions,
    .smtp-save-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .smtp-test-actions .btn,
    .smtp-save-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .document-filters {
        grid-template-columns: 1fr;
    }

    .document-filters .filter-search,
    .document-filters .filter-submit {
        grid-column: auto;
    }

    .auth-recovery-form,
    .auth-recovery-success {
        padding: 1.5rem;
    }
}

.fp-sii-icon.updated {
    background: #eef7ff;
    color: #2f78a8;
}
