/* ============================================================
   Traffic Watch - Keycloak Login Theme: Split Screen
   Design: Left branding panel + Right login form
   ============================================================ */

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

:root {
    --teal-500: #14b8a6;
    --teal-600: #0d9488;
    --teal-700: #0f766e;
    --navy: #022B6D;
    --navy-dark: #011a42;
    --white: #ffffff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --red-50: #fef2f2;
    --red-500: #ef4444;
    --red-600: #dc2626;
    --red-700: #b91c1c;
    --font-heading: 'Outfit', sans-serif;
    --font-body: 'Montserrat', sans-serif;
}

html, body {
    height: 100%;
    font-family: var(--font-body);
    background: var(--white);
    color: var(--gray-800);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---- Layout: Split Screen ---- */

.split-container {
    display: flex;
    min-height: 100vh;
}

/* ---- Left Branding Panel ---- */

.brand-panel {
    position: relative;
    flex: 0 0 45%;
    max-width: 45%;
    background: linear-gradient(160deg, var(--teal-500) 0%, var(--teal-700) 35%, var(--navy) 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 2.5rem;
    overflow: hidden;
    color: var(--white);
}

/* Decorative background pattern */
.brand-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(circle at 2px 2px, rgba(255,255,255,0.07) 1px, transparent 0);
    background-size: 28px 28px;
    pointer-events: none;
}

/* Decorative diagonal lines */
.brand-panel::after {
    content: '';
    position: absolute;
    bottom: -60px;
    right: -60px;
    width: 320px;
    height: 320px;
    border: 2px solid rgba(255,255,255,0.08);
    border-radius: 50%;
    pointer-events: none;
}

.brand-content {
    position: relative;
    z-index: 1;
    text-align: center;
    max-width: 380px;
}

/* Decorative accent lines */
.brand-accents {
    position: absolute;
    top: 40px;
    left: 40px;
    z-index: 1;
}

.brand-accents .line {
    display: block;
    height: 3px;
    border-radius: 2px;
    background: rgba(255,255,255,0.15);
    margin-bottom: 8px;
}

.brand-accents .line:nth-child(1) { width: 60px; }
.brand-accents .line:nth-child(2) { width: 40px; }
.brand-accents .line:nth-child(3) { width: 24px; }

.brand-dots {
    position: absolute;
    bottom: 50px;
    right: 50px;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(4, 8px);
    gap: 10px;
}

.brand-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.12);
}

.brand-dots .dot:nth-child(3),
.brand-dots .dot:nth-child(6),
.brand-dots .dot:nth-child(9),
.brand-dots .dot:nth-child(11) {
    background: rgba(255,255,255,0.25);
}

.brand-logo {
    margin-bottom: 2rem;
}

.brand-logo svg {
    width: 80px;
    height: 96px;
    filter: drop-shadow(0 4px 20px rgba(0,0,0,0.2));
}

.brand-name {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 2.5rem;
    line-height: 1.1;
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
}

.brand-tagline {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: 1.05rem;
    opacity: 0.8;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.brand-divider {
    width: 48px;
    height: 3px;
    background: rgba(255,255,255,0.4);
    border-radius: 2px;
    margin: 1.5rem auto;
}

.brand-description {
    font-size: 0.9rem;
    line-height: 1.65;
    opacity: 0.65;
    max-width: 320px;
}

/* ---- Right Login Panel ---- */

.login-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem 2rem;
    background: var(--white);
}

.login-wrapper {
    width: 100%;
    max-width: 420px;
}

.login-header {
    margin-bottom: 2.25rem;
}

.login-header h1 {
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 1.75rem;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.login-header p {
    font-size: 0.95rem;
    color: var(--gray-500);
    line-height: 1.5;
}

/* ---- Error Alert ---- */
/* FreeMarker: <#if message?has_content && (message.type = 'error' || message.type = 'warning')> */

.alert-error {
    display: none; /* Hidden by default; remove display:none when error present */
    background: var(--red-50);
    border: 1px solid #fecaca;
    border-left: 4px solid var(--red-500);
    border-radius: 8px;
    padding: 0.875rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--red-700);
    line-height: 1.5;
}

