/**
 * Modern Login Page Styles v2.1 - Enhanced Vibrant Edition
 * Premium vibrant gradient design with enhanced visual appeal
 * Version: 2.1 - October 2025
 *
 * FIX (2025-12-02): Removed duplicate CSS variables
 * All CSS variables are defined in variables.css
 */

/* ============================================ */
/* NOTE: CSS Variables defined in variables.css */
/* ============================================ */

/* ============================================ */
/* Page Layout */
/* ============================================ */

.login-page {
    position: relative;
    min-height: 100vh;
    overflow-x: hidden;
}

.login-background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

.login-background .gradient-bg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Premium Sea Depth - туманное утро */
    background: linear-gradient(135deg, #F0F7FF 0%, #E8F4FC 50%, #DCE8F5 100%);
    opacity: 1;
}

.login-background .grid-pattern {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Subtle grid pattern - Sea Depth */
    background-image:
        linear-gradient(rgba(30, 58, 95, 0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(30, 58, 95, 0.03) 1px, transparent 1px);
    background-size: 50px 50px;
}

/* ============================================ */
/* Login Container */
/* ============================================ */

.login-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background: var(--color-bg-white);
    border-radius: var(--radius-2xl);
    /* Premium Sea Depth shadow */
    box-shadow: 0 25px 50px -12px rgba(30, 58, 95, 0.12), 0 0 0 1px rgba(30, 58, 95, 0.08);
    overflow: hidden;
    animation: fadeInUp 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(30, 58, 95, 0.1);
    position: relative;
}

.login-container::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: var(--radius-2xl);
    padding: 1px;
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.2) 0%, rgba(44, 82, 130, 0.1) 100%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0.5;
    z-index: -1;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================ */
/* Welcome Section (Left) */
/* ============================================ */

.login-welcome {
    background: var(--gradient-primary);
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

.login-welcome::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(circle at 20% 50%, rgba(255, 255, 255, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.08) 0%, transparent 50%);
    pointer-events: none;
}

.welcome-content {
    position: relative;
    z-index: 1;
}

.welcome-icon {
    width: 90px;
    height: 90px;
    background: rgba(255, 255, 255, 0.25);
    backdrop-filter: blur(12px);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 2rem;
    box-shadow: 0 8px 32px rgba(255, 255, 255, 0.2);
    border: 3px solid rgba(255, 255, 255, 0.3);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    /* 🔧 UX FIX (2026-01-01): Reduced animation duration from 3s to 2s for better UX */
    animation: float 2s ease-in-out infinite;
}

.welcome-icon:hover {
    transform: rotate(-5deg);
    box-shadow: 0 12px 40px rgba(255, 255, 255, 0.3);
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-8px);
    }
}

.welcome-icon i {
    font-size: 2.75rem;
    color: var(--color-bg-white);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

.welcome-title {
    font-size: 2rem;
    font-weight: 700;
    color: var(--color-bg-white);
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

.welcome-subtitle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
    margin-bottom: 2rem;
}

.welcome-features {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.welcome-features .feature-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--color-bg-white);
    font-size: 0.95rem;
}

.welcome-features .feature-item i {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.1rem;
}

/* ============================================ */
/* Form Section (Right) */
/* ============================================ */

.login-form-wrapper {
    padding: 3rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.login-form-header {
    margin-bottom: 2rem;
}

.form-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
    letter-spacing: -0.02em;
}

.form-title i {
    color: var(--color-accent);
}

.form-subtitle {
    font-size: 0.95rem;
    color: var(--color-text-secondary);
    margin: 0;
}

.login-form-body {
    flex: 1;
}

/* ============================================ */
/* Modern Form Controls */
/* ============================================ */

.form-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
}

.form-label i {
    color: var(--color-accent);
}

.modern-input {
    height: 3.25rem;
    border: 2.5px solid #e2e8f0;
    border-radius: var(--radius-lg);
    padding: 0.875rem 1.25rem;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    background: var(--color-bg-white);
    position: relative;
}

.modern-input:hover {
    border-color: var(--color-accent-light);
    background: rgba(30, 58, 95, 0.02);
}

.modern-input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 5px rgba(30, 58, 95, 0.15), 0 4px 12px rgba(30, 58, 95, 0.2);
    background: var(--color-bg-white);
    transform: translateY(-1px);
}

.modern-input::placeholder {
    color: var(--color-text-light);
    font-weight: 400;
}

/* ============================================ */
/* Password Field */
/* ============================================ */

.password-wrapper {
    position: relative;
}

.password-wrapper .modern-input {
    padding-right: 3rem;
}

.password-toggle {
    position: absolute;
    right: 0;
    top: 0;
    height: 100%;
    width: 3rem;
    background: transparent;
    border: none;
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    z-index: 10;
}

.password-toggle i {
    pointer-events: none;
}

.password-toggle:hover {
    color: var(--color-accent);
    background: rgba(30, 58, 95, 0.05);
}

