/**
 * Login Page — Split-screen V2
 * frontend/views/site/login.php + layouts/login.php
 */

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

/* ==========================================================================
   Reset & base
   ========================================================================== */
.login-page {
    margin: 0;
    padding: 0;
    overflow: hidden;
    height: 100vh;
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ==========================================================================
   Split layout
   ========================================================================== */
.login-split {
    display: flex;
    height: 100vh;
    width: 100%;
}

/* ==========================================================================
   Left panel — branding (navy)
   ========================================================================== */
.login-brand-panel {
    width: 50%;
    background: linear-gradient(160deg, #1a2340 0%, #1e2a4a 50%, #243256 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px;
    position: relative;
    overflow: hidden;
}

/* Subtle gradient overlay */
.login-brand-panel::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 80%;
    height: 150%;
    background: radial-gradient(ellipse, rgba(255,255,255,0.03) 0%, transparent 70%);
    pointer-events: none;
}

.login-brand-content {
    position: relative;
    z-index: 1;
    max-width: 440px;
}

/* Logo block */
.login-brand-logo {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 16px;
}

.login-fimar-badge {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
    font-weight: 700;
    font-size: 22px;
    letter-spacing: 3px;
    padding: 10px 24px;
    border-radius: 8px;
}

.login-brand-separator {
    width: 1px;
    height: 40px;
    background: rgba(255, 255, 255, 0.3);
}

.login-gigue-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 4px;
}

.login-brand-tagline {
    color: rgba(255, 255, 255, 0.5);
    font-size: 13.5px;
    margin-bottom: 48px;
    line-height: 1.5;
}

/* Feature items */
.login-features {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.login-feature-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.75);
    font-size: 14px;
    font-weight: 500;
    transition: background 0.2s;
}

.login-feature-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.login-feature-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    color: rgba(255, 255, 255, 0.6);
    flex-shrink: 0;
}

/* ==========================================================================
   Left panel — password recovery variant
   ========================================================================== */
.login-brand-recovery {
    text-align: center;
    margin-top: 16px;
}

.login-recovery-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 32px;
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.04);
}

.login-recovery-title {
    color: #ffffff;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 8px;
}

.login-recovery-subtitle {
    color: rgba(255, 255, 255, 0.5);
    font-size: 13.5px;
    line-height: 1.6;
    margin-bottom: 36px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.login-recovery-steps {
    display: flex;
    flex-direction: column;
    gap: 12px;
    text-align: left;
}

.login-recovery-step {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 20px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: rgba(255, 255, 255, 0.75);
    font-size: 14px;
    font-weight: 500;
}

.login-step-number {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(79, 125, 249, 0.25);
    color: #7ba3fc;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    flex-shrink: 0;
}

/* ==========================================================================
   Password reset — success state
   ========================================================================== */
.pr-success {
    text-align: center;
    padding: 16px 0;
}

.pr-success-check {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: #ecfdf5;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    animation: pr-pop 0.4s ease;
}

.pr-success-check i {
    font-size: 28px;
    color: #10b981;
}

@keyframes pr-pop {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
}

.pr-success-title {
    font-size: 20px;
    font-weight: 700;
    color: #1e2a4a;
    margin-bottom: 8px;
}

.pr-success-email {
    font-family: 'JetBrains Mono', monospace;
    font-size: 14px;
    color: #4f7df9;
    background: rgba(79, 125, 249, 0.08);
    padding: 6px 16px;
    border-radius: 6px;
    display: inline-block;
    margin-bottom: 16px;
}

.pr-success-hint {
    font-size: 13px;
    color: #9ca3af;
    line-height: 1.6;
    margin-bottom: 24px;
}

/* Back to login button (ghost style) */
.login-btn-back {
    width: 100%;
    height: 48px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.login-btn-back:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #374151;
    text-decoration: none;
}

/* ==========================================================================
   Right panel — form
   ========================================================================== */
.login-form-panel {
    width: 50%;
    background: #f1f3f8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px;
    overflow-y: auto;
}

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

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

.login-fimar-badge-sm {
    font-size: 16px;
    padding: 6px 16px;
    background: #1e2a4a;
}

.login-mobile-sep {
    color: #9ca3af;
    font-size: 20px;
    font-weight: 300;
}

.login-mobile-gigue {
    color: #1e2a4a;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: 2px;
}

/* ==========================================================================
   Form heading
   ========================================================================== */
.login-heading {
    font-size: 26px;
    font-weight: 700;
    color: #1e2a4a;
    margin-bottom: 4px;
}

.login-subheading {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 28px;
}

/* ==========================================================================
   Form labels
   ========================================================================== */
.login-form .login-label {
    font-size: 12.5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #374151;
    margin-bottom: 6px;
}

/* ==========================================================================
   Input groups with icons
   ========================================================================== */
.login-input-group {
    position: relative;
    margin-bottom: 20px;
}

.login-input-group .login-input-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    font-size: 16px;
    z-index: 2;
    pointer-events: none;
}