.alert-error .alert-icon {
    display: inline-flex;
    margin-right: 0.5rem;
    vertical-align: middle;
}

.alert-error .alert-icon svg {
    width: 18px;
    height: 18px;
    fill: var(--red-500);
}

/* ---- Form ---- */
/* FreeMarker: <form id="kc-form-login" action="${url.loginAction}" method="post"> */

.form-group {
    margin-bottom: 1.25rem;
}

.form-label {
    display: block;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.4rem;
    letter-spacing: 0.01em;
}

.form-input-wrapper {
    position: relative;
}

.form-input-wrapper .input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    color: var(--gray-400);
    display: flex;
    align-items: center;
}

.form-input-wrapper .input-icon svg {
    width: 18px;
    height: 18px;
}

.form-input {
    width: 100%;
    padding: 0.75rem 0.875rem 0.75rem 2.75rem;
    font-family: var(--font-body);
    font-size: 0.9375rem;
    color: var(--gray-800);
    background: var(--gray-50);
    border: 1.5px solid var(--gray-200);
    border-radius: 10px;
    outline: none;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input::placeholder {
    color: var(--gray-400);
}

.form-input:hover {
    border-color: var(--gray-300);
}

.form-input:focus {
    background: var(--white);
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

/* Password visibility toggle */
.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    transition: color 0.15s ease;
}

.password-toggle:hover {
    color: var(--gray-600);
}

.password-toggle svg {
    width: 18px;
    height: 18px;
}

/* ---- Remember Me & Forgot Password row ---- */

.form-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
}

.remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.remember-me input[type="checkbox"] {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border: 1.5px solid var(--gray-300);
    border-radius: 5px;
    background: var(--white);
    cursor: pointer;
    position: relative;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.remember-me input[type="checkbox"]:checked {
    background: var(--teal-600);
    border-color: var(--teal-600);
}

.remember-me input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 2px;
    width: 5px;
    height: 9px;
    border: solid var(--white);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.remember-me input[type="checkbox"]:focus-visible {
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.2);
}

.remember-me span {
    font-size: 0.8125rem;
    color: var(--gray-600);
    user-select: none;
}

.forgot-password {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--teal-600);
    text-decoration: none;
    transition: color 0.15s ease;
}

.forgot-password:hover {
    color: var(--teal-700);
    text-decoration: underline;
}

/* ---- Submit Button ---- */

.btn-submit {
    width: 100%;
    padding: 0.8125rem 1.5rem;
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1rem;
    letter-spacing: 0.02em;
    color: var(--white);
    background: linear-gradient(135deg, var(--teal-500) 0%, var(--teal-700) 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease, filter 0.2s ease;
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.3);
}

.btn-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(20, 184, 166, 0.35);
    filter: brightness(1.05);
}

.btn-submit:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(20, 184, 166, 0.25);
}

.btn-submit:focus-visible {
    outline: 3px solid rgba(20, 184, 166, 0.4);
    outline-offset: 2px;
}

/* ---- Register Link ---- */
/* FreeMarker: <#if realm.registrationAllowed && !registrationDisabled??> */

.register-link {
    text-align: center;
    margin-top: 1.75rem;
    font-size: 0.875rem;
    color: var(--gray-500);
}

.register-link a {
    font-weight: 600;
    color: var(--teal-600);
    text-decoration: none;
    transition: color 0.15s ease;
}

.register-link a:hover {
    color: var(--teal-700);
    text-decoration: underline;
}

/* ---- Footer ---- */

.login-footer {
    margin-top: 3rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--gray-400);
}

.login-footer a {
    color: var(--gray-400);
    text-decoration: none;
}

