/* Login Page - Simple & Elegant Design */

/* ============================================
   1. ROOT VARIABLES
   ============================================ */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --primary-light: #eef2ff;
    --secondary-color: #06b6d4;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    
    --bg-body: linear-gradient(135deg, #eef2ff 0%, #ecfeff 100%);
    --bg-white: #ffffff;
    --border: #e2e8f0;
    --border-focus: #cbd5e1;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    
    --transition: all 0.2s ease;
}

/* ============================================
   2. RESET & BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Tajawal', -apple-system, system-ui, sans-serif;
    background: var(--bg-body);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    direction: rtl;
}

/* ============================================
   3. LAYOUT
   ============================================ */
.login-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 420px;
    background: var(--bg-white);
    border-bottom-left-radius: var(--radius-lg);
    border-bottom-right-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg), 0 0 0 1px rgba(79, 70, 229, 0.1);
    padding: 2.5rem 2rem;
    border-top: 3px solid transparent;
    border-image: linear-gradient(90deg, var(--primary-color), var(--secondary-color)) 1;
    border-image-slice: 1 0 0 0;
}

/* ============================================
   4. LOGO & HEADER
   ============================================ */
.login-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.login-logo img {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-md);
    object-fit: cover;
    box-shadow: var(--shadow-md), 0 0 20px rgba(79, 70, 229, 0.15);
    border: 2px solid rgba(79, 70, 229, 0.1);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.login-header p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* ============================================
   5. ALERTS
   ============================================ */
#alertArea {
    margin-bottom: 1.5rem;
}

.alert {
    padding: 0.875rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: slideDown 0.3s ease;
    margin-bottom: 0.75rem;
}

.alert i {
    font-size: 1.1rem;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ============================================
   6. FORM ELEMENTS
   ============================================ */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-label i {
    color: var(--primary-color);
    font-size: 1rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-white);
    transition: var(--transition);
    outline: none;
    direction: ltr;
    text-align: left;
}

.form-input::placeholder {
    color: var(--text-muted);
}

.form-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-input.error {
    border-color: var(--error);
}

.form-input.error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.error-message {
    font-size: 0.85rem;
    color: var(--error);
    display: none;
}

.error-message.show {
    display: block;
    animation: slideDown 0.2s ease;
}

/* Password Input */
.password-wrapper {
    position: relative;
}


.toggle-password {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.toggle-password:hover {
    color: var(--primary-color);
    background: var(--primary-light);
}

.toggle-password i {
    font-size: 1.1rem;
}

/* ============================================
   7. CHECKBOX & OPTIONS
   ============================================ */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    user-select: none;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.checkbox-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.checkbox-custom {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:checked + .checkbox-custom::after {
    content: '✓';
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
}

.forgot-link {
    color: var(--primary-color);
    font-size: 0.9rem;
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.forgot-link:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* ============================================
   8. BUTTONS
   ============================================ */
.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 0.875rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-hover) 0%, #0891b2 100%);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    
}

.btn-primary.success {
    background: linear-gradient(135deg, var(--success) 0%, #059669 100%);
    opacity: 1;
    cursor: default;
}

.btn-primary.success:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

.btn-secondary {
    background: var(--bg-body);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
}

.btn-loader {
    display: none;
}

.btn-primary.loading .btn-content,
.btn-secondary.loading .btn-content {
    display: none;
}

.btn-primary.loading .btn-loader,
.btn-secondary.loading .btn-loader {
    display: flex;
}

.btn-primary.success .btn-content,
.btn-secondary.success .btn-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary.success .btn-loader,
.btn-secondary.success .btn-loader {
    display: flex;
    align-items: center;
}

.spin {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   9. MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
    animation: fadeIn 0.2s ease;
}

.modal-overlay.show {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    font-size: 1.5rem;
}

.modal-close:hover {
    color: var(--text-primary);
    background: var(--bg-body);
}

.modal-body {
    padding: 1.5rem;
}

.modal-description {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    gap: 0.75rem;
}

.modal-footer .btn-secondary,
.modal-footer .btn-primary {
    flex: 1;
}

/* ============================================
   10. FOOTER
   ============================================ */
.login-footer {
    text-align: center;
    padding: 1.5rem 1rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.login-footer a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-footer a:hover {
    opacity: 0.8;
    text-decoration: underline;
}

/* ============================================
   10.1 FORCE PASSWORD CHANGE MODAL
   ============================================ */
.modal-force {
    z-index: 1001;
}

.modal-force .modal-content {
    max-width: 500px;
}

.modal-header-security {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    padding: 2rem 1.5rem;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.security-icon {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.security-icon i {
    font-size: 1.75rem;
}

.modal-header-security h3 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
}

.security-subtitle {
    margin: 0.25rem 0 0 0;
    font-size: 0.9rem;
    opacity: 0.9;
}

.security-notice {
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: var(--radius-md);
    padding: 1rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.security-notice i {
    color: #92400e;
    font-size: 1.25rem;
    flex-shrink: 0;
    margin-top: 0.125rem;
}

.security-notice p {
    color: #92400e;
    font-size: 0.9rem;
    line-height: 1.6;
    margin: 0;
}

.password-requirements {
    background: var(--bg-body);
    border-radius: var(--radius-md);
    padding: 1rem;
    margin-top: 1rem;
}

.requirements-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0 0 0.75rem 0;
}

.password-requirements ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.password-requirements li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.password-requirements li i {
    color: var(--text-muted);
    font-size: 0.5rem;
}

.password-requirements li.valid i {
    color: var(--success);
}

.password-requirements li.valid {
    color: var(--success);
}

.password-requirements li.valid i::before {
    content: "\F26B";
}

.btn-full {
    width: 100%;
}

/* ============================================
   11. RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
    .login-container {
        padding: 2rem 1.5rem;
    }
    
    .login-header h1 {
        font-size: 1.5rem;
    }
    
    .form-options {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .modal-footer {
        flex-direction: column-reverse;
    }
    
    .modal-footer .btn-secondary,
    .modal-footer .btn-primary {
        width: 100%;
    }
}

@media (max-width: 360px) {
    .login-logo img {
        width: 64px;
        height: 64px;
    }
    
    .login-container {
        padding: 1.5rem 1rem;
    }
}

