/* 
 * ====================================================================
 * تنسيقات صفحة الاستبيان
 * المسار: css/survey.css
 * ====================================================================
 */

/* ====================================================================
   1. Container الرئيسي
   ==================================================================== */
.survey-page {
    min-height: 80vh;
    padding: 3rem 1rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
}

.survey-container {
    max-width: 900px;
    margin: 0 auto;
    background: var(--white);
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    animation: slideDown 0.6s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ====================================================================
   2. رأس الاستبيان
   ==================================================================== */
.survey-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 3rem 2rem;
    text-align: center;
    position: relative;
    overflow: hidden;
}

.survey-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="40" fill="rgba(255,255,255,0.05)"/></svg>');
    opacity: 0.3;
    z-index: 0;
}

.survey-header > * {
    position: relative;
    z-index: 1;
}

.survey-icon {
    width: 80px;
    height: 80px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1.5rem;
    font-size: 2.5rem;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
}

.survey-title {
    font-size: 2rem;
    margin-bottom: 1rem;
    font-weight: 700;
    line-height: 1.3;
}

.survey-description {
    font-size: 1.1rem;
    line-height: 1.8;
    opacity: 0.95;
    max-width: 700px;
    margin: 0 auto;
}

/* ====================================================================
   3. جسم الاستبيان
   ==================================================================== */
.survey-body {
    padding: 2.5rem;
}

/* ====================================================================
   4. رسائل التنبيه
   ==================================================================== */
.alert {
    padding: 1.25rem;
    border-radius: 12px;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    font-size: 1rem;
    position: relative;
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error-color);
    border: 2px solid var(--error-color);
}

.alert i {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.alert > div {
    flex: 1;
    line-height: 1.6;
}

.alert-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    opacity: 0.7;
    transition: opacity 0.3s;
    flex-shrink: 0;
}

.alert-close:hover {
    opacity: 1;
}

/* ====================================================================
   5. بطاقة السؤال
   ==================================================================== */
.question-card {
    background: var(--light-gray);
    border: 2px solid var(--medium-gray);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    transition: all 0.3s ease;
}

.question-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 8px 16px rgba(123, 33, 159, 0.1);
    transform: translateY(-2px);
}

.question-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.question-number {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border-radius: 50%;
    font-weight: bold;
    font-size: 1.1rem;
    flex-shrink: 0;
    box-shadow: 0 4px 8px rgba(123, 33, 159, 0.2);
}

.question-text {
    flex: 1;
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-dark);
    line-height: 1.6;
}

.required-star {
    color: var(--error-color);
    font-size: 1.3rem;
    margin-left: 0.25rem;
    display: inline-block;
}

/* ====================================================================
   6. خيارات التقييم (Rating Options)
   ==================================================================== */
.rating-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.rating-option {
    position: relative;
}

.rating-option input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.rating-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    background: var(--white);
    border: 2px solid var(--medium-gray);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    height: 100%;
    min-height: 120px;
}

.rating-label:hover {
    border-color: var(--primary-color);
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(123, 33, 159, 0.15);
}

.rating-option input[type="radio"]:checked + .rating-label {
    border-color: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    transform: translateY(-4px);
    box-shadow: 0 8px 20px rgba(123, 33, 159, 0.3);
}

.rating-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    transition: transform 0.3s ease;
}

.rating-option input[type="radio"]:checked + .rating-label .rating-icon {
    transform: scale(1.2);
    animation: bounce 0.5s ease;
}

@keyframes bounce {
    0%, 100% { 
        transform: scale(1.2); 
    }
    50% { 
        transform: scale(1.4); 
    }
}

/* ألوان أيقونات التقييم */
.satisfied .rating-icon {
    color: var(--success-color);
}

.neutral .rating-icon {
    color: #f59e0b;
}

.unsatisfied .rating-icon {
    color: var(--error-color);
}

