/* ════════════════════════════════════════════════════════
   Portal Banco de Materiales 2026 — MINVU
   Tokens de diseño del kit digital framework.digital.gob.cl
════════════════════════════════════════════════════════ */

:root {
    --azul:        #00568c;
    --azul-medio:  #006fb3;
    --rojo:        #b6152e;
    --bg:          #f2f6fb;
    --surface:     #ffffff;
    --text:        #181c20;
    --text-sec:    #404750;
    --border:      #dee2e6;
    --success:     #1a7a3c;
    --warning:     #9a6700;
    --amber:       #d97706;
    --header-h:    64px;
    --sidebar-w:   256px;
    --base-font-size: 15px;
}

/* ── Reset base ── */
*, *::before, *::after { box-sizing: border-box; }

html { font-size: var(--base-font-size); }

body {
    font-family: 'Roboto', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding-top: var(--header-h);
}

/* ════════════════════
   HEADER STICKY
════════════════════ */
.portal-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--header-h);
    background-color: var(--azul);
    display: flex;
    align-items: center;
    z-index: 1030;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
    padding: 0 1.25rem;
    gap: 1rem;
}

.portal-header__brand {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
}

.portal-header__stripe {
    width: 8px;
    height: 40px;
    border-radius: 3px;
    margin-right: 3px;
}
.portal-header__stripe--rojo { background-color: var(--rojo); }
.portal-header__stripe--azul { background-color: var(--azul-medio); margin-right: 12px; }

.portal-header__logotipo {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.portal-header__gobierno {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: #ffffff;
}

.portal-header__ministerio {
    font-size: 0.72rem;
    color: rgba(255,255,255,.75);
}

.portal-header__nav {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    justify-content: center;
}

.portal-header__nav-link {
    color: rgba(255,255,255,.85);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 0.875rem;
    border-radius: 4px;
    border-bottom: 2px solid transparent;
    transition: color .15s, background .15s;
    cursor: pointer;
}
.portal-header__nav-link:hover { color: #fff; background: rgba(255,255,255,.1); }
.portal-header__nav-link.active { color: #fff; border-bottom-color: #fff; }
.portal-header__nav-link.disabled { opacity: .45; cursor: not-allowed; }

.portal-header__actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
    flex-shrink: 0;
}

/* ── Campana ── */
.portal-notif-btn__icon {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px; height: 36px;
    border-radius: 50%;
    color: rgba(255,255,255,.85);
    text-decoration: none;
    transition: background .15s;
}
.portal-notif-btn__icon:hover { background: rgba(255,255,255,.15); color: #fff; }

.portal-notif-btn__badge {
    position: absolute;
    top: -2px; right: -2px;
    background: var(--rojo);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
    border: 2px solid var(--azul);
}

/* ── Chip usuario ── */
.portal-user-chip {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.portal-user-chip__avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--azul-medio);
    border: 2px solid rgba(255,255,255,.4);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; color: #fff;
    flex-shrink: 0;
}

.portal-user-chip__info {
    flex-direction: column;
    line-height: 1.2;
}
.portal-user-chip__name { font-size: 0.8rem; color: #fff; font-weight: 500; }
.portal-user-chip__clave {
    font-size: 0.68rem;
    color: #6ee7b7;
    display: flex; align-items: center; gap: 4px;
}

/* ── Animaciones ── */
.portal-badge-pulse, .portal-pulse {
    animation: pulse-ring 1.5s infinite;
}

.portal-clave-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #34d399;
    display: inline-block;
}

@keyframes pulse-ring {
    0%   { box-shadow: 0 0 0 0 rgba(182,21,46,.7); }
    70%  { box-shadow: 0 0 0 6px rgba(182,21,46,0); }
    100% { box-shadow: 0 0 0 0 rgba(182,21,46,0); }
}

/* ════════════════════
   LAYOUT
════════════════════ */
.portal-layout {
    display: flex;
    min-height: calc(100vh - var(--header-h));
}

/* ════════════════════
   SIDEBAR
════════════════════ */
.portal-sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--surface);
    border-right: 1px solid var(--border);
    flex-direction: column;
    position: sticky;
    top: var(--header-h);
    height: calc(100vh - var(--header-h));
    overflow-y: auto;
}

.portal-sidebar__header {
    padding: 1.25rem 1rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.portal-sidebar__title {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--azul);
}

.portal-sidebar__subtitle {
    font-size: 0.72rem;
    color: var(--text-sec);
    margin-top: 2px;
}

