/* ══════════════════════════════════════════════════════════════════
   PORTAL CORPORATIVO — Login
   Referencia: Figma node 920:1997
   ══════════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:opsz,wght@9..40,400;9..40,500;9..40,600;9..40,700;9..40,800&display=swap');

:root {
    --teal:           #0EA5A3;
    --teal-dim:       #0b8785;
    --teal-border:    rgba(14, 165, 163, 0.24);
    --teal-hover:     rgba(14, 165, 163, 0.07);

    --bg-page:        #fbfcff;
    --bg-left:        #ffffff;
    --bg-right-outer: #ffffff;
    --bg-right-inner: #d9eced;

    --border-subtle:  #e2e8f0;

    --text-primary:   #000000;
    --text-body:      #374151;
    --text-muted:     #6b7280;
    --text-dim:       #9ca3af;

    --danger:         #dc2626;
    --danger-bg:      rgba(220, 38, 38, 0.07);
    --success:        #16a34a;
    --success-bg:     rgba(22, 163, 74, 0.07);
    --warn:           #d97706;
    --warn-bg:        rgba(217, 119, 6, 0.07);

    --radius-box:     20px;
    --radius-pill:    100px;
    --shadow-box:     0px 1px 1px rgba(0,0,0,0.06),
                      0px 1px 1.5px rgba(0,0,0,0.10);
    --shadow-qr:      0 4px 20px rgba(0,0,0,0.10),
                      0 0 0 1.5px rgba(14,165,163,0.18);
    --font:           'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }

/* ── Reset — pisa site.css ──────────────────────── */
html, body {
    margin: 0 !important;
    padding: 0 !important;
    background-color: var(--bg-page) !important;
    min-height: 100vh;
    font-family: var(--font);
}

/* ── Centrado de página ─────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-page);
    padding: 32px 20px;
}

/* ── Caja principal ─────────────────────────────── */
.login-box {
    display: flex;
    width: 100%;
    max-width: 1232px;
    /* 763px de Figma, limitado a la altura visible (laptops 1366x768) */
    min-height: min(763px, calc(100vh - 64px));
    border-radius: var(--radius-box);
    overflow: hidden;
    box-shadow: var(--shadow-box);
    position: relative;
    background: #fff;
}

/* ── Panel izquierdo ─────────────────────────────── */
.login-panel-left {
    flex: 1;
    background: var(--bg-left);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 36px 60px 28px;
    position: relative;
    overflow-y: auto;
    min-width: 0;
}

/* ── Panel derecho ──────────────────────────────── */
.login-panel-right {
    flex: 1;
    background: var(--bg-right-outer);
    padding: 12px;
    display: flex;
    align-items: stretch;
    min-width: 0;
}

.right-panel-inner {
    flex: 1;
    background: var(--bg-right-inner);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    padding: 10px;
    gap: 0;
}


/* marca de agua — patrón halftone en panel derecho */
.right-watermark {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 100%;
    background-size: cover;
    background-repeat: no-repeat;
    background-position: bottom center;
    mix-blend-mode: multiply;
    opacity: 0.1;
    pointer-events: none;
    z-index: 0;
}


.right-carousel-wrap {
    width: min(316px, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 1;
}

/* Owl Carousel — overrides */
.right-carousel {
    width: 100%;
}

.right-carousel .owl-stage-outer,
.right-carousel .owl-stage,
.right-carousel .owl-item {
    height: 323px;
}

.right-slide {
    display: flex !important;
    align-items: center;
    justify-content: center;
    height: 323px;
    width: 100%;
}

.carousel-slide-img {
    max-width: min(220px, 100%);
    max-height: 270px;
    object-fit: contain;
    opacity: 0.88;
    transition: opacity 0.3s ease;
}

/* Dots del carousel */
.right-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    margin-top: 12px;
}

.right-dots .dot {
    height: 4px;
    border-radius: 35px;
    background: rgba(255,255,255,0.9);
    opacity: 0.5;
    width: 20px;
    transition: width 0.3s ease, opacity 0.3s ease;
}