.login-input-group .form-control {
    padding-left: 42px;
    padding-right: 14px;
    height: 48px;
    border-radius: 10px;
    border: 1px solid #d1d5db;
    background: #ffffff;
    font-size: 14px;
    color: #1f2937;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.login-input-group .form-control:focus {
    border-color: #4f7df9;
    box-shadow: 0 0 0 3px rgba(79, 125, 249, 0.15);
    outline: none;
}

.login-input-group .form-control.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

/* Password toggle */
.login-input-group .login-password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    font-size: 16px;
    z-index: 2;
    transition: color 0.2s;
}

.login-input-group .login-password-toggle:hover {
    color: #4b5563;
}

.login-input-group.has-toggle .form-control {
    padding-right: 44px;
}

/* Validation errors */
.login-input-group .invalid-feedback,
.login-input-group .help-block {
    font-size: 12px;
    color: #ef4444;
    margin-top: 4px;
}

/* ==========================================================================
   Remember me + forgot password (same line)
   ========================================================================== */
.login-options-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

/* Custom checkbox */
.login-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.login-checkbox input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    transition: all 0.15s;
    flex-shrink: 0;
}

.login-checkbox input[type="checkbox"]:checked {
    background-color: #4f7df9;
    border-color: #4f7df9;
}

.login-checkbox input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 1px;
    width: 6px;
    height: 10px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.login-checkbox .login-checkbox-label {
    font-size: 13.5px;
    color: #4b5563;
    user-select: none;
}

.login-forgot-link {
    font-size: 13.5px;
    color: #4f7df9;
    text-decoration: none;
    font-weight: 500;
    white-space: nowrap;
}

.login-forgot-link:hover {
    color: #3b6de8;
    text-decoration: underline;
}

/* ==========================================================================
   Submit button
   ========================================================================== */
.login-btn-submit {
    width: 100%;
    height: 48px;
    border-radius: 10px;
    background: #4f7df9;
    border: none;
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 24px;
}

.login-btn-submit:hover {
    background: #3b6de8;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(79, 125, 249, 0.35);
}

.login-btn-submit:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(79, 125, 249, 0.25);
}

/* Spinner on submit */
.login-btn-submit .login-spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: login-spin 0.6s linear infinite;
}

.login-btn-submit.is-loading .login-spinner {
    display: inline-block;
}

.login-btn-submit.is-loading .login-btn-text,
.login-btn-submit.is-loading .login-btn-icon {
    display: none;
}

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

/* ==========================================================================
   Divider "ou continuer avec"
   ========================================================================== */
.login-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.login-divider::before,
.login-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #d1d5db;
}

.login-divider span {
    font-size: 13px;
    color: #9ca3af;
    white-space: nowrap;
}

/* ==========================================================================
   Google button
   ========================================================================== */
.login-btn-google {
    width: 100%;
    height: 48px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #d1d5db;
    color: #374151;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    margin-bottom: 32px;
}

.login-btn-google:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    color: #374151;
    text-decoration: none;
}

.login-btn-google svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Override AuthChoice wrapper styles */
.login-form .auth-clients {
    list-style: none;
    padding: 0;
    margin: 0;
}

.login-form .auth-clients li {
    list-style: none;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.login-footer {
    text-align: center;
    font-size: 12.5px;
    color: #9ca3af;
}

.login-footer a {
    color: #4f7df9;
    text-decoration: none;
}

.login-footer a:hover {
    text-decoration: underline;
}

/* ==========================================================================
   Yii ActiveForm overrides (hide default field wrappers)
   ========================================================================== */
.login-form .form-group {
    margin-bottom: 0;
}

/* Hide Yii's default labels (we use our own) */
.login-form .form-group > label.control-label {
    display: none;
}

/* Error state from Yii validation */
.login-form .form-group.has-error .form-control,
.login-form .form-group .form-control.is-invalid {
    border-color: #ef4444;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.login-form .form-group .help-block.help-block-error:not(:empty) {
    font-size: 12px;
    color: #ef4444;
    margin-top: 4px;
    display: block;
}

/* Hide empty error blocks */
.login-form .form-group .help-block.help-block-error:empty {
    display: none;
}

/* ==========================================================================
   Password new — criteria panel (left panel items)
   ========================================================================== */
.pw-criterion {
    transition: all 0.25s ease;
}

.pw-criterion .pw-criterion-icon {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    flex-shrink: 0;
    transition: all 0.25s ease;
}

.pw-criterion .pw-criterion-icon i {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.3);
}

