/* نظام المصادقة - تصميم CSS */

/* متغيرات الألوان والخصائص */
:root {
    --auth-primary: #4A90E2;
    --auth-secondary: #F39C12;
    --auth-success: #27AE60;
    --auth-danger: #E74C3C;
    --auth-warning: #F39C12;
    --auth-purple: #8E44AD;
    --auth-gold: #F1C40F;
    --auth-dark: #2C3E50;
    --auth-light: #7F8C8D;
    --auth-glass: rgba(255, 255, 255, 0.1);
    --auth-radius: 15px;
    --auth-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    --auth-transition: all 0.3s ease;
}

/* التصميم الأساسي للمصادقة */
.auth-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    font-family: 'Cairo', 'Segoe UI', sans-serif;
    direction: rtl;
}

.auth-container {
    background: white;
    border-radius: 20px;
    box-shadow: var(--auth-shadow);
    overflow: hidden;
    width: 100%;
    max-width: 500px;
    animation: authSlideUp 0.6s ease;
    position: relative;
}

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

/* رأس نظام المصادقة */
.auth-header {
    background: linear-gradient(135deg, var(--auth-primary), var(--auth-purple));
    color: white;
    padding: 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.auth-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><defs><pattern id="castle" patternUnits="userSpaceOnUse" width="20" height="20"><path d="M0 20L10 10L20 20L20 0L0 0Z" fill="rgba(255,255,255,0.05)"/></pattern></defs><rect width="100" height="100" fill="url(%23castle)"/></svg>');
    opacity: 0.3;
}

.auth-header * {
    position: relative;
    z-index: 1;
}

.auth-logo-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: var(--auth-gold);
    animation: authLogoFloat 3s ease-in-out infinite;
}

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

.auth-title {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    font-weight: 900;
    background: linear-gradient(45deg, white, var(--auth-gold));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.auth-subtitle {
    opacity: 0.9;
    font-size: 1.1rem;
}

/* تبويبات نظام المصادقة */
.auth-tabs {
    display: flex;
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.auth-tab-button {
    flex: 1;
    padding: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font-weight: 600;
    color: var(--auth-light);
    transition: var(--auth-transition);
    position: relative;
    font-size: 1rem;
}

.auth-tab-button:hover {
    background: rgba(74, 144, 226, 0.05);
    color: var(--auth-primary);
}

.auth-tab-button.active {
    color: var(--auth-primary);
    background: white;
}

.auth-tab-button.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--auth-primary), var(--auth-purple));
    animation: authTabSlide 0.3s ease;
}

@keyframes authTabSlide {
    from { width: 0; left: 50%; }
    to { width: 100%; left: 0; }
}

/* نماذج المصادقة */
.auth-form {
    padding: 2rem;
    display: none;
    animation: authFormFadeIn 0.4s ease;
}

.auth-form.active {
    display: block;
}

@keyframes authFormFadeIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.auth-form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.auth-form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--auth-dark);
    font-size: 0.95rem;
}

.auth-form-label i {
    margin-left: 0.5rem;
    color: var(--auth-primary);
}

.auth-form-input {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: var(--auth-radius);
    font-size: 1rem;
    transition: var(--auth-transition);
    direction: rtl;
    background: white;
}

.auth-form-input:focus {
    outline: none;
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
    transform: translateY(-2px);
}

.auth-form-input:invalid {
    border-color: var(--auth-danger);
}

.auth-form-input:valid {
    border-color: var(--auth-success);
}

/* إدخال كلمة المرور */
.auth-password-group {
    position: relative;
}

.auth-password-toggle {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    color: var(--auth-light);
    font-size: 1rem;
    transition: var(--auth-transition);
    z-index: 2;
}

.auth-password-toggle:hover {
    color: var(--auth-primary);
    transform: translateY(-50%) scale(1.1);
}

/* اختيار العمر والجنس */
.auth-form-select {
    width: 100%;
    padding: 1rem;
    border: 2px solid #e9ecef;
    border-radius: var(--auth-radius);
    font-size: 1rem;
    background: white;
    cursor: pointer;
    transition: var(--auth-transition);
    direction: rtl;
}

