/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --midnight-blue: #1a1a2e;
    --dark-blue: #16213e;
    --parchment-beige: #f5f2e8;
    --gold-accent: #d4af37;
    --soft-gold: #f4e8c1;
    --text-dark: #2c2c2c;
    --error-color: #e74c3c;
    --success-color: #27ae60;
}

html, body {
    height: 100%;
    font-family: 'Tajawal', 'Source Sans Pro', sans-serif;
    background: var(--midnight-blue);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Animated Background */
.animated-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 0;
    background: linear-gradient(135deg, var(--midnight-blue) 0%, var(--dark-blue) 100%);
    will-change: transform;
}

.floating-elements {
    position: absolute;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.floating-book {
    position: absolute;
    color: rgba(212, 175, 55, 0.15);
    font-size: 4rem; /* تكبير الأيقونات */
    animation: float 6s ease-in-out infinite;
    will-change: transform;
    cursor: pointer;
    transition: all 0.3s ease;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.floating-book:hover {
    transform: scale(1.2) translateY(-10px);
    color: rgba(212, 175, 55, 0.3);
}

.floating-book:active {
    transform: scale(1.1) translateY(-5px);
}

.floating-book:nth-child(1) { top: 10%; left: 10%; animation-delay: 0s; }
.floating-book:nth-child(2) { top: 20%; right: 15%; animation-delay: 2s; }
.floating-book:nth-child(3) { bottom: 30%; left: 20%; animation-delay: 4s; }
.floating-book:nth-child(4) { bottom: 15%; right: 10%; animation-delay: 1s; }
.floating-book:nth-child(5) { top: 50%; left: 5%; animation-delay: 3s; }

@keyframes float {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-20px) rotate(5deg); }
}

.abstract-shape {
    position: absolute;
    border-radius: 50%;
    background: linear-gradient(45deg, rgba(212, 175, 55, 0.08), rgba(244, 232, 193, 0.15));
    animation: pulse 4s ease-in-out infinite;
    will-change: transform, opacity;
    pointer-events: none;
}

.shape1 { width: 150px; height: 150px; top: 15%; right: 25%; animation-delay: 0s; }
.shape2 { width: 200px; height: 200px; bottom: 25%; left: 15%; animation-delay: 2s; }
.shape3 { width: 120px; height: 120px; top: 60%; right: 10%; animation-delay: 1s; }

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.1); opacity: 0.7; }
}

/* Main Container - تحسين الأبعاد */
.main-container {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.auth-wrapper {
    background: rgba(245, 242, 232, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 700px; /* زيادة العرض */
    min-height: 600px; /* إضافة ارتفاع أدنى */
    overflow: hidden;
    transition: all 0.3s ease;
    will-change: transform, opacity;
    animation: fadeInUp 0.8s ease-out;
}

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

.auth-header {
    background: linear-gradient(135deg, var(--gold-accent), var(--soft-gold));
    padding: 40px 30px;
    text-align: center;
    color: var(--text-dark);
}

.logo {
    font-size: 3rem;
    font-weight: 700;
    margin-bottom: 15px;
    position: relative;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--text-dark) !important; /* إزالة اللون الأزرق */
    text-decoration: none;
    display: inline-block;
}

.logo:hover {
    transform: scale(1.05);
    color: var(--text-dark) !important; /* إزالة اللون الأزرق */
    text-decoration: none;
}

.logo::before {
    content: "📚";
    margin-left: 15px;
    display: inline-block;
    transition: all 0.3s ease;
    cursor: pointer;
}

.logo:hover::before {
    transform: translateY(-8px) rotate(15deg) scale(1.2);
}

.logo:active::before {
    transform: translateY(-5px) rotate(10deg) scale(1.1);
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    font-weight: 400;
    line-height: 1.5;
    color: var(--text-dark); /* إزالة اللون الأزرق */
}

/* Form Container */
.form-container {
    position: relative;
    height: auto;
    min-height: auto;
    overflow: visible;
}

.form-panel {
    position: relative;
    width: 100%;
    padding: 50px 40px;
    transition: transform 0.6s cubic-bezier(0.4, 0.0, 0.2, 1);
    will-change: transform;
}

.login-panel {
    transform: translateX(0);
}

.register-panel {
    transform: translateX(100%);
}

.form-container.register-mode .login-panel {
    transform: translateX(-100%);
}

.form-container.register-mode .register-panel {
    transform: translateX(0);
}

.form-title {
    font-size: 2.2rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 40px;
    text-align: center;
    line-height: 1.3;
}

/* Form Elements */
.form-group {
    margin-bottom: 25px;
    position: relative;
}

.form-input {
    width: 100%;
    padding: 18px 25px;
    border: 2px solid #e0e0e0;
    border-radius: 15px;
    font-size: 1.1rem;
    font-family: 'Tajawal', 'Source Sans Pro', sans-serif;
    background: #fff;
    transition: all 0.3s ease;
    direction: rtl;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    display: block;
    line-height: 1.5;
    color: var(--text-dark);
}

.form-input:focus {
    outline: none;
    border-color: var(--gold-accent);
    box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.15);
    transform: translateY(-2px);
}

