/* ==========================================
   LOGIN PAGE - Split Screen Layout
   ========================================== */

/* Override layout for login - no sidebar, no nav */
.login-page {
    display: flex;
    min-height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9999;
}

/* Hide nav and main-content offset for login */
.login-page ~ .sidebar-nav,
body:has(.login-page) .sidebar-nav,
body:has(.login-page) .mobile-hamburger {
    display: none !important;
}

body:has(.login-page) .main-content {
    margin-left: 0 !important;
    padding: 0 !important;
}

/* ==========================================
   LEFT PANEL - BRANDING
   ========================================== */
.login-brand-panel {
    flex: 0 0 480px;
    background: linear-gradient(160deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px 50px;
    position: relative;
    overflow: hidden;
}

/* Subtle pattern overlay */
.login-brand-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-image:
        radial-gradient(circle at 20% 80%, rgba(208, 167, 100, 0.08) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(208, 167, 100, 0.06) 0%, transparent 50%);
    pointer-events: none;
}

/* Decorative geometric accents */
.login-brand-panel::after {
    content: '';
    position: absolute;
    top: -120px;
    right: -120px;
    width: 300px;
    height: 300px;
    border: 1px solid rgba(208, 167, 100, 0.1);
    border-radius: 50%;
    pointer-events: none;
}

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

.brand-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 28px;
    background: linear-gradient(135deg, #d0a764 0%, #c49a58 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 34px;
    color: #fff;
    box-shadow: 0 8px 32px rgba(208, 167, 100, 0.3);
}

/* Org-uploaded logo inside the gold brand tile (white-label auth pages). */
.brand-icon-img {
    max-height: 72px;
    width: auto;
}

/* Platform (Sahab Key) hero logo on the dark brand panel. Light variant,
   sized by height so the wordmark scales cleanly and never stretches. */
.brand-logo-hero {
    display: block;
    height: 40px;
    width: auto;
    max-width: 100%;
    margin: 0 auto 8px;
}