.auth-form-select:focus {
    outline: none;
    border-color: var(--auth-primary);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* تحذيرات وإشعارات */
.auth-age-warning {
    background: linear-gradient(135deg, #fff3cd, #ffeaa7);
    border: 1px solid #ffeaa7;
    border-radius: var(--auth-radius);
    padding: 1.5rem;
    margin: 1rem 0;
    display: none;
    animation: authWarningSlide 0.4s ease;
}

.auth-age-warning.show {
    display: block;
}

@keyframes authWarningSlide {
    from {
        opacity: 0;
        max-height: 0;
        padding: 0 1.5rem;
    }
    to {
        opacity: 1;
        max-height: 200px;
        padding: 1.5rem;
    }
}

.auth-age-warning h4 {
    color: #856404;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
}

.auth-age-warning p {
    color: #856404;
    line-height: 1.6;
    margin: 0;
}

/* قسم ولي الأمر */
.auth-guardian-section {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-radius: var(--auth-radius);
    padding: 2rem;
    margin: 1.5rem 0;
    display: none;
    border: 2px solid #dee2e6;
    animation: authGuardianSlide 0.5s ease;
}

.auth-guardian-section.show {
    display: block;
}

@keyframes authGuardianSlide {
    from {
        opacity: 0;
        transform: translateY(-20px);
        max-height: 0;
        padding: 0 2rem;
    }
    to {
        opacity: 1;
        transform: translateY(0);
        max-height: 600px;
        padding: 2rem;
    }
}

.auth-guardian-section h4 {
    color: var(--auth-primary);
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.2rem;
    font-weight: 700;
}

/* مربعات الاختيار */
.auth-checkbox-group {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(74, 144, 226, 0.05);
    border-radius: var(--auth-radius);
    border: 1px solid rgba(74, 144, 226, 0.1);
}

.auth-checkbox-input {
    margin-top: 0.25rem;
    transform: scale(1.2);
    accent-color: var(--auth-primary);
}

.auth-checkbox-label {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--auth-dark);
    cursor: pointer;
}

.auth-checkbox-label a {
    color: var(--auth-primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-checkbox-label a:hover {
    text-decoration: underline;
}

/* معلومات رمز الدخول */
.auth-access-code-info {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border: 1px solid #90caf9;
    border-radius: var(--auth-radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    position: relative;
    overflow: hidden;
}

.auth-access-code-info::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="2" fill="rgba(21,101,192,0.1)"/></svg>');
    opacity: 0.3;
}

.auth-access-code-info * {
    position: relative;
    z-index: 1;
}

.auth-access-code-info h5 {
    color: #1565c0;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
}

.auth-access-code-info p {
    color: #1565c0;
    line-height: 1.6;
    margin: 0;
}

/* أزرار الإرسال */
.auth-submit-btn {
    width: 100%;
    padding: 1.2rem;
    background: linear-gradient(135deg, var(--auth-primary), var(--auth-purple));
    color: white;
    border: none;
    border-radius: var(--auth-radius);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--auth-transition);
    margin-top: 1.5rem;
    position: relative;
    overflow: hidden;
}

.auth-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;
}

.auth-submit-btn:hover::before {
    left: 100%;
}

.auth-submit-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 30px rgba(74, 144, 226, 0.4);
}

.auth-submit-btn:active {
    transform: translateY(-1px);
}

.auth-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* رسائل الخطأ والنجاح */
.auth-error-message,
.auth-success-message {
    padding: 1rem;
    border-radius: var(--auth-radius);
    margin: 1rem 0;
    font-weight: 500;
    animation: authMessageSlide 0.3s ease;
    border: 1px solid;
}

@keyframes authMessageSlide {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.auth-error-message {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

.auth-success-message {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

/* روابط التسجيل والدخول */
.auth-links {
    text-align: center;
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid #dee2e6;
}

.auth-links p {
    color: var(--auth-light);
    margin-bottom: 0.5rem;
}

.auth-links a {
    color: var(--auth-primary);
    text-decoration: none;
    font-weight: 600;
    transition: var(--auth-transition);
}

.auth-links a:hover {
    text-decoration: underline;
    color: var(--auth-purple);
}

/* تصميم التذكر ونسيان كلمة المرور */
.auth-remember-forgot {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 1.5rem 0;
    flex-wrap: wrap;
    gap: 1rem;
}

.auth-remember-me {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.auth-remember-me input {
    transform: scale(1.1);
    accent-color: var(--auth-primary);
}

.auth-forgot-password {
    color: var(--auth-primary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--auth-transition);
}

.auth-forgot-password:hover {
    text-decoration: underline;
    color: var(--auth-purple);
}

/* إشعارات أمان الأطفال */
.auth-child-safety-notice {
    background: linear-gradient(135deg, #e3f2fd, #bbdefb);
    border: 1px solid #90caf9;
    border-radius: var(--auth-radius);
    padding: 1.5rem;
    margin: 1.5rem 0;
    font-size: 0.9rem;
    animation: authSafetyPulse 2s ease-in-out infinite;
}

@keyframes authSafetyPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.4); }
    50% { box-shadow: 0 0 0 10px rgba(33, 150, 243, 0); }
}

.auth-child-safety-notice h5 {
    color: #1565c0;
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
}

.auth-child-safety-notice p {
    color: #1565c0;
    line-height: 1.6;
    margin: 0;
}

/* تصميم متجاوب */
@media (max-width: 768px) {
    .auth-page {
        padding: 10px;
    }
    
    .auth-container {
        margin: 10px;
        max-width: none;
    }
    
    .auth-header {
        padding: 1.5rem;
    }
    
    .auth-title {
        font-size: 1.5rem;
    }
    
    .auth-form {
        padding: 1.5rem;
    }
    
    .auth-tab-button {
        padding: 0.75rem;
        font-size: 0.9rem;
    }
    
    .auth-remember-forgot {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.8rem;
    }
    
    .auth-guardian-section {
        padding: 1.5rem;
    }
}

@media (max-width: 480px) {
    .auth-header {
        padding: 1rem;
    }
    
    .auth-title {
        font-size: 1.3rem;
    }
    
    .auth-form {
        padding: 1rem;
    }
    
    .auth-form-input,
    .auth-form-select {
        padding: 0.8rem;
        font-size: 0.9rem;
    }
    
    .auth-submit-btn {
        padding: 1rem;
        font-size: 1rem;
    }
}

/* تأثيرات خاصة للوضع الليلي */
@media (prefers-color-scheme: dark) {
    .auth-container {
        background: #2c3e50;
        color: white;
    }
    
    .auth-form-input,
    .auth-form-select {
        background: #34495e;
        color: white;
        border-color: #4a5f7a;
    }
    
    .auth-guardian-section {
        background: linear-gradient(135deg, #34495e, #2c3e50);
    }
    
    .auth-checkbox-group {
        background: rgba(74, 144, 226, 0.1);
    }
}

/* تحسينات الأداء */
.auth-container * {
    will-change: auto;
}

.auth-form-input:focus,
.auth-submit-btn:hover {
    will-change: transform, box-shadow;
}

/* تحسينات إمكانية الوصول */
.auth-form-input:focus,
.auth-submit-btn:focus,
.auth-tab-button:focus {
    outline: 2px solid var(--auth-primary);
    outline-offset: 2px;
}

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