/* 🔧 A11Y FIX (2026-01-01): Added visible focus indicator */
.password-toggle:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    color: var(--color-accent);
}

.password-toggle:focus:not(:focus-visible) {
    outline: none;
}

/* ============================================ */
/* Checkbox */
/* ============================================ */

.modern-checkbox {
    display: flex;
    align-items: center;
}

.modern-checkbox .form-check-input {
    width: 1.25rem;
    height: 1.25rem;
    border: 2px solid #e2e8f0 !important;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-color: #ffffff !important;
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.modern-checkbox .form-check-input:hover {
    border-color: var(--color-accent);
    background-color: rgba(30, 58, 95, 0.05);
}

.modern-checkbox .form-check-input:checked {
    background-color: #1E3A5F !important;
    border-color: #1E3A5F !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3e%3cpath fill='none' stroke='%23ffffff' stroke-linecap='round' stroke-linejoin='round' stroke-width='3.5' d='M6 10l3 3l6-6'/%3e%3c/svg%3e") !important;
    background-repeat: no-repeat !important;
    background-position: center !important;
    background-size: 75% 75% !important;
    box-shadow: 0 0 0 2px rgba(30, 58, 95, 0.2) !important;
}

.modern-checkbox .form-check-input:checked:hover {
    background-color: #2C5282 !important;
    border-color: #2C5282 !important;
    box-shadow: 0 0 0 2px rgba(30, 58, 95, 0.3) !important;
}

/* 🔧 A11Y FIX (2026-01-01): Keep visible focus for keyboard users */
.modern-checkbox .form-check-input:focus {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.25);
}

.modern-checkbox .form-check-input:focus:not(:focus-visible) {
    /* Hide outline for mouse clicks but keep for keyboard */
    outline: none;
    box-shadow: none;
}

.modern-checkbox .form-check-input:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 3px rgba(44, 82, 130, 0.25);
}

.modern-checkbox .form-check-label {
    margin-left: 0.5rem;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
    cursor: pointer;
}

/* ============================================ */
/* Submit Button */
/* ============================================ */

.btn-login-primary {
    width: 100%;
    height: 3.75rem;
    background: var(--gradient-primary);
    border: 3px solid transparent;
    border-radius: var(--radius-lg);
    color: var(--color-bg-white);
    font-size: 1.05rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-colored);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    margin-bottom: 1.5rem;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-login-primary::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-login-primary:hover:not(:disabled)::before {
    width: 400px;
    height: 400px;
}

.btn-login-primary:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 16px 40px rgba(30, 58, 95, 0.5);
    border-color: rgba(255, 255, 255, 0.3);
}

.btn-login-primary:active:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-colored);
}

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

.btn-login-primary:focus {
    outline: none;
    box-shadow: 0 0 0 5px rgba(30, 58, 95, 0.25), var(--shadow-colored);
}

/* ============================================ */
/* Register Link */
/* ============================================ */

.register-link {
    text-align: center;
    margin-bottom: 1.5rem;
}

.register-link p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--color-text-secondary);
}

.register-link a {
    color: var(--color-accent);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    margin-left: 0.25rem;
}

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

/* ============================================ */
/* Security Notice */
/* ============================================ */

.security-notice {
    display: flex;
    gap: 1rem;
    padding: 1.25rem;
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.08), rgba(44, 82, 130, 0.08));
    border-radius: var(--radius-lg);
    border-left: 5px solid var(--color-accent);
    border: 2px solid rgba(30, 58, 95, 0.2);
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.1);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.security-notice:hover {
    transform: translateX(4px);
    box-shadow: 0 6px 20px rgba(30, 58, 95, 0.2);
    border-color: rgba(30, 58, 95, 0.4);
}

.notice-icon {
    flex-shrink: 0;
    width: 2.75rem;
    height: 2.75rem;
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.15), rgba(44, 82, 130, 0.15));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(30, 58, 95, 0.2);
    border: 2px solid rgba(30, 58, 95, 0.3);
    transition: all 0.3s ease;
}

.security-notice:hover .notice-icon {
    transform: rotate(-5deg);
}

.notice-icon i {
    color: var(--color-accent);
    font-size: 1.2rem;
    filter: drop-shadow(0 2px 4px rgba(30, 58, 95, 0.3));
}

.notice-text {
    flex: 1;
}

.notice-text strong {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: 0.25rem;
}

.notice-text p {
    font-size: 0.85rem;
    color: var(--color-text-secondary);
    margin: 0;
    line-height: 1.5;
}

/* ============================================ */
/* Alert Messages */
/* ============================================ */

.alert {
    border-radius: var(--radius-lg);
    border: 2.5px solid;
    padding: 1.125rem 1.5rem;
    margin-bottom: 1.5rem;
    animation: fadeIn 0.3s ease, slideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    font-weight: 600;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.alert::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
}

.alert-danger {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.12), rgba(248, 113, 113, 0.12));
    color: #b91c1c;
    border-color: rgba(239, 68, 68, 0.3);
}