.pw-criterion.is-valid .pw-criterion-icon {
    background: rgba(16, 185, 129, 0.25);
}

.pw-criterion.is-valid .pw-criterion-icon i {
    color: #34d399;
}

.pw-criterion.is-valid .pw-criterion-icon i::before {
    content: "\f26b"; /* bi-check-lg */
}

.pw-criterion.is-invalid .pw-criterion-icon {
    background: rgba(239, 68, 68, 0.2);
}

.pw-criterion.is-invalid .pw-criterion-icon i {
    color: #f87171;
}

.pw-criterion.is-invalid .pw-criterion-icon i::before {
    content: "\f62a"; /* bi-x */
}

/* ==========================================================================
   Password new — user badge
   ========================================================================== */
.pw-user-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 12px;
    border-radius: 6px;
    background: rgba(79, 125, 249, 0.08);
    color: #4f7df9;
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 24px;
}

.pw-user-badge i {
    font-size: 14px;
    opacity: 0.7;
}

/* ==========================================================================
   Password new — strength meter
   ========================================================================== */
.pw-strength-meter {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
}

.pw-strength-segment {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: #e5e7eb;
    transition: background 0.3s;
}

.pw-strength-meter[data-strength="1"] .pw-strength-segment:nth-child(1) {
    background: #ef4444;
}

.pw-strength-meter[data-strength="2"] .pw-strength-segment:nth-child(1),
.pw-strength-meter[data-strength="2"] .pw-strength-segment:nth-child(2) {
    background: #f59e0b;
}

.pw-strength-meter[data-strength="3"] .pw-strength-segment:nth-child(1),
.pw-strength-meter[data-strength="3"] .pw-strength-segment:nth-child(2),
.pw-strength-meter[data-strength="3"] .pw-strength-segment:nth-child(3) {
    background: #10b981;
}

.pw-strength-meter[data-strength="4"] .pw-strength-segment {
    background: #10b981;
}

.pw-strength-label {
    font-size: 11.5px;
    font-weight: 600;
    margin-bottom: 20px;
    margin-top: -16px;
    text-align: right;
}

.pw-strength-label[data-strength="0"] { color: #9ca3af; }
.pw-strength-label[data-strength="1"] { color: #ef4444; }
.pw-strength-label[data-strength="2"] { color: #f59e0b; }
.pw-strength-label[data-strength="3"] { color: #10b981; }
.pw-strength-label[data-strength="4"] { color: #10b981; }

/* ==========================================================================
   Password new — match indicator
   ========================================================================== */
.pw-match-indicator {
    font-size: 12px;
    margin-top: -14px;
    margin-bottom: 20px;
    display: none;
}

.pw-match-indicator.show { display: block; }
.pw-match-indicator.is-match { color: #10b981; }
.pw-match-indicator.is-mismatch { color: #ef4444; }

/* ==========================================================================
   Password new — mobile criteria (shown inline on mobile)
   ========================================================================== */
.pw-criteria-mobile {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.pw-criteria-mobile .pw-crit-tag {
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    background: #f3f4f6;
    color: #9ca3af;
    transition: all 0.2s;
}

.pw-criteria-mobile .pw-crit-tag.is-valid {
    background: #ecfdf5;
    color: #10b981;
}

.pw-criteria-mobile .pw-crit-tag.is-invalid {
    background: #fef2f2;
    color: #ef4444;
}

/* ==========================================================================
   Password new — success state with countdown
   ========================================================================== */
.pw-success-countdown {
    font-size: 13px;
    color: #9ca3af;
    margin-bottom: 20px;
}

.pw-success-countdown span {
    font-weight: 700;
    color: #4f7df9;
}

/* ==========================================================================
   Responsive — mobile (< 900px)
   ========================================================================== */
@media (max-width: 900px) {
    .login-split {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

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

    .login-form-panel {
        width: 100%;
        min-height: 100vh;
        padding: 32px 24px;
    }

    .login-mobile-brand {
        display: flex;
    }

    /* Mobile: show inline criteria */
    .pw-criteria-mobile {
        display: flex;
    }
}

@media (max-width: 480px) {
    .login-form-panel {
        padding: 24px 16px;
    }

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