.portal-sidebar__nav {
    padding: 0.5rem 0;
}

.portal-sidebar__item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1rem;
    color: var(--text-sec);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-left: 4px solid transparent;
    transition: background .15s, color .15s, border-color .15s;
    position: relative;
}
.portal-sidebar__item:hover {
    background: #f0f6ff;
    color: var(--azul-medio);
}
.portal-sidebar__item.active {
    border-left-color: var(--azul);
    background: #e8f1fb;
    color: var(--azul);
}

.portal-sidebar__icon {
    width: 18px; height: 18px;
    flex-shrink: 0;
    stroke: currentColor;
}

.portal-sidebar__badge {
    margin-left: auto;
    background: var(--rojo);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 18px; height: 18px;
    border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px;
}

/* ════════════════════
   ÁREA PRINCIPAL
════════════════════ */
.portal-main {
    flex: 1;
    min-width: 0;
    padding: 1.5rem;
}

.portal-main__inner {
    max-width: 960px;
    margin: 0 auto;
}

/* ── Breadcrumb ── */
.portal-breadcrumb {
    margin-bottom: 1rem;
}
.breadcrumb { font-size: 0.8rem; }
.breadcrumb-item a { color: var(--azul-medio); text-decoration: none; }
.breadcrumb-item a:hover { text-decoration: underline; }

/* ── Alert global ── */
.portal-alert-global {
    background: #fff8e6;
    border-color: #f3cc6a;
    color: var(--warning);
    font-size: 0.875rem;
}