.login-brand-panel h1 {
    color: #fff;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}

.brand-tagline {
    color: rgba(255, 255, 255, 0.5);
    font-size: 15px;
    font-weight: 400;
    margin-bottom: 48px;
}

.brand-features {
    display: flex;
    flex-direction: column;
    gap: 18px;
    text-align: left;
    max-width: 280px;
    margin: 0 auto;
}

.feature-item {
    display: flex;
    align-items: center;
    gap: 14px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

.feature-item i {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(208, 167, 100, 0.12);
    border: 1px solid rgba(208, 167, 100, 0.2);
    border-radius: 10px;
    color: #d0a764;
    font-size: 14px;
    flex-shrink: 0;
}

.brand-footer {
    position: relative;
    z-index: 1;
    margin-top: auto;
    padding-top: 40px;
    color: rgba(255, 255, 255, 0.3);
    font-size: 13px;
}

.brand-footer strong {
    color: rgba(255, 255, 255, 0.5);
}

.brand-footer a {
    color: rgba(255, 255, 255, 0.6);
    font-weight: 600;
    text-decoration: none;
    transition: color 0.2s ease;
}

.brand-footer a:hover {
    color: rgba(255, 255, 255, 0.9);
    text-decoration: underline;
}

/* ==========================================
   RIGHT PANEL - LOGIN FORM
   ========================================== */
.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    background: #fff;
    overflow-y: auto;
}

.login-form-wrap {
    width: 100%;
    max-width: 400px;
}

/* Mobile brand (hidden on desktop) */
.mobile-brand {
    display: none;
    align-items: center;
    gap: 10px;
    margin-bottom: 32px;
}

.brand-icon-sm {
    width: 38px;
    height: 38px;
    background: linear-gradient(135deg, #d0a764 0%, #c49a58 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: #fff;
}

/* Org-uploaded logo inside the small gold tile (mobile brand row). */
.brand-icon-sm-img {
    max-height: 28px;
    width: auto;
}

/* Platform (Sahab Key) logo in the mobile brand row, on the white form panel.
   Espresso (dark-text) variant for the light background. */
.mobile-brand-logo {
    height: 30px;
    width: auto;
    max-width: 100%;
}

.mobile-brand span {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-dark);
}

/* Header */
.login-header {
    margin-bottom: 36px;
}

.login-header h2 {
    font-size: 26px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 6px;
    letter-spacing: -0.3px;
}

.login-header p {
    color: #6b7280;
    font-size: 15px;
}

/* Form */
.login-form-wrap .form-group {
    margin-bottom: 20px;
}

.login-form-wrap label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 6px;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.label-row label {
    margin-bottom: 0;
}

.forgot-link {
    font-size: 13px;
    color: #8a6726;
    font-weight: 500;
    text-decoration: none;
}

.forgot-link:hover {
    color: #6f521e;
    text-decoration: underline;
}

/* Input with icon */
.input-icon-wrap {
    position: relative;
}

.input-icon-wrap > i:first-child {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #c0c4cc;
    font-size: 14px;
    pointer-events: none;
    transition: color 0.2s;
}

.input-icon-wrap input {
    width: 100%;
    padding: 12px 14px 12px 42px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    color: var(--text-dark);
    background: #fff;
    transition: all 0.2s;
    outline: none;
}

.input-icon-wrap input::placeholder {
    color: #c0c4cc;
}

.input-icon-wrap input:focus {
    border-color: #d0a764;
    box-shadow: 0 0 0 3px rgba(208, 167, 100, 0.1);
}

.input-icon-wrap:has(input:focus) > i:first-child {
    color: #d0a764;
}

/* Password toggle */
.password-toggle-btn {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #c0c4cc;
    cursor: pointer;
    padding: 4px;
    font-size: 14px;
    transition: color 0.15s;
}

.password-toggle-btn:hover {
    color: #d0a764;
}

.password-toggle-btn:focus {
    outline: none;
}

/* Keyboard focus stays visible; pointer focus does not show an outline. */
.password-toggle-btn:focus-visible {
    outline: 2px solid #d0a764;
    outline-offset: 2px;
    border-radius: 6px;
    color: #d0a764;
}

/* Login button */
.btn-login {
    width: 100%;
    height: 48px;
    margin-top: 8px;
    background: linear-gradient(135deg, #d0a764 0%, #c49a58 100%);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: 0.2px;
    position: relative;
    white-space: nowrap;
}

.btn-login.is-loading .btn-text {
    visibility: hidden;
}

.btn-login.is-loading .btn-loading {
    display: inline-flex !important;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    align-items: center;
    gap: 8px;
    pointer-events: none;
}

.btn-login:hover {
    background: linear-gradient(135deg, #c49a58 0%, #b8903a 100%);
    box-shadow: 0 4px 16px rgba(208, 167, 100, 0.35);
    transform: translateY(-1px);
}

.btn-login:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(208, 167, 100, 0.25);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.btn-loading {
    display: flex;
    align-items: center;
    gap: 8px;
}

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Alerts */
.login-form-wrap .alert {
    margin-top: 16px;
    padding: 12px 14px;
    border-radius: 8px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.login-form-wrap .alert-danger {
    background: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.login-form-wrap .alert-success {
    background: #f0fdf4;
    color: #047857;
    border: 1px solid #bbf7d0;
}

/* Help section */
.login-help {
    margin-top: 36px;
    padding-top: 24px;
    border-top: 1px solid #f3f4f6;
    text-align: center;
}

.login-help > p {
    font-size: 13px;
    color: #6b7280;
    margin-bottom: 10px;
}

.help-contacts {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
}

.help-contacts a {
    font-size: 13px;
    color: #6b7280;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: color 0.15s;
}

.help-contacts a:hover {
    color: #d0a764;
}

.help-contacts a i {
    color: #d0a764;
    font-size: 12px;
    width: 14px;
}

/* Back to login link */
.back-to-login {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #6b7280;
    text-decoration: none;
    transition: color 0.15s;
}

.back-to-login:hover {
    color: #d0a764;
}

.back-to-login i {
    font-size: 12px;
}

/* Readonly input */
.input-readonly {
    background: #f9fafb !important;
    color: #6b7280 !important;
    cursor: not-allowed;
}

/* Form hint text */
.form-hint {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #6b7280;
}

/* Legal links */
.login-legal {
    margin-top: 20px;
    text-align: center;
    font-size: 12px;
    color: #c0c4cc;
}

.login-legal a {
    color: #6b7280;
    text-decoration: none;
    transition: color 0.15s;
}

.login-legal a:hover {
    color: #8a6726;
}

.legal-consent a {
    color: #8a6726;
    text-decoration: none;
}

.legal-consent a:hover {
    color: #6f521e;
    text-decoration: underline;
}

.login-legal span {
    margin: 0 8px;
}

/* ==========================================
   ANIMATIONS
   ========================================== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.shake {
    animation: shake 0.4s;
}

/* Entrance animation */
@keyframes fadeSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-form-wrap {
    animation: fadeSlideUp 0.5s ease-out;
}

.brand-content {
    animation: fadeSlideUp 0.6s ease-out 0.1s both;
}

/* ==========================================
   RESPONSIVE
   ========================================== */
@media (max-width: 1024px) {
    .login-brand-panel {
        flex: 0 0 380px;
        padding: 40px 36px;
    }
}

@media (max-width: 768px) {
    .login-page {
        flex-direction: column;
    }

    .login-brand-panel {
        display: none;
    }

    .mobile-brand {
        display: flex;
    }

    .login-form-panel {
        padding: 24px;
    }

    .login-header h2 {
        font-size: 22px;
    }
}
