/* إعادة تعيين الأساسيات */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* الخطوط العربية */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800&display=swap');

/* متغيرات CSS */
:root {
    --primary-color: #6366f1;
    --primary-dark: #4f46e5;
    --primary-light: #a5b4fc;
    --secondary-color: #f8fafc;
    --accent-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --success-color: #10b981;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --border-focus: #6366f1;
    --background-main: #ffffff;
    --background-secondary: #f8fafc;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --transition-fast: 0.15s ease-in-out;
    --transition-normal: 0.3s ease-in-out;
    --transition-slow: 0.5s ease-in-out;
}

/* الجسم الأساسي */
body {
    font-family: 'Cairo', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    direction: rtl;
    color: var(--text-primary);
    overflow-x: hidden;
    position: relative;
}

/* خلفية النجوم المتحركة */
.stars-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.stars {
    position: absolute;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(2px 2px at 20px 30px, #eee, transparent),
        radial-gradient(2px 2px at 40px 70px, rgba(255,255,255,0.8), transparent),
        radial-gradient(1px 1px at 90px 40px, #fff, transparent),
        radial-gradient(1px 1px at 130px 80px, rgba(255,255,255,0.6), transparent),
        radial-gradient(2px 2px at 160px 30px, #ddd, transparent);
    background-repeat: repeat;
    background-size: 200px 100px;
    animation: sparkle 20s linear infinite;
}

@keyframes sparkle {
    from { transform: translateX(0); }
    to { transform: translateX(-200px); }
}

.shooting-star {
    position: absolute;
    width: 2px;
    height: 2px;
    background: linear-gradient(45deg, #fff, transparent);
    border-radius: 50%;
    animation: shooting 4s linear infinite;
}

@keyframes shooting {
    0% {
        transform: translateX(-100px) translateY(-100px);
        opacity: 0;
    }
    10% {
        opacity: 1;
    }
    90% {
        opacity: 1;
    }
    100% {
        transform: translateX(300px) translateY(300px);
        opacity: 0;
    }
}

/* الحاوي الرئيسي */
.container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    position: relative;
    z-index: 2;
}

/* بطاقة التسجيل */
.register-card {
    background: var(--background-main);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    padding: 2.5rem;
    position: relative;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    animation: slideUp 0.6s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* رأس البطاقة */
.header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: var(--radius-lg);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-icon::before {
    content: '🏢';
    font-size: 24px;
    filter: brightness(0) invert(1);
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 400;
    margin: 0;
}

/* النموذج */
.register-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* أقسام النموذج */
.form-section {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    background: var(--background-secondary);
    transition: var(--transition-normal);
}

.form-section:hover {
    border-color: var(--primary-light);
    box-shadow: var(--shadow-sm);
}

.form-section h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.form-section h3::before {
    content: '';
    width: 4px;
    height: 20px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    border-radius: 2px;
}

/* مجموعات الحقول */
.form-group {
    margin-bottom: 1.25rem;
    position: relative;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* التسميات */
label {
    display: block;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* الحقول */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"] {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--background-main);
    color: var(--text-primary);
    transition: var(--transition-fast);
    outline: none;
}

input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
    transform: translateY(-1px);
}

input.success {
    border-color: var(--success-color);
    background: rgba(16, 185, 129, 0.05);
}

input.error {
    border-color: var(--error-color);
    background: rgba(239, 68, 68, 0.05);
}

/* تلميحات الحقول */
.input-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.input-hint::before {
    content: 'ℹ️';
    font-size: 0.75rem;
}

/* معاينة الرابط */
.url-preview {
    display: flex;
    align-items: center;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--background-main);
    overflow: hidden;
    transition: var(--transition-fast);
}

.url-preview:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.url-base {
    background: var(--background-secondary);
    padding: 0.875rem 1rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-left: 1px solid var(--border-color);
    white-space: nowrap;
}

.url-preview input {
    border: none;
    padding: 0.875rem 1rem;
    flex: 1;
    background: transparent;
}

.url-preview input:focus {
    box-shadow: none;
    transform: none;
}

/* مربع الاختيار */
.checkbox-group {
    margin: 1.5rem 0;
}

.checkbox {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1.5;
}

.checkbox input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--background-main);
    position: relative;
    transition: var(--transition-fast);
    flex-shrink: 0;
    margin-top: 2px;
}

.checkbox:hover .checkmark {
    border-color: var(--primary-color);
}

.checkbox input:checked + .checkmark {
    background: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox input:checked + .checkmark::after {
    content: '✓';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.privacy-link {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-fast);
}

.privacy-link:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* زر الإرسال */
.submit-btn {
    width: 100%;
    padding: 1rem 2rem;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-normal);
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-md);
}