.form-input::placeholder {
    color: #999;
    font-weight: 400;
    opacity: 0.8;
}

.btn-primary {
    width: 100%;
    padding: 18px;
    background: linear-gradient(135deg, var(--gold-accent), #e6c547);
    border: none;
    border-radius: 15px;
    color: var(--text-dark);
    font-size: 1.2rem;
    font-weight: 600;
    font-family: 'Tajawal', 'Source Sans Pro', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 15px;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    line-height: 1.5;
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

.btn-primary:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(212, 175, 55, 0.4);
    text-decoration: none;
    color: var(--text-dark);
}

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

.forgot-password {
    display: block;
    text-align: center;
    color: var(--gold-accent);
    text-decoration: none;
    font-size: 1rem;
    margin-top: 20px;
    transition: color 0.3s ease;
    font-weight: 500;
}

.forgot-password:hover {
    color: #b8941f;
    text-decoration: underline;
}

/* Toggle Buttons */
.toggle-container {
    background: var(--parchment-beige);
    padding: 30px;
    text-align: center;
}

.toggle-text {
    color: var(--text-dark);
    margin-bottom: 20px;
    font-size: 1.1rem;
    font-weight: 500;
}

.btn-toggle {
    background: transparent;
    border: 2px solid var(--gold-accent);
    color: var(--gold-accent);
    padding: 12px 30px;
    border-radius: 30px;
    font-family: 'Tajawal', 'Source Sans Pro', sans-serif;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-toggle:hover {
    background: var(--gold-accent);
    color: var(--text-dark);
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(212, 175, 55, 0.3);
}

/* Loading Animation */
.loading {
    display: none;
    width: 24px;
    height: 24px;
    border: 3px solid transparent;
    border-top: 3px solid var(--text-dark);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Messages */
.error-message {
    color: var(--error-color);
    font-size: 0.9rem;
    margin-top: 8px;
    display: none;
    font-weight: 500;
    animation: slideIn 0.3s ease-out;
}

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

/* Social Buttons */
.sb {
    display: inline-block;
    height: 50px;
    color: white !important;
    font-family: sans-serif;
    padding-right: 20px;
    font-size: 16px;
    text-decoration: none;
    overflow: hidden;
    border: 1px solid transparent;
    margin: 8px 0;
    border-radius: 15px;
    transition: all 0.3s ease;
    width: 100%;
    text-align: center;
    font-weight: 500;
}

.sb::before {
    font-family: "Font Awesome 5 Brands", sans-serif;
    text-align: center;
    width: 50px;
    height: 100%;
    display: inline-block;
    font-size: 28px;
    margin-right: 15px;
    line-height: 50px;
    margin-bottom: 2px;
    vertical-align: middle;
}

.sb:hover {
    text-decoration: none;
    color: white !important;
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

/* Social Button Colors */
.sb-facebook {
    background-color: #4366ad;
    border-color: #2e4576;
}

.sb-facebook::before {
    background-color: #3C5B9B;
    content: "\f39e";
}

.sb-facebook:hover::before {
    background-color: #4366ad;
}

.sb-facebook:hover {
    background-color: #4f72bb;
}

.sb-twitter {
    background-color: #43b3e4;
    border-color: #1b8dc0;
}

.sb-twitter::before {
    background-color: #2DAAE1;
    content: "\f099";
}

.sb-twitter:hover::before {
    background-color: #43b3e4;
}

.sb-twitter:hover {
    background-color: #5abce7;
}

.sb-google {
    background-color: #4285f4;
    border-color: #4285f4;
}

.sb-google::before {
    color: #4285f4;
    background-color: #ffffff;
    content: "\f1a0";
}

.sb-google:hover::before {
    background-color: #ffffff;
}

.sb-google:hover {
    background-color: #6098f3;
}

/* Form Check - إصلاح المسافات */
.form-check {
    display: flex;
    align-items: center;
    justify-content: space-between; /* توزيع العناصر */
    margin: 25px 0;
    gap: 30px; /* زيادة المسافة أكثر */
    padding: 15px 0; /* زيادة padding */
    text-align: center; /* توسيط النص */
    flex-direction: row-reverse; /* عكس الترتيب - مربع الاختيار في اليمين */
}

.form-check-input {
    margin: 0;
    transform: scale(1.6); /* تكبير أكثر */
    cursor: pointer;
    flex-shrink: 0;
    order: 2; /* ترتيب مربع الاختيار ثانياً (في اليمين) */
}

.form-check-label {
    color: var(--text-dark);
    font-size: 1.1rem; /* تكبير الخط قليلاً */
    cursor: pointer;
    font-weight: 500;
    margin: 0;
    flex: 1;
    order: 1; /* ترتيب النص أولاً (في اليسار) */
    text-align: right; /* محاذاة النص لليمين */
    padding: 0 10px; /* إضافة padding للنص */
}

/* Divider */
hr {
    border: none;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold-accent), transparent);
    margin: 30px 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-container {
        padding: 15px;
    }

    .auth-wrapper {
        border-radius: 15px;
        max-width: 100%;
        min-height: auto;
    }

    .form-panel {
        padding: 40px 25px;
    }

    .auth-header {
        padding: 30px 20px;
    }

    .logo {
        font-size: 2.5rem;
    }

    .form-title {
        font-size: 1.8rem;
        margin-bottom: 30px;
    }

    .form-input, .btn-primary {
        padding: 16px 20px;
        font-size: 1rem;
    }

    .floating-book {
        font-size: 3rem; /* تكبير الأيقونات في الموبايل */
    }

    .shape1, .shape2, .shape3 {
        width: 100px;
        height: 100px;
    }
}

@media (max-width: 480px) {
    .main-container {
        padding: 10px;
    }

    .auth-wrapper {
        border-radius: 12px;
        max-width: 100%;
        min-height: auto;
    }

    .form-panel {
        padding: 30px 20px;
    }

    .auth-header {
        padding: 25px 15px;
    }

    .logo {
        font-size: 2rem;
    }

    .form-title {
        font-size: 1.6rem;
        margin-bottom: 25px;
    }

    .form-input, .btn-primary {
        padding: 14px 18px;
        font-size: 0.95rem;
    }

    .toggle-container {
        padding: 25px 20px;
    }

    .floating-book {
        font-size: 2.5rem; /* تكبير الأيقونات في الشاشات الصغيرة */
    }

    .shape1, .shape2, .shape3 {
        width: 80px;
        height: 80px;
    }

    .form-check {
        gap: 25px; /* مسافة مناسبة في الشاشات الصغيرة */
        justify-content: space-between;
        flex-direction: row-reverse;
    }

    .form-check-input {
        transform: scale(1.5);
        order: 2;
    }

    .form-check-label {
        font-size: 1rem;
        text-align: right;
        order: 1;
    }
}

@media (max-width: 320px) {
    .form-title {
        font-size: 1.4rem;
    }

    .form-input, .btn-primary {
        padding: 12px 15px;
        font-size: 0.9rem;
    }

    .logo {
        font-size: 1.8rem;
    }

    .floating-book {
        font-size: 2rem;
    }
}

/* RTL Support */
html[dir=rtl] .sb {
    padding-right: 0;
    padding-left: 20px;
}

html[dir=rtl] .sb::before {
    margin-right: 0;
    margin-left: 15px;
}

html[dir=rtl] .form-check-input {
    margin: 0;
}

/* Legacy Support */
.auth {
    overflow: hidden;
    width: 100%;
    max-width: 360px;
    margin: 40px auto;
}

.auth-title {
    font-size: 35px;
    text-align: center;
    margin-bottom: 1.25rem;
    font-weight: 300;
}

.auth-title a {
    color: #444;
}

.auth-title a:hover {
    text-decoration: none;
}

.auth-content {
    background: #fff;
    padding: 15px;
}

/* Cookie bar */
#cookie-pop {
    position: sticky;
    bottom: 0;
    z-index: 10000;
    background-color: #2b2b2b;
    padding: 15px 0;
}

.cookie-message {
    flex: 1;
    color: #ffffff;
}

.cookie-message a {
    color: #ffffff;
}

/* Performance optimizations */
@media (prefers-reduced-motion: reduce) {
    .floating-book,
    .abstract-shape,
    .auth-wrapper,
    .form-panel,
    .logo::before {
        animation: none;
        transition: none;
    }
}

/* Focus styles for accessibility */
.form-input:focus-visible,
.btn-primary:focus-visible,
.btn-toggle:focus-visible {
    outline: 2px solid var(--gold-accent);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .form-input {
        border-width: 3px;
    }
    
    .btn-primary {
        border: 2px solid var(--text-dark);
    }
}

/* تحسين الأداء - إضافة will-change للأعناصر المتحركة */
.logo,
.logo::before,
.floating-book,
.abstract-shape {
    will-change: transform;
}

/* تحسين الانتقالات */
.auth-wrapper,
.form-panel,
.btn-primary,
.btn-toggle {
    will-change: transform, opacity;
}

/* تحسين التفاعل - إضافة تأثيرات إضافية */
.form-input:focus + .form-group::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--gold-accent);
    animation: expandWidth 0.3s ease-out;
}

@keyframes expandWidth {
    from { width: 0; }
    to { width: 100%; }
}

/* تحسين الأداء - تحسين الرسومات */
.auth-wrapper {
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* تحسين التفاعل مع الشاشات اللمسية */
@media (hover: none) and (pointer: coarse) {
    .floating-book:hover {
        transform: none;
    }
    
    .btn-primary:hover,
    .btn-toggle:hover {
        transform: none;
    }
    
    .form-input:focus {
        transform: none;
    }
}