/* ════════════════════
   TARJETAS
════════════════════ */
.portal-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.portal-card--borrador  { border-top: 4px solid #9ca3af; }
.portal-card--revision  { border-top: 4px solid var(--amber); }
.portal-card--aprobada  { border-top: 4px solid var(--success); }

/* ── Badges de estado ── */
.portal-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    text-transform: uppercase;
    letter-spacing: .4px;
}
.portal-badge--borrador { background: #f3f4f6; color: #374151; }
.portal-badge--revision { background: #fef3c7; color: #92400e; }
.portal-badge--aprobada { background: #d1fae5; color: #065f46; }
.portal-badge--pendiente { background: #fef3c7; color: #92400e; }
.portal-badge--en-revision { background: #dbeafe; color: #1e40af; }
.portal-badge--aprobado { background: #d1fae5; color: #065f46; }
.portal-badge--abierto { background: #d1fae5; color: #065f46; }
.portal-badge--cierre { background: #fef3c7; color: #92400e; }
.portal-badge--cerrado { background: #f3f4f6; color: #374151; }

/* ════════════════════
   TIMELINE TRACKER
════════════════════ */
.portal-timeline {
    display: flex;
    align-items: center;
    gap: 0;
    margin-top: 1rem;
}

.portal-timeline__step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
}

.portal-timeline__step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 14px;
    left: 50%;
    right: -50%;
    height: 2px;
    background: var(--border);
    z-index: 0;
}
.portal-timeline__step.done:not(:last-child)::after { background: var(--success); }
.portal-timeline__step.active:not(:last-child)::after { background: var(--border); }

.portal-timeline__circle {
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    position: relative;
    z-index: 1;
    border: 2px solid var(--border);
    background: #fff;
    color: var(--text-sec);
}
.portal-timeline__step.done .portal-timeline__circle {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
}
.portal-timeline__step.active .portal-timeline__circle {
    background: var(--azul);
    border-color: var(--azul);
    color: #fff;
}

.portal-timeline__label {
    font-size: 0.65rem;
    color: var(--text-sec);
    margin-top: 4px;
    text-align: center;
    line-height: 1.2;
}
.portal-timeline__step.active .portal-timeline__label { color: var(--azul); font-weight: 600; }
.portal-timeline__step.done .portal-timeline__label { color: var(--success); }

/* ════════════════════
   FORMULARIO
════════════════════ */
.portal-form-section {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}

.portal-form-section__header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.portal-form-section__header h3 {
    font-family: 'Roboto Slab', serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--azul);
    margin: 0;
}

.portal-form-section__num {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--azul);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}

/* Input con prefijo telefónico */
.portal-tel-prefix {
    background: #f0f6ff;
    border: 1px solid var(--border);
    border-right: none;
    padding: 0.375rem 0.75rem;
    color: var(--text-sec);
    font-weight: 500;
    border-radius: 4px 0 0 4px;
    font-size: 0.875rem;
}

/* Calculadora UF */
.portal-uf-display {
    background: linear-gradient(135deg, var(--azul) 0%, var(--azul-medio) 100%);
    border-radius: 8px;
    padding: 1.5rem;
    text-align: center;
    color: #fff;
}
.portal-uf-display__amount {
    font-family: 'Roboto Slab', serif;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}
.portal-uf-display__label {
    font-size: 0.8rem;
    opacity: .8;
    margin-top: 4px;
}

/* Tarjetas de tipo obra (radio cards) */
.portal-obra-card {
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: border-color .15s, background .15s;
    text-align: center;
}
.portal-obra-card:hover { border-color: var(--azul-medio); background: #f0f6ff; }
.portal-obra-card.selected { border-color: var(--azul); background: #e8f1fb; }
.portal-obra-card__icon { font-size: 1.75rem; margin-bottom: 0.5rem; }
.portal-obra-card__title { font-weight: 700; font-size: 0.875rem; color: var(--text); }
.portal-obra-card__desc { font-size: 0.75rem; color: var(--text-sec); margin-top: 0.25rem; }

/* Declaración Jurada */
.portal-declaracion {
    background: #f8f9fa;
    border: 1px solid var(--border);
    border-left: 4px solid var(--azul);
    border-radius: 4px;
    padding: 1rem 1.25rem;
    font-size: 0.82rem;
    color: var(--text-sec);
    line-height: 1.6;
}

/* Validación cédula */
.portal-cedula-status {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 0;
    min-height: 24px;
}
.portal-cedula-status--validando { color: var(--warning); }
.portal-cedula-status--valid { color: var(--success); }
.portal-cedula-status--error { color: var(--rojo); }

/* ════════════════════
   FILTROS (tabs)
════════════════════ */
.portal-filter-tabs {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.25rem;
}
.portal-filter-tab {
    padding: 0.5rem 1.25rem;
    border: none;
    background: none;
    color: var(--text-sec);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}
.portal-filter-tab:hover { color: var(--azul-medio); }
.portal-filter-tab.active { color: var(--azul); border-bottom-color: var(--azul); }

/* ════════════════════
   TOAST
════════════════════ */
.portal-toast {
    min-width: 280px;
    border-radius: 8px;
    font-size: 0.875rem;
}
.portal-toast--success { background: #d1fae5; border-color: #a7f3d0; color: #065f46; }
.portal-toast--error   { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.portal-toast--info    { background: #dbeafe; border-color: #bfdbfe; color: #1e40af; }

/* ════════════════════
   ACCESIBILIDAD
════════════════════ */
html.high-contrast {
    --bg: #000;
    --surface: #000;
    --text: #fff;
    --text-sec: #e5e5e5;
    --border: #fff;
    filter: contrast(1.2);
}
html.high-contrast .portal-sidebar,
html.high-contrast .portal-header,
html.high-contrast .portal-card,
html.high-contrast .portal-form-section {
    border: 2px solid #fff !important;
}

html.text-chico  { font-size: 13px; }
html.text-normal { font-size: 15px; }
html.text-grande { font-size: 18px; }
html.text-enorme { font-size: 21px; }

/* ════════════════════
   BUSCADOR FONDOS
════════════════════ */
.portal-fondo-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow .15s;
}
.portal-fondo-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,.1); }

.portal-fondo-card__header {
    padding: 1.25rem;
    border-bottom: 1px solid var(--border);
}
.portal-fondo-card__body { padding: 1.25rem; }
.portal-fondo-card__footer {
    padding: 1rem 1.25rem;
    background: #f8f9fa;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.portal-fondo-card__monto {
    font-family: 'Roboto Slab', serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--azul);
}

.portal-req-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.portal-req-list li {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.82rem;
    color: var(--text-sec);
    padding: 0.2rem 0;
}
.portal-req-list li::before {
    content: '✓';
    color: var(--success);
    font-weight: 700;
    flex-shrink: 0;
    margin-top: 1px;
}

/* ════════════════════
   DOCUMENTOS
════════════════════ */
.portal-doc-table th {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-sec);
    background: #f8f9fa;
}
.portal-doc-table td { font-size: 0.875rem; vertical-align: middle; }

/* ════════════════════
   MODAL CONFIRMACIÓN
════════════════════ */
.portal-modal .modal-header {
    background: var(--azul);
    color: #fff;
    border-radius: 8px 8px 0 0;
}
.portal-modal .modal-header .btn-close { filter: invert(1); }
.portal-modal .btn-confirmar {
    background: var(--azul);
    border-color: var(--azul);
    color: #fff;
}
.portal-modal .btn-confirmar:hover {
    background: var(--azul-medio);
    border-color: var(--azul-medio);
}

/* ════════════════════
   CONFIGURACIÓN
════════════════════ */
.portal-config-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1rem;
}
.portal-config-card__title {
    font-family: 'Roboto Slab', serif;
    font-weight: 700;
    color: var(--azul);
    font-size: 1rem;
    margin-bottom: 0.25rem;
}

.portal-text-size-btn {
    padding: 0.4rem 1rem;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 4px;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-sec);
    transition: background .15s, border-color .15s, color .15s;
}
.portal-text-size-btn:hover { border-color: var(--azul-medio); color: var(--azul); }
.portal-text-size-btn.active {
    background: var(--azul);
    border-color: var(--azul);
    color: #fff;
}

/* ════════════════════
   UTILIDADES
════════════════════ */
.portal-section-title {
    font-family: 'Roboto Slab', serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--azul);
    margin-bottom: 0.25rem;
}

.portal-btn-primary {
    background: var(--azul);
    border-color: var(--azul);
    color: #fff;
    font-weight: 600;
}
.portal-btn-primary:hover {
    background: var(--azul-medio);
    border-color: var(--azul-medio);
    color: #fff;
}

.portal-btn-outline {
    border-color: var(--azul);
    color: var(--azul);
    font-weight: 600;
}
.portal-btn-outline:hover {
    background: #e8f1fb;
    border-color: var(--azul);
    color: var(--azul);
}

/* Candado RSH */
.portal-rsh-lock {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-sec);
    background: #f0f6ff;
    border: 1px solid #c7dbf4;
    border-radius: 4px;
    padding: 0.5rem 0.75rem;
    margin-bottom: 1rem;
}

/* Ahorro badge */
.portal-ahorro-ok   { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; border-radius: 6px; padding: 0.5rem 1rem; font-weight: 600; }
.portal-ahorro-warn { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; border-radius: 6px; padding: 0.5rem 1rem; font-weight: 600; }

/* Resumen de montos — Sección 7 */
.portal-monto-resumen {
    background: var(--fondo-sec, #f8fafc);
    border: 1px solid var(--borde, #e5e7eb);
    border-radius: 8px;
    padding: 1.25rem 1.5rem;
    text-align: center;
    height: 100%;
}
.portal-monto-resumen--total {
    background: linear-gradient(135deg, var(--azul) 0%, var(--azul-medio) 100%);
    border-color: transparent;
    color: #fff;
}
.portal-monto-resumen__label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
    opacity: .7;
    margin-bottom: 0.5rem;
}
.portal-monto-resumen--total .portal-monto-resumen__label {
    opacity: .85;
    color: #fff;
}
.portal-monto-resumen__value {
    font-family: 'Roboto Slab', serif;
    font-size: 1.8rem;
    font-weight: 700;
    line-height: 1;
    color: var(--azul);
}
.portal-monto-resumen--total .portal-monto-resumen__value {
    color: #fff;
    font-size: 2rem;
}

/* Upload zone */
.portal-upload-zone {
    border: 2px dashed var(--border);
    border-radius: 6px;
    padding: 1rem;
    text-align: center;
    transition: border-color .15s, background .15s;
    cursor: pointer;
}
.portal-upload-zone:hover { border-color: var(--azul-medio); background: #f0f6ff; }
.portal-upload-zone.uploaded { border-color: var(--success); background: #f0fdf4; }


.login-card {
    background-color: #ffffff;
}

.login-accent-bar {
    height: 6px;
}

.login-accent-bar__red {
    flex: 1;
    background-color: #b6152e;
}

.login-accent-bar__blue {
    flex: 2;
    background-color: #00568c;
}

.login-logo {
    max-height: 80px;
}

.login-title {
    font-family: 'Roboto Slab', serif;
    color: #00568c;
    font-size: 1.5rem;
}

.login-claveunica-btn {
    max-width: 220px;
}

.hover-scale {
    transition: transform 0.2s ease-in-out;
}

    .hover-scale:hover {
        transform: scale(1.03);
    }

.tracking-wider {
    letter-spacing: 0.05em;
}