:root {
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --primary: #111827;
    --primary-hover: #1f2937;
    --border: #e5e7eb;
    --border-focus: #9ca3af;
    --error: #dc2626;
    --error-bg: #fef2f2;
    --error-border: #fecaca;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Cairo', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    background-attachment: fixed;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 20% 50%, rgba(120, 119, 198, 0.03) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(255, 255, 255, 0.05) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* Login Container */
.login-container {
    width: 100%;
    max-width: 440px;
    position: relative;
    z-index: 1;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Login Card */
.login-card {
    background: #ffffff;
    border-radius: 20px;
    padding: 3.5rem 2.75rem;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.05),
        0 10px 15px -3px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(0, 0, 0, 0.02);
    border: 1px solid rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(0, 0, 0, 0.05), transparent);
}

/* Logo Section */
.logo-section {
    text-align: center;
    margin-bottom: 2.5rem;
}

.logo-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
    border-radius: 16px;
    margin-bottom: 1.75rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    position: relative;
    animation: logoFadeIn 0.6s ease-out;
}

.logo-wrapper::after {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.logo-wrapper:hover {
    transform: translateY(-2px);
    box-shadow: 
        0 8px 12px -2px rgba(0, 0, 0, 0.15),
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

.logo-wrapper:hover::after {
    opacity: 1;
}

.logo-wrapper i {
    font-size: 2rem;
    color: #ffffff;
    font-weight: 600;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2));
}