.right-dots .dot.active {
    width: 30px;
    opacity: 1;
}

/* ── Header ─────────────────────────────────────── */
.login-header {
    text-align: center;
    margin-bottom: 24px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.portal-label {
    display: block;
    font-family: var(--font);
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 1.76px;
    text-transform: uppercase;
    color: var(--teal);
    padding-top: 14px;
    margin-bottom: 0;
}

.login-header .brand-img {
    height: 53px;
    width: 129px;
    object-fit: contain;
}

/* ── Botón "Obtener aplicación" ─────────────────── */
.get-app-button {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border-subtle);
    background: #ffffff;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: var(--font);
    white-space: nowrap;
    box-shadow: var(--shadow-box);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.get-app-button svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--teal);
}

.get-app-button:hover {
    border-color: var(--teal);
    box-shadow: 0 4px 14px var(--teal-hover);
}

/* Estado "nueva versión disponible" — brillo + badge para llamar la atención */
.get-app-badge {
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 2px #ffffff;
}

.get-app-button.has-update {
    border-color: var(--teal);
    animation: get-app-pulse 1.8s ease-in-out infinite;
}

@keyframes get-app-pulse {
    0%, 100% { box-shadow: var(--shadow-box), 0 0 0 0 rgba(14, 165, 163, 0.45); }
    50%      { box-shadow: var(--shadow-box), 0 0 0 9px rgba(14, 165, 163, 0); }
}

/* Burbuja "nueva versión disponible" */
.get-app-tooltip {
    position: absolute;
    top: calc(100% + 12px);
    right: 0;
    max-width: 220px;
    white-space: nowrap;
    background: var(--teal);
    color: #ffffff;
    padding: 9px 14px;
    border-radius: 10px;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: var(--font);
    box-shadow: 0 8px 22px rgba(14, 165, 163, 0.35);
    animation: get-app-tooltip-in 0.35s cubic-bezier(.34, 1.56, .64, 1), get-app-tooltip-bounce 1.6s ease-in-out 0.35s 2;
}

.get-app-tooltip::after {
    content: '';
    position: absolute;
    top: -5px;
    right: 18px;
    width: 10px;
    height: 10px;
    background: var(--teal);
    transform: rotate(45deg);
}

@keyframes get-app-tooltip-in {
    from { opacity: 0; transform: translateY(-8px) scale(0.9); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes get-app-tooltip-bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-4px); }
}

@media (max-width: 640px) {
    .get-app-tooltip {
        white-space: normal;
        right: -8px;
    }
}

@media (max-width: 640px) {
    .get-app-button span {
        display: none;
    }
    .get-app-button {
        padding: 10px;
        border-radius: 50%;
    }
}

/* ── Modal descarga de app ──────────────────────── */
.app-qr-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 10, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 24px;
    animation: app-qr-fade-in 0.15s ease;
}

.app-qr-backdrop[hidden] {
    display: none;
}

@keyframes app-qr-fade-in {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.app-qr-modal {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    padding: 32px 28px;
    max-width: 340px;
    width: 100%;
    max-height: 100%;
    overflow-y: auto;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
}

.app-qr-modal h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px;
}

.app-qr-modal p {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: 0 0 20px;
    line-height: 1.5;
}

.app-qr-image {
    width: 220px;
    max-width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    border-radius: 12px;
}

.app-qr-update-msg {
    display: inline-block;
    margin: -4px 0 12px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    background: var(--teal-hover);
    color: var(--teal-dim);
    font-size: 0.8rem;
    font-weight: 700;
}

.app-qr-version {
    display: inline-block;
    margin: -12px 0 16px;
    color: var(--text-dim);
    font-size: 0.75rem;
    font-weight: 600;
}

.app-qr-hint {
    margin: 14px 0 0;
    color: var(--text-dim);
    font-size: 0.75rem;
    line-height: 1.4;
}

