@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700;900&family=Roboto+Mono:wght@400;700&display=swap');

:root {
    --font-main: 'Roboto', sans-serif;
    --font-mono: 'Roboto Mono', monospace;
    
    /* Professional Security Palette */
    --color-primary: #156ab7;    /* Deep Security Blue */
    --color-accent: #f68c40;     /* Warning/Highlight Orange */
    --color-success: #acbe29;    /* Trust Lime Green */
    
    --color-bg: #f4f6f9;
    --color-surface: #ffffff;
    --color-surface-alt: #f8fafc;
    --color-border: #d9e2ec;
    --color-text: #102a43;
    --color-muted: #52606d;
    --color-slate-100: #f1f5f9;
    --color-slate-200: #e2e8f0;
    --color-slate-400: #94a3b8;
    --color-slate-500: #64748b;
    --color-slate-900: #102a43;
    
    --radius-lg: 18px;
    --radius-md: 14px;
    --shadow-premium: 0 24px 64px rgba(15, 23, 42, 0.08);
}

* { 
    box-sizing: border-box; 
}

body {
    font-family: var(--font-main);
    background-color: var(--color-bg);
    color: var(--color-text);
    margin: 0;
    padding: 48px 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    line-height: 1.6;
}

/* --- Card Frame --- */
.auth-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 40px;
    max-width: 520px;
    width: 100%;
    box-shadow: var(--shadow-premium);
    text-align: center;
    animation: cardReveal 0.5s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes cardReveal {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Typography --- */
h2 {
    font-size: 26px;
    font-weight: 800;
    margin: 0 0 12px 0;
    letter-spacing: -0.02em;
    color: var(--color-text);
}

h2.gradient-text {
    background: linear-gradient(135deg, #102a43 0%, var(--color-slate-500) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

p {
    color: var(--color-muted);
    font-size: 14px;
    margin: 0 0 24px 0;
    line-height: 1.75;
}

/* --- Security Badge Icons & Dynamic Logos --- */
.icon-wrap {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
}

.icon-wrap.lock {
    background: rgba(21, 106, 183, 0.12);
    border: 2px solid var(--color-primary);
    color: #60a5fa;
    box-shadow: 0 0 20px rgba(21, 106, 183, 0.2);
}

.icon-wrap.shield {
    background: rgba(172, 190, 41, 0.12);
    border: 2px solid var(--color-success);
    color: var(--color-success);
    box-shadow: 0 0 20px rgba(172, 190, 41, 0.2);
}

/* Flexible Rectangular Brand Emblem Wrapper to handle varied aspect ratios & text-heavy logos */
.logo-container {
    max-width: 220px;
    height: 100px;
    padding: 12px 14px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 22px;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    color: var(--color-slate-400);
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden; /* Restricts raw image bounds overflow */
}

.logo-container.tenant-active {
    background: rgba(172, 190, 41, 0.12);
    border: 1px solid rgba(172, 190, 41, 0.2);
    color: var(--color-success);
    box-shadow: 0 12px 28px rgba(172, 190, 41, 0.12);
}

/* When a raster/brand image is present we prefer a flatter canvas so images don't inherit the SVG-focused treatment */
.logo-container.image-active {
    background: transparent;
    border-color: transparent;
    box-shadow: none;
    padding: 8px 12px; /* give image some breathing room */
}

/* Ensure the SVG fallback retains a clear, colored theme */
.logo-fallback {
    display: none;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
}

.logo-fallback svg {
    color: var(--color-primary);
    fill: none;
}

/* Proportional fitting for modern rectangular logos without cropping text */
.logo-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain; /* Retains complete image and aspect ratio dynamics */
    display: block;
}

/* --- Steps & Labels --- */
.step-num {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(21, 106, 183, 0.2);
    color: #60a5fa;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 800;
    margin-right: 8px;
    vertical-align: middle;
}

.step-title {
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--color-slate-400);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.input-label {
    display: block;
    font-size: 12px;
    font-weight: 700;
    color: var(--color-slate-400);
    margin-bottom: 12px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

/* --- Interactive Code & Form Inputs --- */
.code-input-container {
    position: relative;
    margin-bottom: 24px;
}

.confirmation-input {
    width: 100%;
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 16px;
    font-family: var(--font-main);
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
    text-align: left;
    letter-spacing: normal;
    outline: none;
    transition: border-color 0.25s ease, box-shadow 0.25s ease, background 0.25s ease;
}

.confirmation-input.login-input {
    font-size: 15px;
    letter-spacing: normal;
    padding-left: 16px;
}

.confirmation-input:focus {
    border-color: var(--color-primary);
    background: #ffffff;
    box-shadow: 0 0 0 4px rgba(21, 106, 183, 0.08);
}

.confirmation-input::placeholder {
    color: var(--color-slate-400);
    letter-spacing: normal;
}

.confirmation-input.login-input::placeholder {
    color: var(--color-slate-400);
    font-size: 14px;
    font-weight: 500;
    letter-spacing: normal;
}

/* --- Shared Form Layout Structures --- */
.form-group {
    margin-bottom: 20px;
    position: relative;
}

.form-group-collapsible {
    max-height: 100px;
    opacity: 1;
    transform: translateY(0);
    margin-bottom: 20px;
    transition: max-height 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                opacity 0.25s ease-out,
                transform 0.4s cubic-bezier(0.16, 1, 0.3, 1),
                margin-bottom 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.form-group-collapsible.is-hidden {
    max-height: 0;
    opacity: 0;
    transform: translateY(-12px);
    margin-bottom: 0;
    pointer-events: none;
}

/* Password action button alignment */
.input-action-btn {
    position: absolute;
    right: 16px;
    top: 67%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-slate-500);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s;
}

.input-action-btn:hover {
    color: var(--color-primary);
}

/* Checkbox and contextual link lines */
.option-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    font-size: 13px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 500;
    color: var(--color-slate-400);
    user-select: none;
}

.checkbox-input {
    appearance: none;
    width: 16px;
    height: 16px;
    border: 1.5px solid var(--color-border);
    border-radius: 4px;
    background-color: #ffffff;
    outline: none;
    cursor: pointer;
    display: inline-grid;
    place-content: center;
    transition: all 0.2s;
}

.checkbox-input:hover {
    border-color: var(--color-slate-400);
}

.checkbox-input:checked {
    background-color: var(--color-primary);
    border-color: var(--color-primary);
}

.checkbox-input::before {
    content: "";
    width: 8px;
    height: 6px;
    clip-path: polygon(14% 44%, 0 58%, 35% 100%, 100% 16%, 86% 2%, 35% 72%);
    transform: scale(0);
    transform-origin: center;
    transition: transform 0.1s ease-in-out;
    background-color: #ffffff;
}

.checkbox-input:checked::before {
    transform: scale(1);
}

.forgot-link {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.forgot-link:hover {
    color: #60a5fa;
}

/* --- Shared Navigation & Portal Selection Elements --- */
.tenant-selector {
    display: flex;
    background-color: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    padding: 4px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    gap: 4px;
}

.tenant-selector.hidden {
    display: none;
}

.selector-btn {
    flex: 1;
    background: none;
    border: none;
    font-family: var(--font-main);
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-muted);
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.selector-btn.active {
    background-color: var(--color-primary);
    color: #ffffff;
    box-shadow: 0 8px 16px rgba(21, 106, 183, 0.14);
}

/* --- Action Elements --- */
.btn-secure {
    width: 100%;
    color: white;
    border: none;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    text-decoration: none;
}

.btn-secure.primary {
    background: var(--color-primary);
    box-shadow: 0 12px 24px rgba(21, 106, 183, 0.16);
}

.btn-secure.primary:hover {
    background: #1f79dc;
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(21, 106, 183, 0.18);
}

.btn-secure.primary:active {
    transform: translateY(0);
}

/* --- Loader Animation --- */
.spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --- QR Configuration Framework --- */
.qr-outer-container {
    background: var(--color-surface-alt);
    padding: 24px;
    border-radius: var(--radius-md);
    display: inline-block;
    margin-bottom: 24px;
    box-shadow: inset 0 2px 4px rgba(15, 23, 42, 0.04);
    border: 1px solid var(--color-border);
    transition: transform 0.3s;
}

.qr-outer-container:hover {
    transform: scale(1.02);
}

.qr-image {
    display: block;
    width: 180px;
    height: 180px;
}

/* --- Backup Manual Keys --- */
.backup-container {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 32px;
    text-align: left;
}

.backup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.backup-label {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--color-slate-500);
    letter-spacing: 0.05em;
}

.copy-trigger {
    background: transparent;
    border: none;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: 0.2s;
}

.copy-trigger:hover {
    background: rgba(21, 106, 183, 0.1);
    color: #60a5fa;
}

.secret-display {
    font-family: var(--font-mono);
    font-size: 15px;
    color: var(--color-text);
    letter-spacing: 0.05em;
    word-break: break-all;
    display: block;
    background: var(--color-surface-alt);
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
}

.verification-form {
    border-top: 1px solid var(--color-border);
    padding-top: 32px;
    text-align: left;
}

.verification-form.no-border {
    border-top: none;
    padding-top: 0;
}

/* --- Recovery Code Grid --- */
.recovery-vault {
    background: var(--color-surface-alt);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 24px;
    text-align: left;
}

.vault-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 12px;
}

.vault-title {
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--color-primary);
    letter-spacing: 0.08em;
    display: flex;
    align-items: center;
    gap: 6px;
}