/* عند الاختيار - تتحول الأيقونات للأبيض */
.rating-option input[type="radio"]:checked + .satisfied .rating-icon,
.rating-option input[type="radio"]:checked + .neutral .rating-icon,
.rating-option input[type="radio"]:checked + .unsatisfied .rating-icon {
    color: var(--white);
}

.rating-text {
    font-weight: 600;
    font-size: 1rem;
}

/* ====================================================================
   7. حقل النص (Text Answer)
   ==================================================================== */
.text-answer-wrapper {
    margin-top: 1rem;
}

.text-answer {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--medium-gray);
    border-radius: 12px;
    font-size: 1rem;
    font-family: 'Tajawal', sans-serif;
    resize: vertical;
    min-height: 120px;
    transition: all 0.3s ease;
    background: var(--white);
    color: var(--text-dark);
    line-height: 1.6;
}

.text-answer:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px var(--primary-light);
}

.text-answer::placeholder {
    color: var(--text-light);
}

/* عداد الأحرف */
.char-counter {
    text-align: left;
    font-size: 0.875rem;
    color: var(--text-light);
    margin-top: 0.5rem;
    padding: 0 0.25rem;
}

.counter-warning {
    color: var(--error-color);
    font-weight: 600;
}

/* ====================================================================
   8. تذييل النموذج وزر الإرسال
   ==================================================================== */
.form-footer {
    margin-top: 2rem;
    text-align: center;
}

.btn-submit {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    border: none;
    padding: 1.25rem 3rem;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    transition: all 0.3s ease;
    font-family: 'Tajawal', sans-serif;
    min-width: 250px;
    box-shadow: 0 4px 12px rgba(123, 33, 159, 0.2);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 24px rgba(123, 33, 159, 0.3);
}

.btn-submit:active {
    transform: translateY(0);
}

.btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-submit i {
    font-size: 1.2rem;
}

/* ====================================================================
   9. صفحة النجاح (Success Card)
   ==================================================================== */
.success-card {
    text-align: center;
    padding: 3rem 2rem;
}

.success-icon {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, var(--success-color) 0%, #0d5a2b 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 2rem;
    animation: scaleIn 0.6s ease;
    box-shadow: 0 8px 24px rgba(21, 128, 60, 0.3);
}

@keyframes scaleIn {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.success-icon i {
    font-size: 4rem;
    color: var(--white);
}

.success-card h2 {
    font-size: 2.5rem;
    color: var(--text-dark);
    margin-bottom: 1rem;
    font-weight: 700;
}

.success-card p {
    font-size: 1.2rem;
    color: var(--text-light);
    line-height: 1.8;
    margin-bottom: 0.5rem;
}

.success-subtitle {
    font-size: 1rem !important;
    margin-bottom: 2rem !important;
}

.btn-home {
    display: inline-flex;
    align-items: center;
    gap: 0.75rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 1rem 2rem;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    margin-top: 1rem;
    box-shadow: 0 4px 12px rgba(123, 33, 159, 0.2);
}

.btn-home:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(123, 33, 159, 0.3);
    text-decoration: none;
    color: var(--white);
}

/* ====================================================================
   10. صفحة الخطأ (Error Container)
   ==================================================================== */