.app-qr-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: #f2f2f2;
    color: var(--text-primary);
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.app-qr-close:hover {
    background: #e5e5e5;
}

/* ── Flip card ──────────────────────────────────── */
.login-card-inner {
    width: 100%;
    flex: 1;
    position: relative;
    transform-style: preserve-3d;
    perspective: 1400px;
    transition: transform 0.85s cubic-bezier(0.4, 0.2, 0.2, 1);
}

.login-card-inner.flipped { transform: rotateY(180deg); }

.login-card-front,
.login-card-back {
    width: 100%;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    background: transparent;
    border: none;
    box-shadow: none;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-card-back {
    position: absolute;
    top: 0; left: 0;
    transform: rotateY(180deg);
}

/* ── Bloque QR ──────────────────────────────────── */
#bloqueQR {
    position: relative;
    width: 100%;
}

#bloqueQR h4 {
    font-family: var(--font);
    font-size: 22px;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

#bloqueQR p {
    font-family: var(--font);
    font-size: 16px;
    font-weight: 500;
    color: var(--text-primary);
    opacity: 0.5;
    line-height: 1.5;
    margin-bottom: 0;
    max-width: 430px;
    margin-left: auto;
    margin-right: auto;
}

.max-width {
    max-width: 100%;
    width: 100%;
}

/* ── Selector segmented ─────────────────────────── */
.segmented {
    display: inline-flex;
    padding: 3px;
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 8px;
    background: #f8fafc;
    gap: 2px;
    height: 38px;
    align-items: center;
}

.segmented .btn {
    border-radius: 6px !important;
    border: 1px solid transparent !important;
    background: transparent;
    color: #475569;
    font-family: var(--font);
    font-weight: 600;
    font-size: 14px;
    letter-spacing: 0.25px;
    padding: 4px 14px;
    line-height: 1.3;
    transition: all 0.18s ease;
    white-space: nowrap;
}

.segmented .btn:hover {
    background: var(--teal-hover);
    color: var(--text-body);
}

.btn-check:checked + .btn,
.segmented .btn.active {
    background: var(--teal) !important;
    color: #fff !important;
    border-color: transparent !important;
    box-shadow: 0 2px 8px rgba(14, 165, 163, 0.30) !important;
}

/* ── Contenedor QR ──────────────────────────────── */
/* block (antes inline-block): el ancho de #qrcode es porcentual y dentro de
   un inline-block vacío (mientras se genera el QR) colapsaba a 0. */
#qrBox {
    display: block;
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    box-shadow: none !important;
}

/* El canvas se genera a 260px (Login.js); en pantallas angostas se escala
   proporcionalmente para no desbordar el panel. */
#qrcode {
    width: min(260px, 100%);
    aspect-ratio: 1 / 1;
    margin: 0 auto;
}

#qrcode canvas,
#qrcode img {
    border-radius: 4px;
    display: block;
    width: 100%;
    height: auto;
}

/* ── Status bar ─────────────────────────────────── */
/* position+z-index por encima de .qr-loader (z-index:10) para que el mensaje
   ("QR expirado...", "Demasiadas consultas...", etc.) no quede lavado/ilegible
   debajo del backdrop-filter: blur() del overlay de regenerar QR. */
.qr-status-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 30px;
    position: relative;
    z-index: 20;
}

.qr-countdown {
    display: inline-block;
    min-width: 46px;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    background: #ebf7f7;
    color: var(--teal);
    border: 1px solid var(--teal);
    transition: background 0.35s, color 0.35s, border-color 0.35s;
    letter-spacing: 0.04em;
}

.qr-countdown.warn   { background: var(--warn-bg);   color: var(--warn);   border-color: rgba(217,119,6,0.28); }
.qr-countdown.danger { background: var(--danger-bg); color: var(--danger); border-color: rgba(220,38,38,0.28);
                        animation: pulse-danger 0.75s ease-in-out infinite; }