.vault-actions {
    display: flex;
    gap: 8px;
}

.vault-btn {
    background: #ffffff;
    border: 1px solid var(--color-border);
    color: var(--color-text);
    cursor: pointer;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: 0.2s;
}

.vault-btn:hover {
    background: var(--color-surface-alt);
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.codes-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.code-block {
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
    background: #f1f5f9;
    border: 1px solid var(--color-border);
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    letter-spacing: 0.05em;
    box-shadow: inset 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: all 0.2s;
}

.code-block:hover {
    border-color: var(--color-primary);
    background: rgba(21, 106, 183, 0.05);
}

/* --- Feedback & Warnings --- */
.alert-toast {
    display: none;
    background: rgba(172, 190, 41, 0.12);
    border: 1px solid rgba(172, 190, 41, 0.24);
    color: var(--color-text);
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 24px;
    text-align: left;
    animation: toastIn 0.3s ease-out;
}

.error-alert {
    background: rgba(246, 140, 64, 0.12);
    border: 1px solid rgba(246, 140, 64, 0.24);
    color: #92400e;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 0;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 8px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top-width: 0;
    border-bottom-width: 0;
    transition:
        max-height 0.35s ease,
        margin-bottom 0.35s ease,
        opacity 0.25s ease,
        padding 0.35s ease,
        border-width 0.35s ease;
}

.error-alert.is-visible {
    max-height: 180px;
    overflow-y: auto;
    margin-bottom: 24px;
    opacity: 1;
    padding-top: 12px;
    padding-bottom: 12px;
    border-top-width: 1px;
    border-bottom-width: 1px;
}

.error-alert.is-fading {
    pointer-events: none;
}

.security-warning {
    background: rgba(246, 140, 64, 0.06);
    border: 1px solid rgba(246, 140, 64, 0.2);
    border-radius: var(--radius-md);
    padding: 14px 16px;
    margin-bottom: 32px;
    display: flex;
    gap: 12px;
    align-items: flex-start;
    text-align: left;
}

.warning-icon {
    color: var(--color-accent);
    flex-shrink: 0;
    margin-top: 2px;
}

.warning-text {
    font-size: 12px;
    font-weight: 600;
    color: #fdba74;
    line-height: 1.5;
    margin: 0;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Informational Footer (Verification Screen Only) --- */
.recovery-info {
    border-top: 1px solid var(--color-border);
    padding-top: 20px;
    margin-top: 24px;
    text-align: left;
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.recovery-icon {
    color: var(--color-slate-500);
    flex-shrink: 0;
    margin-top: 2px;
}

.recovery-text {
    font-size: 12px;
    color: var(--color-slate-500);
    line-height: 1.5;
    margin: 0;
}

.recovery-highlight {
    color: var(--color-accent);
    font-weight: 700;
    text-decoration: underline;
    text-decoration-thickness: 1.5px;
    text-underline-offset: 3px;
}

/* --- Global Portal/Auth Navigation Footnotes --- */
.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--color-muted);
}

.auth-footer a {
    color: var(--color-primary);
    text-decoration: none;
    font-weight: 700;
    transition: color 0.2s;
}

.auth-footer a:hover {
    color: #174f8d;
}

/* Legal & Copyright Footer */
.legal-footer {
    text-align: center;
    margin-top: 85px;
    font-size: 11px;
    color: var(--color-slate-500);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.legal-footer a {
    color: var(--color-slate-400);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.legal-footer p {
    margin: 5px 0 5px 0;
}

.legal-footer a:hover {
    color: var(--color-primary);
}

.legal-footer .divider {
    margin: 0 6px;
    color: rgba(100, 116, 139, 0.45);
    user-select: none;
}