/**
 * Custom Auth Pages Styling
 * Module: PortalClient
 *
 * Modern login page design with split layout
 */

/* ============================================
   Auth Background & Overlay
   ============================================ */

.auth-bg {
    min-height: 100vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    background-size: cover;
    background-position: center center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    box-sizing: border-box;
    overflow-y: auto;
}

.auth-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1;
    pointer-events: none;
}

/* ============================================
   Language Switcher
   ============================================ */

.auth-lang-switch {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: white;
    padding: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    border-radius: 8px;
    z-index: 9999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    pointer-events: auto;
}

.lang-btn {
    border: none;
    background-color: rgb(243, 244, 246);
    cursor: pointer;
    color: rgb(75, 85, 99);
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    transition: all 0.2s ease;
    pointer-events: auto !important;
}

.lang-btn:hover {
    background-color: rgb(229, 231, 235);
}

.lang-btn.active {
    color: rgb(29, 78, 216);
    background-color: rgb(239, 246, 255);
    border: 1px solid rgb(191, 219, 254);
}

.lang-separator {
    color: rgb(209, 213, 219);
    font-size: 14px;
}

/* ============================================
   Split Layout Container
   ============================================ */

.auth-container {
    position: relative;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    max-width: 100%;
    padding: 40px 0;
    box-sizing: border-box;
}

/* ============================================
   Left Side - Logo & Branding
   ============================================ */

.auth-left {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    padding-left: 5%;
}

.auth-logo {
    margin-bottom: 20px;
}

.auth-logo img {
    width: 560px;
    height: auto;
    object-fit: contain;
}

.auth-tagline {
    font-size: 18px;
    color: rgba(255, 255, 255, 0.9);
    margin: 0;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Right Side - Form
   ============================================ */

.auth-right {
    flex: 0 0 420px;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-right: 5%;
}

/* ============================================
   Auth Card
   ============================================ */

.auth-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}

.auth-welcome {
    display: block;
    font-size: 14px;
    color: rgb(107, 114, 128);
    margin-bottom: 8px;
}

.auth-heading {
    font-size: 24px;
    font-weight: 600;
    color: rgb(17, 24, 39);
    margin: 0 0 30px 0;
}

/* ============================================
   Form Groups (Floating Labels)
   ============================================ */

.auth-form-group {
    position: relative;
    margin-bottom: 20px;
}

.auth-input {
    width: 100%;
    padding: 16px 14px;
    font-size: 15px;
    border: 1px solid rgb(209, 213, 219);
    border-radius: 10px;
    outline: none;
    transition: all 0.2s ease;
    background-color: white !important;
    box-sizing: border-box;
}

/* Force white background on autofill (Chrome, Safari, Edge) */
.auth-input:-webkit-autofill,
.auth-input:-webkit-autofill:hover,
.auth-input:-webkit-autofill:focus,
.auth-input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 1000px white inset !important;
    box-shadow: 0 0 0 1000px white inset !important;
    -webkit-text-fill-color: rgb(17, 24, 39) !important;
    background-color: white !important;
    transition: background-color 5000s ease-in-out 0s;
}

/* Firefox autofill */
.auth-input:autofill {
    background-color: white !important;
}

.auth-input:focus {
    border-color: rgb(59, 130, 246);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.auth-input:focus + .auth-label,
.auth-input:not(:placeholder-shown) + .auth-label {
    top: -8px;
    left: 12px;
    font-size: 12px;
    color: rgb(59, 130, 246);
    background: linear-gradient(to bottom, transparent 50%, white 50%);
    padding: 0 4px;
}

/* Also handle autofill state for label */
.auth-input:-webkit-autofill + .auth-label {
    top: -8px;
    left: 12px;
    font-size: 12px;
    color: rgb(59, 130, 246);
    background: linear-gradient(to bottom, transparent 50%, white 50%);
    padding: 0 4px;
}

.auth-label {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 15px;
    color: rgb(107, 114, 128);
    pointer-events: none;
    transition: all 0.2s ease;
    background: transparent;
}

/* Password Eye Button */
.auth-form-group[data-name="password"] {
    position: relative;
}

.auth-form-group[data-name="password"] .auth-input {
    padding-right: 45px;
}

.auth-eye-btn {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: rgb(156, 163, 175);
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.auth-eye-btn:hover {
    color: rgb(75, 85, 99);
}

/* ============================================
   Form Options (Remember Me & Forgot Password)
   ============================================ */

.auth-form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.auth-remember-me {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: rgb(55, 65, 81);
    position: relative;
}

.auth-remember-me input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    cursor: pointer;
    height: 0;
    width: 0;
}

.auth-remember-me .checkmark {
    height: 18px;
    width: 18px;
    background-color: white;
    border: 2px solid rgb(209, 213, 219);
    border-radius: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.auth-remember-me:hover .checkmark {
    border-color: rgb(59, 130, 246);
}

.auth-remember-me input[type="checkbox"]:checked ~ .checkmark {
    background-color: rgb(59, 130, 246);
    border-color: rgb(59, 130, 246);
}

.auth-remember-me .checkmark:after {
    content: "";
    display: none;
    width: 4px;
    height: 8px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
    margin-bottom: 2px;
}

.auth-remember-me input[type="checkbox"]:checked ~ .checkmark:after {
    display: block;
}

.auth-remember-me span:not(.checkmark) {
    user-select: none;
}

.auth-forgot-link {
    font-size: 14px;
    color: rgb(59, 130, 246);
    text-decoration: none;
    cursor: pointer;
    transition: color 0.2s ease;
}

.auth-forgot-link:hover {
    color: rgb(29, 78, 216);
    text-decoration: underline;
}

/* ============================================
   Recovery Panel
   ============================================ */

.hidden {
    display: none !important;
}

.auth-back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: rgb(107, 114, 128);
    text-decoration: none;
    cursor: pointer;
    margin-bottom: 20px;
    transition: color 0.2s ease;
}

.auth-back-link:hover {
    color: rgb(59, 130, 246);
}

.auth-back-link .fas {
    font-size: 12px;
}

.auth-subtitle {
    font-size: 14px;
    color: rgb(107, 114, 128);
    margin: 0 0 25px 0;
    line-height: 1.5;
}

#recovery-panel .auth-heading {
    margin-bottom: 10px;
}

