/* ============================================
   AUTHENTICATION PAGES - MODERN THEME
   Description: Styling for Login, Forgot Password, Verify Code, and Reset Password pages
   Theme: Professional Government Web Application
   ============================================ */

/* Import Cairo font from Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

/* ============================================
   ROOT VARIABLES - COLOR PALETTE
   ============================================ */
:root {
    /* Primary Colors */
    --primary-blue: #0369A1;
    --primary-blue-dark: #025a83;
    --primary-blue-light: rgba(3, 105, 161, 0.1);

    /* Accent Colors */
    --accent-green: #10B981;
    --accent-green-dark: #059669;

    /* Background & Surface */
    --background: #F9FAFB;
    --card: #FFFFFF;
    --muted: #F1F5F9;
    --surface: #F8FAFC;

    /* Borders & Dividers */
    --border: #E2E8F0;
    --border-light: #F1F5F9;

    /* Text Colors */
    --heading: #1E293B;
    --body-text: #64748B;
    --text-light: #94A3B8;
    --text-dark: #0F172A;

    /* Status Colors */
    --error: #EF4444;
    --error-light: #FEE2E2;
    --error-border: #FCA5A5;
    --error-dark: #991B1B;

    --success: #10B981;
    --success-light: #D1FAE5;
    --success-border: #6EE7B7;
    --success-dark: #065F46;

    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --warning-border: #FCD34D;
    --warning-dark: #92400E;

    --info: #3B82F6;
    --info-light: #DBEAFE;
    --info-border: #93C5FD;
    --info-dark: #1E3A8A;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    /* Border Radius */
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ============================================
   GLOBAL RESET & BASE STYLES
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    direction: rtl;
    text-align: right;
    background: linear-gradient(135deg, #F9FAFB 0%, #E0F2FE 100%);
    color: var(--body-text);
    min-height: 100vh;
    max-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    position: relative;
    overflow: hidden;
}

/* Decorative Background Elements */
body::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 600px;
    height: 600px;
    background: radial-gradient(circle, rgba(3, 105, 161, 0.05) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

body::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -5%;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.03) 0%, transparent 70%);
    border-radius: 50%;
    pointer-events: none;
}

/* ============================================
   AUTH CONTAINER & CARD
   ============================================ */
.auth-container {
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 16px);
    margin: 0 auto;
    position: relative;
    z-index: 1;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Custom scrollbar for auth container */
.auth-container::-webkit-scrollbar {
    width: 6px;
}

.auth-container::-webkit-scrollbar-track {
    background: transparent;
}

.auth-container::-webkit-scrollbar-thumb {
    background: var(--primary-blue);
    border-radius: var(--radius-full);
}

.auth-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-blue-dark);
}

.auth-card {
    background: var(--card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    padding: 20px 30px;
    margin-bottom: 8px;
    border: 1px solid var(--border-light);
    position: relative;
    overflow: hidden;
}

/* Card decorative top border */
.auth-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-blue) 0%, var(--accent-green) 100%);
}

/* ============================================
   LOGO & HEADER SECTION
   ============================================ */
.logo-container {
    text-align: center;
    margin-bottom: 16px;
}

.logo {
    width: 70px;
    height: 70px;
    margin-bottom: 12px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    object-fit: cover;
    border: 2px solid var(--border-light);
    animation: logoRotate 1s ease-in-out;
}

.system-title {
    color: var(--heading);
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 6px;
    line-height: 1.2;
    letter-spacing: -0.5px;
}

.system-subtitle {
    color: var(--body-text);
    font-size: 13px;
    font-weight: 400;
    line-height: 1.4;
    margin-bottom: 4px;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
    margin-bottom: 14px;
}

.form-label {
    display: block;
    color: var(--heading);
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    letter-spacing: -0.2px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: 'Cairo', sans-serif;
    font-size: 14px;
    color: var(--heading);
    background-color: var(--surface);
    transition: all var(--transition-base);
    direction: rtl;
    text-align: right;
}

.form-control:hover {
    border-color: var(--primary-blue);
    background-color: var(--card);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-blue);
    background-color: var(--card);
    box-shadow: 0 0 0 4px var(--primary-blue-light);
    transform: translateY(-1px);
}

.form-control::placeholder {
    color: var(--text-light);
    opacity: 0.8;
}

.form-control.text-center {
    text-align: center;
}

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

.input-icon-wrapper .form-control {
    padding-right: 48px;
}

.input-icon-wrapper .input-icon {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 18px;
    pointer-events: none;
}

.form-control:focus ~ .input-icon {
    color: var(--primary-blue);
}

/* Password Toggle */
.password-toggle-container {
    position: relative;
}

.password-toggle {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.password-toggle:hover {
    color: var(--primary-blue);
    background-color: var(--primary-blue-light);
}

.password-toggle svg,
.password-toggle i {
    width: 20px;
    height: 20px;
}

/* Form Helper Text */
.form-text-helper {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--body-text);
    line-height: 1.5;
}

.form-text-helper i {
    margin-top: 2px;
    font-size: 14px;
    color: var(--info);
    flex-shrink: 0;
}

.form-text.text-muted {
    display: block;
    margin-top: 8px;
    font-size: 13px;
    color: var(--body-text);
}

/* Validation Errors */
.text-danger {
    color: var(--error) !important;
    font-size: 13px;
    margin-top: 6px;
    display: block;
    font-weight: 500;
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    width: 100%;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-family: 'Cairo', sans-serif;
    position: relative;
    overflow: hidden;
}

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

.btn:hover::before {
    width: 300px;
    height: 300px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-blue) 0%, #0284C7 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(3, 105, 161, 0.25);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--primary-blue-dark) 0%, var(--primary-blue) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(3, 105, 161, 0.35);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: var(--muted);
    color: var(--text-light);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background-color: transparent;
    color: var(--primary-blue);
    border: 2px solid var(--border);
}