.qr-countdown:empty  { display: none; }

@keyframes pulse-danger {
    0%, 100% { opacity: 1; }
    50%       { opacity: 0.45; }
}

.qr-status-text                { font-family: var(--font); font-size: 14px; font-weight: 500; color: var(--text-primary); opacity: 0.5; transition: opacity 0.25s, color 0.25s; }
.qr-status-text.status-error   { color: var(--danger); font-weight: 600; opacity: 1; }
.qr-status-text.status-success { color: var(--success); font-weight: 600; opacity: 1; }
.qr-status-text:empty          { display: none; }

/* ── QR Loader overlay ──────────────────────────── */
.qr-loader {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(4px);
    z-index: 10;
    border-radius: 12px;
    padding-top: 38%;
}
.qr-loader.hidden { display: none; }

.qr-loader__spinner {
    width: 38px; height: 38px;
    border: 2.5px solid rgba(14,165,163,0.14);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
    margin-bottom: 10px;
}

.qr-loader__text {
    font-family: var(--font);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

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

.qr-loaderv2 { padding-top: 34% !important; }

.cursorPointer {
    cursor: pointer;
    color: var(--teal);
    transition: transform 0.25s, color 0.2s;
}
.cursorPointer:hover { transform: rotate(60deg); color: var(--teal-dim); }

/* ── Instrucción ────────────────────────────────── */
.qr-instruction {
    margin: 18px 0 0;
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    text-align: center;
    line-height: 1.6;
    width: 100%;
}

.qr-instruction strong { color: var(--text-primary); font-weight: 700; }

.qr-instruction .icon,
.icon {
    width: 17px;
    height: 17px;
    vertical-align: -3px;
    margin: 0 2px;
    opacity: 0.82;
}

/* ── Footer ─────────────────────────────────────── */
.login-box-footer {
    margin-top: auto;
    padding-top: 14px;
    border-top: 1px solid var(--border-subtle);
    width: 100%;
}

.footer-text {
    color: #7f7f7f !important;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    line-height: 1.6;
}

.footer-text a,
.copy-text,
.footer-link-sep {
    color: #7f7f7f !important;
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
}

.footer-text a       { color: #007d88 !important; text-decoration: none; white-space: nowrap; }
.footer-text a:hover { text-decoration: underline; }

/* ── Semáforo de estado ─────────────────────────── */
.svc-health {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: default;
    user-select: none;
}

.svc-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: var(--text-dim);
    flex-shrink: 0;
    transition: background 0.5s;
}

.svc-label {
    font-family: var(--font);
    font-size: 12px;
    font-weight: 500;
    color: var(--text-dim);
    transition: color 0.3s;
    white-space: nowrap;
}

.svc-health.ok .svc-dot          { background: #389e0d; }
.svc-health.ok .svc-label        { color: var(--teal); }
.svc-health.degraded .svc-dot    { background: #f59e0b; }
.svc-health.degraded .svc-label  { color: #92400e; }
.svc-health.down .svc-dot        { background: #ef4444; animation: pulse-svc 1.1s ease-in-out infinite; }
.svc-health.down .svc-label      { color: #b91c1c; font-weight: 600; }

@keyframes pulse-svc {
    0%, 100% { opacity: 1;   box-shadow: 0 0 0 0   rgba(239,68,68,0.45); }
    50%       { opacity: 0.65; box-shadow: 0 0 0 5px rgba(239,68,68,0); }
}

/* ── Misc heredado ───────────────────────────────── */
.password-check { display: flex; align-items: center; width: 100%; }
.password-check .form-control { flex: 1; padding-right: 40px; }
.input-suffix { cursor: pointer; margin-left: -30px; }
.input-suffix svg { vertical-align: middle; }
.toggle-link { margin-top: auto; font-size: 13px; color: var(--teal); cursor: pointer; text-decoration: underline; }
.login-card-back { transform: rotateY(180deg); }

/* ══════════════════════════════════════════════════════════════════
   RESPONSIVE
   Desktop (>= 992px): dos paneles lado a lado (diseño Figma original).
   Tablet / móvil (< 992px): paneles apilados — primero el formulario,
   debajo el carrusel como franja compacta.
   ══════════════════════════════════════════════════════════════════ */

/* Laptop angosta: menos padding lateral para que QR y selector respiren */
@media (max-width: 1199.98px) {
    .login-panel-left {
        padding: 36px 36px 28px;
    }
}

@media (max-width: 991.98px) {
    .login-page {
        align-items: flex-start;
        padding: 24px 16px;
    }

    .login-box {
        flex-direction: column;
        max-width: 640px;
        min-height: 0;
        margin: 0 auto;
    }

    .login-panel-left {
        flex: none;
        overflow-y: visible;
        padding: 32px 32px 24px;
    }

    .login-card-inner {
        flex: none;
    }

    .login-box-footer {
        margin-top: 24px;
    }

    .login-panel-right {
        flex: none;
        padding: 0 12px 12px;
    }

    .right-panel-inner {
        min-height: 220px;
    }

    .right-carousel .owl-stage-outer,
    .right-carousel .owl-stage,
    .right-carousel .owl-item,
    .right-slide {
        height: 180px;
    }

    .carousel-slide-img {
        max-height: 150px;
    }
}

@media (max-width: 575.98px) {
    .login-page {
        padding: 12px;
    }

    .login-panel-left {
        padding: 24px 16px 20px;
    }

    /* Deja espacio al botón "Obtener aplicación" (absoluto arriba a la derecha) */
    .login-header {
        padding: 0 44px;
        margin-bottom: 16px;
    }

    .get-app-button {
        top: 12px;
        right: 12px;
    }

    #bloqueQR h4 {
        font-size: 20px;
    }

    #bloqueQR p {
        font-size: 15px;
    }

    /* Selector segmentado: ocupa el ancho disponible y reparte los botones */
    .segmented {
        display: flex;
        width: 100%;
        max-width: 360px;
        margin-left: auto;
        margin-right: auto;
    }

    /* .login-panel-left sube especificidad: el tema S3 (style.css) carga
       después y define padding/font-size de .btn-group-sm > .btn */
    .login-panel-left .segmented .btn {
        flex: 1 1 auto;
        padding: 4px 6px;
        font-size: 13px;
        letter-spacing: 0;
    }

    .right-panel-inner {
        min-height: 180px;
    }

    .right-carousel .owl-stage-outer,
    .right-carousel .owl-stage,
    .right-carousel .owl-item,
    .right-slide {
        height: 140px;
    }

    .carousel-slide-img {
        max-height: 120px;
    }

    .app-qr-backdrop {
        padding: 16px;
    }

    .app-qr-modal {
        padding: 28px 20px 24px;
    }

    /* Área táctil cómoda para cerrar el modal */
    .app-qr-close {
        width: 40px;
        height: 40px;
        top: 8px;
        right: 8px;
    }
}

/* Móviles muy angostos: los íconos del selector son decorativos (el texto se
   conserva) y se ocultan para que las tres opciones quepan sin recortarse. */
@media (max-width: 359.98px) {
    .login-panel-left .segmented .btn i {
        display: none;
    }

    .portal-label {
        font-size: 14px;
        letter-spacing: 1.2px;
    }
}

/* Desktop con poca altura (laptops 1366x768, 1280x720): compacta el espaciado
   vertical para que el login completo quepa sin scroll. */
@media (min-width: 992px) and (max-height: 820px) {
    .login-page {
        padding-top: 16px;
        padding-bottom: 16px;
    }

    .login-box {
        min-height: min(763px, calc(100vh - 32px));
    }

    .login-panel-left {
        padding-top: 20px;
        padding-bottom: 16px;
    }

    .portal-label {
        padding-top: 4px;
    }

    .login-header {
        margin-bottom: 12px;
    }
}