.submit-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.submit-btn:active {
    transform: translateY(0);
}

.submit-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.submit-btn.loading .btn-text {
    opacity: 0;
}

.submit-btn.loading .btn-loader {
    opacity: 1;
}

.btn-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top: 2px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    opacity: 0;
    transition: var(--transition-fast);
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* رابط تسجيل الدخول */
.login-link {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.login-link a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition-fast);
}

.login-link a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* حاوي الرسائل */
.message-container {
    padding: 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    display: none;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-container.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.message-container.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.message-container.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.message-container.info {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

/* رسائل الحقول */
.error-message {
    color: var(--error-color);
    font-size: 0.8rem;
    margin-top: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.error-message::before {
    content: '⚠️';
    font-size: 0.75rem;
}

.field-message {
    font-size: 0.8rem;
    margin-top: 0.375rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.field-message[style*="color: rgb(39, 174, 96)"]::before {
    content: '✅';
    font-size: 0.75rem;
}

.field-message[style*="color: rgb(231, 76, 60)"]::before {
    content: '❌';
    font-size: 0.75rem;
}

/* الاقتراحات */
.suggestions {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: var(--warning-color);
}

.suggestion-btn {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning-color);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    margin: 0.125rem;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition-fast);
}

.suggestion-btn:hover {
    background: rgba(245, 158, 11, 0.2);
    border-color: var(--warning-color);
}

/* تأثير التركيز على مجموعات الحقول */
.form-group.focused {
    transform: scale(1.02);
}

/* تأثير الريبل للأزرار */
.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: scale(0);
    animation: ripple-animation 0.6s linear;
    pointer-events: none;
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* الاستجابة للأجهزة المحمولة */
@media (max-width: 768px) {
    .container {
        padding: 1rem 0.5rem;
    }
    
    .register-card {
        padding: 1.5rem;
        margin: 0.5rem;
        border-radius: var(--radius-lg);
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .form-section {
        padding: 1rem;
    }
    
    .logo h1 {
        font-size: 1.5rem;
    }
    
    .url-base {
        font-size: 0.85rem;
        padding: 0.75rem;
    }
    
    .url-preview input {
        padding: 0.75rem;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="tel"] {
        padding: 0.75rem;
        font-size: 16px; /* منع التكبير في iOS */
    }
}

@media (max-width: 480px) {
    .register-card {
        padding: 1rem;
        margin: 0.25rem;
    }
    
    .form-section {
        padding: 0.75rem;
    }
    
    .submit-btn {
        padding: 0.875rem 1.5rem;
    }
}

/* تحسينات إضافية للأداء */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .stars,
    .shooting-star {
        animation: none;
    }
}

/* وضع الطباعة */
@media print {
    .stars-container,
    .shooting-star {
        display: none;
    }
    
    body {
        background: white;
    }
    
    .register-card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* تحسينات إمكانية الوصول */
@media (prefers-contrast: high) {
    :root {
        --border-color: #000;
        --text-secondary: #000;
        --text-muted: #333;
    }
}

/* تأثيرات إضافية للتفاعل */
.form-group:hover input:not(:focus) {
    border-color: var(--primary-light);
}

.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: var(--transition-slow);
}

.submit-btn:hover::before {
    left: 100%;
}

/* تحسينات للوضع المظلم (إذا لزم الأمر) */
@media (prefers-color-scheme: dark) {
    :root {
        --background-main: #1e293b;
        --background-secondary: #334155;
        --text-primary: #f8fafc;
        --text-secondary: #cbd5e1;
        --text-muted: #94a3b8;
        --border-color: #475569;
    }
    
    .register-card {
        background: rgba(30, 41, 59, 0.95);
        border-color: rgba(255, 255, 255, 0.1);
    }
}