@keyframes logoFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.brand-title {
    font-size: 1.875rem;
    font-weight: 800;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
    letter-spacing: -0.03em;
    line-height: 1.2;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.brand-subtitle {
    font-size: 0.9375rem;
    color: var(--gray-500);
    font-weight: 500;
    line-height: 1.5;
    letter-spacing: 0.01em;
}

/* Form Styles */
.login-form {
    margin-top: 0;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group:last-of-type {
    margin-bottom: 1.75rem;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    letter-spacing: 0;
    line-height: 1.5;
}

.form-label .required {
    color: var(--error);
    margin-right: 0.25rem;
    font-weight: 600;
}

.input-wrapper {
    position: relative;
}

.form-input {
    width: 100%;
    padding: 0.875rem 2.75rem 0.875rem 2.75rem;
    font-size: 0.9375rem;
    color: var(--gray-900);
    background: var(--gray-50);
    border: 1.5px solid var(--border);
    border-radius: 10px;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: inherit;
    line-height: 1.5;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.form-input::placeholder {
    color: var(--gray-400);
    font-weight: 400;
}

.form-input:focus {
    outline: none;
    border-color: var(--gray-600);
    background: #ffffff;
    box-shadow: 
        0 0 0 3px rgba(17, 24, 39, 0.08),
        inset 0 1px 2px rgba(0, 0, 0, 0.02);
    transform: translateY(-1px);
}

.form-input:hover:not(:focus) {
    border-color: var(--gray-300);
    background: #ffffff;
}

.input-wrapper.focused .input-icon {
    color: var(--gray-600);
    transform: translateY(-50%) scale(1.1);
}

.input-wrapper.has-value .input-icon {
    color: var(--gray-600);
}

.input-wrapper.has-error .form-input {
    border-color: var(--error);
}

.input-wrapper.has-error .input-icon {
    color: var(--error);
}

.input-wrapper.has-success .form-input {
    border-color: #10b981;
}

.input-wrapper.has-success .input-icon {
    color: #10b981;
}

.input-icon {
    position: absolute;
    right: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
    font-size: 0.9375rem;
    pointer-events: none;
    transition: all 0.2s ease;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-input:focus + .input-icon {
    color: var(--gray-600);
}

.password-toggle {
    position: absolute;
    left: 0.875rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    width: 18px;
    height: 18px;
}

.password-toggle:hover {
    color: var(--gray-600);
    transform: translateY(-50%) scale(1.1);
}

.password-toggle:active {
    transform: translateY(-50%) scale(0.95);
}

.password-toggle:focus {
    outline: none;
    color: var(--gray-600);
}

.password-toggle i {
    font-size: 0.9375rem;
}

.error-text {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--error);
    font-weight: 500;
    line-height: 1.5;
}

/* Error Alert */
.error-alert {
    background: linear-gradient(135deg, var(--error-bg) 0%, #fef1f1 100%);
    border: 1px solid var(--error-border);
    border-right-width: 3px;
    color: var(--error);
    padding: 1rem 1.25rem;
    border-radius: 10px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    box-shadow: 0 1px 3px rgba(220, 38, 38, 0.1);
}

.error-alert i {
    font-size: 1rem;
    margin-top: 0.125rem;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.error-alert-content {
    flex: 1;
}

.error-alert-content p {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
}

/* Form Options */
.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.75rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.checkbox-wrapper {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.checkbox-wrapper input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--gray-900);
    margin: 0;
}

.checkbox-wrapper label {
    font-size: 0.875rem;
    color: var(--gray-600);
    cursor: pointer;
    user-select: none;
    font-weight: 500;
    line-height: 1.5;
    margin: 0;
    transition: color 0.15s ease;
}

.checkbox-wrapper:hover label {
    color: var(--gray-700);
}

.forgot-link {
    font-size: 0.875rem;
    color: var(--gray-600);
    text-decoration: none;
    font-weight: 600;
    transition: all 0.15s ease;
    line-height: 1.5;
    position: relative;
}

.forgot-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    right: 0;
    width: 0;
    height: 2px;
    background: var(--gray-900);
    transition: width 0.2s ease;
}

.forgot-link:hover {
    color: var(--gray-900);
}

.forgot-link:hover::after {
    width: 100%;
}

/* Submit Button */
.submit-btn {
    width: 100%;
    padding: 1rem 1.5rem;
    background: linear-gradient(135deg, var(--gray-900) 0%, var(--gray-800) 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 0.9375rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.625rem;
    font-family: inherit;
    line-height: 1.5;
    box-shadow: 
        0 4px 6px -1px rgba(0, 0, 0, 0.1),
        0 2px 4px -1px rgba(0, 0, 0, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.1);
    letter-spacing: 0.01em;
}

.submit-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.submit-btn:hover::before {
    left: 100%;
}

.submit-btn:hover {
    background: linear-gradient(135deg, var(--gray-800) 0%, var(--gray-700) 100%);
    box-shadow: 
        0 6px 8px -1px rgba(0, 0, 0, 0.12),
        0 4px 6px -1px rgba(0, 0, 0, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.submit-btn:active {
    transform: scale(0.98);
}

.submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.submit-btn.pulse {
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(17, 24, 39, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(17, 24, 39, 0);
    }
}

.submit-btn i {
    font-size: 0.9375rem;
    margin: 0;
}

/* Loading State */
.submit-btn.loading {
    pointer-events: none;
}

.submit-btn.loading .btn-text {
    opacity: 0;
}

.submit-btn.loading .btn-spinner {
    opacity: 1;
}

.btn-spinner {
    position: absolute;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.btn-spinner i {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Success Message */
.success-message {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-right-width: 3px;
    color: #166534;
    padding: 0.875rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: none;
    align-items: flex-start;
    gap: 0.75rem;
    animation: slideDown 0.3s ease-out;
}

.success-message.show {
    display: flex;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.success-message i {
    font-size: 1rem;
    margin-top: 0.125rem;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-message-content {
    flex: 1;
}

.success-message-content p {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.5;
}

/* Input Validation Feedback */
.validation-feedback {
    display: none;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.5;
    animation: fadeIn 0.2s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.validation-feedback.show {
    display: block;
}

.validation-feedback.success {
    color: #166534;
}

.validation-feedback.error {
    color: var(--error);
}

/* Shake animation for errors */
.shake {
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
    20%, 40%, 60%, 80% { transform: translateX(4px); }
}

/* Responsive Design */
@media (max-width: 640px) {
    body {
        padding: 1rem;
    }

    .login-card {
        padding: 2.5rem 2rem;
        border-radius: 12px;
    }

    .logo-wrapper {
        width: 56px;
        height: 56px;
        margin-bottom: 1.25rem;
    }

    .logo-wrapper i {
        font-size: 1.5rem;
    }

    .brand-title {
        font-size: 1.625rem;
        margin-bottom: 0.25rem;
    }

    .brand-subtitle {
        font-size: 0.875rem;
    }
    
    .form-group {
        margin-bottom: 1.25rem;
    }

    .form-group:last-of-type {
        margin-bottom: 1.5rem;
    }
    
    .form-options {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 1.5rem;
    }
}

@media (max-height: 700px) {
    body {
        align-items: flex-start;
        padding-top: 2rem;
    }

    .login-card {
        padding: 2rem 2rem;
    }

    .logo-section {
        margin-bottom: 2rem;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus Visible */
.form-input:focus-visible,
.submit-btn:focus-visible,
.password-toggle:focus-visible,
.checkbox-wrapper input:focus-visible {
    outline: 2px solid var(--gray-900);
    outline-offset: 2px;
}

.forgot-link:focus-visible {
    outline: 2px solid var(--gray-900);
    outline-offset: 2px;
    border-radius: 2px;
}