.alert-danger::before {
    background: linear-gradient(180deg, #ef4444, #f87171);
}

.alert-info {
    background: linear-gradient(135deg, rgba(30, 58, 95, 0.12), rgba(44, 82, 130, 0.12));
    color: #1E3A5F;
    border-color: rgba(30, 58, 95, 0.3);
}

.alert-info::before {
    background: linear-gradient(180deg, #1E3A5F, #2C5282);
}

.alert-success {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.12), rgba(52, 211, 153, 0.12));
    color: #047857;
    border-color: rgba(16, 185, 129, 0.3);
}

.alert-success::before {
    background: linear-gradient(180deg, #10b981, #34d399);
}

@keyframes slideIn {
    from {
        transform: translateX(-20px);
    }
    to {
        transform: translateX(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================ */
/* Form Validation */
/* ============================================ */

.invalid-feedback {
    display: none;
    font-size: 0.85rem;
    color: var(--color-error);
    margin-top: 0.5rem;
}

.was-validated .form-control:invalid ~ .invalid-feedback,
.form-control.is-invalid ~ .invalid-feedback {
    display: block;
    animation: fadeIn 0.3s ease;
}

.was-validated .form-control:invalid,
.form-control.is-invalid {
    border-color: var(--color-error);
}

.was-validated .form-control:invalid:focus,
.form-control.is-invalid:focus {
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.1);
}

.was-validated .form-control:valid,
.form-control.is-valid {
    border-color: var(--color-success);
}

.was-validated .form-control:valid:focus,
.form-control.is-valid:focus {
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.1);
}

/* ============================================ */
/* Loading State */
/* ============================================ */

#btnSpinner {
    display: none;
}

.btn-login-primary:disabled #btnSpinner {
    display: inline-block;
}

/* ============================================ */
/* Responsive Design */
/* ============================================ */

/* Tablet */
@media (max-width: 991px) {
    .login-container {
        grid-template-columns: 1fr;
    }

    .login-welcome {
        padding: 2.5rem;
    }

    .login-form-wrapper {
        padding: 2.5rem;
    }

    .welcome-title {
        font-size: 1.75rem;
    }

    .form-title {
        font-size: 1.5rem;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .login-welcome {
        padding: 2rem;
    }

    .login-form-wrapper {
        padding: 2rem;
    }

    .welcome-icon {
        width: 60px;
        height: 60px;
        margin-bottom: 1.5rem;
    }

    .welcome-icon i {
        font-size: 2rem;
    }

    .welcome-title {
        font-size: 1.5rem;
    }

    .welcome-subtitle {
        font-size: 0.9rem;
    }

    .form-title {
        font-size: 1.35rem;
    }

    .modern-input {
        height: 2.75rem;
    }

    .btn-login-primary {
        height: 3rem;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .login-welcome {
        padding: 1.5rem;
    }

    .login-form-wrapper {
        padding: 1.5rem;
    }

    .welcome-features {
        gap: 0.75rem;
    }

    .welcome-features .feature-item {
        font-size: 0.85rem;
    }
}

/* ============================================ */
/* Accessibility */
/* ============================================ */

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast support */
@media (prefers-contrast: high) {
    .modern-input {
        border-width: 3px;
    }

    .btn-login-primary {
        border: 3px solid var(--color-bg-white);
    }
}

/* Focus visible for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--color-accent);
    outline-offset: 2px;
}

/* Password Strength Progress Bar - CSP Compliant */
.password-strength-progress {
    height: 5px;
    background-color: #e2e8f0;
}

.password-strength-bar {
    width: 0%;
}

/* Terms Link - CSP Compliant */
.terms-link {
    color: var(--color-accent);
}

/* Terms Modal - CSP Compliant */
.terms-modal-content {
    border-radius: var(--radius-xl);
    border: none;
}

.terms-modal-header {
    background: var(--gradient-primary);
    color: white;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.terms-modal-body {
    padding: 2rem;
}

.terms-heading {
    color: var(--color-text-primary);
    font-weight: 600;
    margin-top: 1.5rem;
}

.terms-heading-first {
    margin-top: 0;
}

.terms-text {
    color: var(--color-text-secondary);
}

.terms-text-last {
    margin-bottom: 0;
}

.terms-list {
    color: var(--color-text-secondary);
}

.terms-modal-footer {
    background: var(--color-bg-light);
    border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.terms-close-btn {
    border-radius: var(--radius-md);
}

.terms-accept-btn {
    width: auto;
    height: auto;
    padding: 0.5rem 1.5rem;
    margin-bottom: 0;
}

/* SECURITY FIX: Input ripple effect using CSS variables */
.input-ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(30, 58, 95, 0.5);
    transform: scale(0);
    animation: ripple-animation 0.6s ease-out;
    pointer-events: none;
    width: var(--ripple-size, 100px);
    height: var(--ripple-size, 100px);
    left: var(--ripple-x, 0);
    top: var(--ripple-y, 0);
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}