#recovery-panel .auth-form-group {
    margin-bottom: 20px;
}

/* ============================================
   Buttons
   ============================================ */

.auth-btn {
    width: 100%;
    padding: 14px 24px;
    font-size: 16px;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.auth-btn-primary {
    background: linear-gradient(135deg, rgb(59, 130, 246), rgb(37, 99, 235));
    color: white;
}

.auth-btn-primary:hover {
    background: linear-gradient(135deg, rgb(37, 99, 235), rgb(29, 78, 216));
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.auth-btn-primary:active {
    transform: scale(0.98);
}

.auth-btn-primary:disabled {
    background: rgb(156, 163, 175);
    cursor: not-allowed;
    box-shadow: none;
}

.auth-btn-sso {
    background: white;
    color: rgb(55, 65, 81);
    border: 1px solid rgb(209, 213, 219);
}

.auth-btn-sso:hover {
    background: rgb(249, 250, 251);
    border-color: rgb(156, 163, 175);
}

/* ============================================
   SSO / Divider
   ============================================ */

.auth-sso-section {
    margin-bottom: 20px;
}

.auth-or-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
}

.auth-or-divider::before,
.auth-or-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid rgb(229, 231, 235);
}

.auth-or-divider span {
    padding: 0 16px;
    font-size: 13px;
    color: rgb(156, 163, 175);
    text-transform: uppercase;
}

/* ============================================
   Another User
   ============================================ */

.auth-another-user {
    background: rgb(249, 250, 251);
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid rgb(229, 231, 235);
}

.auth-another-user label {
    font-size: 12px;
    color: rgb(107, 114, 128);
    margin-bottom: 4px;
    display: block;
}

.auth-another-user div {
    font-weight: 500;
    color: rgb(17, 24, 39);
}

/* ============================================
   Copyright
   ============================================ */

.auth-copyright {
    margin-top: 20px;
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ============================================
   Responsive
   ============================================ */

@media (max-width: 1100px) {
    .auth-container {
        flex-direction: column;
        gap: 40px;
        padding: 20px;
        justify-content: center;
    }

    .auth-left {
        align-items: center;
        padding-left: 0;
        text-align: center;
    }

    .auth-right {
        flex: 0 0 auto;
        width: 100%;
        max-width: 420px;
        margin-right: 0;
    }

    .auth-logo img {
        width: 400px;
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 30px 24px;
        border-radius: 12px;
    }

    .auth-heading {
        font-size: 20px;
    }

    .auth-logo img {
        width: 280px;
    }

    .auth-lang-switch {
        bottom: 10px;
        right: 10px;
    }

    .auth-form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
}

/* ============================================
   Auth Alert Styles
   ============================================ */

.auth-alert {
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    margin-bottom: 20px;
}

.auth-alert-danger {
    background: rgb(254, 242, 242);
    color: rgb(185, 28, 28);
    border: 1px solid rgb(254, 202, 202);
}

.auth-alert-success {
    background: rgb(236, 253, 245);
    color: rgb(5, 122, 85);
    border: 1px solid rgb(167, 243, 208);
}

.auth-alert-warning {
    background: rgb(255, 251, 235);
    color: rgb(180, 83, 9);
    border: 1px solid rgb(253, 230, 138);
}

/* ============================================
   Override EspoCRM default login styles
   ============================================ */

/* Hide default container when custom auth is active */
body.auth-page .container.content {
    display: none !important;
}

/* Ensure our auth-bg takes full viewport */
body.auth-page {
    overflow: hidden !important;
    background: #1a1a2e !important;
}

body.auth-page > footer {
    display: none !important;
}

/* Hide any other potential containers */
body.auth-page #main,
body.auth-page .main-container {
    background: transparent !important;
}