.login-footer a:hover {
    color: var(--gray-600);
}

/* ============================================================
   Responsive: Mobile / Small Screens
   ============================================================ */

@media (max-width: 900px) {
    .split-container {
        flex-direction: column;
    }

    .brand-panel {
        flex: none;
        max-width: 100%;
        width: 100%;
        padding: 2.5rem 2rem 2rem;
        min-height: auto;
    }

    .brand-accents {
        top: 20px;
        left: 20px;
    }

    .brand-dots {
        display: none;
    }

    .brand-panel::after {
        width: 200px;
        height: 200px;
        bottom: -40px;
        right: -40px;
    }

    .brand-logo svg {
        width: 56px;
        height: 67px;
    }

    .brand-name {
        font-size: 1.75rem;
    }

    .brand-tagline {
        font-size: 0.875rem;
    }

    .brand-divider,
    .brand-description {
        display: none;
    }

    .login-panel {
        padding: 2rem 1.5rem 3rem;
    }

    .login-header h1 {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .brand-panel {
        padding: 2rem 1.25rem 1.5rem;
    }

    .brand-accents {
        display: none;
    }

    .brand-logo svg {
        width: 48px;
        height: 58px;
    }

    .brand-name {
        font-size: 1.5rem;
    }

    .login-panel {
        padding: 1.5rem 1.25rem 2.5rem;
    }

    .form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
}

/* ---- Success/Info Alerts ---- */

.alert-success,
.alert-info {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: #f0fdfa;
    border: 1px solid #99f6e4;
    border-left: 4px solid var(--teal-500);
    border-radius: 8px;
    padding: 0.875rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: var(--teal-700);
    line-height: 1.5;
}

.alert-success .alert-icon svg,
.alert-info .alert-icon svg {
    width: 18px;
    height: 18px;
    fill: var(--teal-500);
}

/* ---- Warning Alert ---- */

.alert-warning {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-left: 4px solid #f59e0b;
    border-radius: 8px;
    padding: 0.875rem 1rem;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    color: #92400e;
    line-height: 1.5;
}

.alert-warning .alert-icon svg {
    width: 18px;
    height: 18px;
    fill: #f59e0b;
}

/* ---- Back to Login Link ---- */

.back-to-login {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--teal-600);
    text-decoration: none;
    margin-top: 1.5rem;
    transition: color 0.15s ease;
}

.back-to-login:hover {
    color: var(--teal-700);
    text-decoration: underline;
}

.back-to-login svg {
    width: 16px;
    height: 16px;
}

/* ---- Info Page Content ---- */

.info-page-content {
    text-align: center;
    padding: 2rem 0;
}

.info-page-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #f0fdfa;
    margin-bottom: 1.5rem;
}

.info-page-icon svg {
    width: 32px;
    height: 32px;
    color: var(--teal-500);
}

.info-page-message {
    font-size: 0.95rem;
    color: var(--gray-600);
    line-height: 1.65;
    max-width: 360px;
    margin: 0 auto 1.5rem;
}

/* ---- Error Page Content ---- */

.error-page-content {
    text-align: center;
    padding: 2rem 0;
}

.error-page-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--red-50);
    margin-bottom: 1.5rem;
}

.error-page-icon svg {
    width: 32px;
    height: 32px;
    color: var(--red-500);
}

.error-page-message {
    font-size: 0.95rem;
    color: var(--gray-600);
    line-height: 1.65;
    max-width: 360px;
    margin: 0 auto 1.5rem;
}

/* ---- Field Error State ---- */

.form-input.input-error {
    border-color: var(--red-500);
    background: var(--red-50);
}

.form-input.input-error:focus {
    border-color: var(--red-500);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.12);
}

.field-error {
    font-size: 0.75rem;
    color: var(--red-600);
    margin-top: 0.25rem;
}

/* ---- Password Requirements ---- */

.password-requirements {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
    line-height: 1.4;
}