.btn-secondary:hover {
    background-color: var(--muted);
    border-color: var(--primary-blue);
    transform: translateY(-1px);
}

/* ============================================
   LINKS
   ============================================ */
.forgot-password-link {
    display: block;
    text-align: left;
    color: var(--primary-blue);
    font-size: 12px;
    text-decoration: none;
    margin-top: 6px;
    transition: all var(--transition-fast);
    font-weight: 500;
}

.forgot-password-link:hover {
    color: var(--primary-blue-dark);
    text-decoration: underline;
}

.back-to-login {
    text-align: center;
    margin-top: 12px;
}

.back-to-login a {
    color: var(--primary-blue);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.back-to-login a:hover {
    background-color: var(--primary-blue-light);
    text-decoration: none;
}

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

/* ============================================
   ALERTS & NOTIFICATIONS
   ============================================ */
.alert {
    padding: 10px 12px;
    border-radius: var(--radius);
    margin-bottom: 14px;
    font-size: 12px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
    border: 1px solid;
    font-weight: 500;
    line-height: 1.4;
}

.alert i {
    margin-top: 2px;
    font-size: 18px;
    flex-shrink: 0;
}

.alert ul {
    margin: 0;
    padding-right: 20px;
}

.alert li {
    margin-bottom: 4px;
}

.alert li:last-child {
    margin-bottom: 0;
}

.alert-danger {
    background-color: var(--error-light);
    border-color: var(--error-border);
    color: var(--error-dark);
}

.alert-success {
    background-color: var(--success-light);
    border-color: var(--success-border);
    color: var(--success-dark);
}

.alert-info {
    background-color: var(--info-light);
    border-color: var(--info-border);
    color: var(--info-dark);
}

.alert-warning {
    background-color: var(--warning-light);
    border-color: var(--warning-border);
    color: var(--warning-dark);
}

/* ============================================
   FOOTER
   ============================================ */
.footer-text {
    text-align: center;
    color: var(--body-text);
    font-size: 12px;
    margin-top: 0;
    margin-bottom: 0;
    font-weight: 500;
    letter-spacing: 0.2px;
}

/* ============================================
   LOADING SPINNER
   ============================================ */
.spinner {
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   VERIFICATION CODE INPUT
   ============================================ */
.code-input-container {
    margin: 24px 0;
}

.verification-code-input {
    font-size: 32px !important;
    letter-spacing: 12px !important;
    font-family: 'Courier New', monospace !important;
    font-weight: 700 !important;
    text-align: center !important;
    padding: 20px 16px !important;
    background: linear-gradient(135deg, var(--surface) 0%, var(--card) 100%) !important;
}

/* ============================================
   SECURITY BADGE
   ============================================ */
.security-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    background: linear-gradient(135deg, var(--success-light) 0%, var(--info-light) 100%);
    border: 1px solid var(--success-border);
    border-radius: var(--radius-full);
    font-size: 10px;
    color: var(--success-dark);
    font-weight: 600;
    margin: 8px auto 0;
}

.security-badge i {
    font-size: 14px;
}

/* ============================================
   DIVIDER
   ============================================ */
.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 12px 0;
}

.divider::before,
.divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border);
}

.divider:not(:empty)::before {
    margin-left: 12px;
}

.divider:not(:empty)::after {
    margin-right: 12px;
}

.divider span {
    color: var(--text-light);
    font-size: 13px;
    font-weight: 500;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 576px) {
    body {
        padding: 4px;
    }

    .auth-container {
        max-width: 100%;
        max-height: calc(100vh - 8px);
    }

    .auth-card {
        padding: 16px;
        margin-bottom: 4px;
    }

    .logo {
        width: 60px;
        height: 60px;
        margin-bottom: 8px;
    }

    .logo-container {
        margin-bottom: 12px;
    }

    .system-title {
        font-size: 18px;
        margin-bottom: 4px;
    }

    .system-subtitle {
        font-size: 12px;
        margin-bottom: 2px;
    }

    .form-control {
        padding: 9px 12px;
        font-size: 14px;
    }

    .btn {
        padding: 9px 16px;
        font-size: 13px;
    }

    .form-group {
        margin-bottom: 12px;
    }

    .form-label {
        font-size: 12px;
        margin-bottom: 4px;
    }

    .alert {
        padding: 8px 10px;
        font-size: 11px;
        margin-bottom: 12px;
    }

    .verification-code-input {
        font-size: 24px !important;
        letter-spacing: 8px !important;
        padding: 12px !important;
    }
}

@media (max-width: 400px) {
    body {
        padding: 2px;
    }

    .auth-card {
        padding: 14px;
    }

    .logo {
        width: 50px;
        height: 50px;
    }

    .system-title {
        font-size: 16px;
    }

    .system-subtitle {
        font-size: 11px;
    }

    .form-group {
        margin-bottom: 10px;
    }
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes logoRotate {
    0% {
        transform: rotate(0deg) scale(0.8);
        opacity: 0;
    }
    50% {
        transform: rotate(180deg) scale(1.1);
    }
    100% {
        transform: rotate(360deg) scale(1);
        opacity: 1;
    }
}

.auth-card {
    animation: fadeIn 0.5s ease;
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.form-control:focus-visible,
.btn:focus-visible,
a:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .form-control {
        border-width: 2px;
    }

    .btn {
        border: 2px solid currentColor;
    }
}

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

    .logo {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* Dark mode support (if needed in future) */
@media (prefers-color-scheme: dark) {
    /* Dark mode styles can be added here if required */
}