.error-container {
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.error-card {
    background: var(--white);
    border-radius: 20px;
    padding: 3rem;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    animation: slideDown 0.6s ease;
}

.error-card i {
    font-size: 5rem;
    color: var(--error-color);
    margin-bottom: 1.5rem;
}

.error-card h2 {
    font-size: 2rem;
    color: var(--text-dark);
    margin-bottom: 1rem;
    font-weight: 700;
}

.error-card p {
    font-size: 1.1rem;
    color: var(--text-light);
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.error-card strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* ====================================================================
   11. تأثيرات الأخطاء والتحقق
   ==================================================================== */
.error-shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.error-border {
    border-color: var(--error-color) !important;
    animation: pulse-error 1s;
}

@keyframes pulse-error {
    0%, 100% { 
        border-color: var(--error-color); 
        box-shadow: 0 0 0 0 rgba(185, 28, 28, 0.4);
    }
    50% { 
        border-color: #ef4444; 
        box-shadow: 0 0 0 6px rgba(185, 28, 28, 0);
    }
}

/* ====================================================================
   12. الاستجابة للشاشات الصغيرة (Responsive)
   ==================================================================== */

/* شاشات التابلت */
@media (max-width: 768px) {
    .survey-page {
        padding: 2rem 1rem;
    }
    
    .survey-header {
        padding: 2rem 1.5rem;
    }
    
    .survey-icon {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }
    
    .survey-title {
        font-size: 1.5rem;
    }
    
    .survey-description {
        font-size: 1rem;
    }
    
    .survey-body {
        padding: 1.5rem;
    }
    
    .question-card {
        padding: 1.5rem;
    }
    
    .question-text {
        font-size: 1rem;
    }
    
    .rating-options {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }
    
    .rating-label {
        min-height: 100px;
    }
    
    .btn-submit {
        width: 100%;
        min-width: auto;
    }
    
    .success-card h2 {
        font-size: 2rem;
    }
    
    .success-card p {
        font-size: 1rem;
    }
    
    .error-card {
        padding: 2rem;
    }
    
    .error-card i {
        font-size: 4rem;
    }
}

/* شاشات الموبايل */
@media (max-width: 480px) {
    .survey-page {
        padding: 1.5rem 0.75rem;
    }
    
    .survey-container {
        border-radius: 16px;
    }
    
    .survey-header {
        padding: 1.5rem 1rem;
    }
    
    .survey-icon {
        width: 60px;
        height: 60px;
        font-size: 1.75rem;
    }
    
    .survey-title {
        font-size: 1.25rem;
    }
    
    .survey-description {
        font-size: 0.95rem;
    }
    
    .survey-body {
        padding: 1.25rem;
    }
    
    .question-card {
        padding: 1.25rem;
        border-radius: 12px;
    }
    
    .question-header {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .question-number {
        min-width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    .question-text {
        font-size: 0.95rem;
    }
    
    .rating-icon {
        font-size: 2rem;
    }
    
    .rating-label {
        padding: 1rem 0.75rem;
        min-height: 90px;
    }
    
    .rating-text {
        font-size: 0.9rem;
    }
    
    .text-answer {
        font-size: 0.95rem;
        min-height: 100px;
    }
    
    .btn-submit {
        padding: 1rem 2rem;
        font-size: 1rem;
    }
    
    .success-icon {
        width: 100px;
        height: 100px;
    }
    
    .success-icon i {
        font-size: 3rem;
    }
    
    .success-card h2 {
        font-size: 1.75rem;
    }
    
    .error-card {
        padding: 1.5rem;
    }
    
    .error-card h2 {
        font-size: 1.5rem;
    }
    
    .error-card p {
        font-size: 1rem;
    }
}

/* ====================================================================
   13. تحسينات الطباعة (Print Styles)
   ==================================================================== */
@media print {
    .survey-page {
        background: white;
        padding: 0;
    }
    
    .survey-header {
        background: white;
        color: black;
    }
    
    .btn-submit,
    .btn-home,
    .alert-close {
        display: none;
    }
    
    .question-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ====================================================================
   14. تحسينات إضافية
   ==================================================================== */

/* Smooth scroll */
html {
    scroll-behavior: smooth;
}

/* تحسين الأداء */
.question-card,
.rating-label,
.btn-submit {
    will-change: transform;
}

/* Focus visible للوصولية */
.rating-option input[type="radio"]:focus + .rating-label {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}

.text-answer:focus-visible,
.btn-submit:focus-visible {
    outline: 3px solid var(--primary-color);
    outline-offset: 2px;
}