* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #17324d;
    --secondary-color: #b4935e;
    --success-color: #2f8061;
    --danger-color: #b94a48;
    --warning-color: #c48a35;
    --light-bg: #f4f1eb;
    --border-color: #d9d0c1;
    --text-dark: #243746;
    --text-light: #687782;
    --shadow: 0 4px 16px rgba(23, 50, 77, 0.12);
    --transition: all 0.3s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #e8e0d2 0%, #f7f5f1 52%, #dfe8e7 100%);
    color: var(--text-dark);
    line-height: 1.6;
}

html[lang="ar"] {
    direction: rtl;
}

html[lang="en"] {
    direction: ltr;
}

/* Header */
.header {
    background: linear-gradient(135deg, #102a43 0%, var(--primary-color) 72%, #244c63 100%);
    color: white;
    padding: 2rem;
    box-shadow: var(--shadow);
    margin-bottom: 2rem;
}

.header-content {
    max-width: 1000px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
}

.brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
}

.brand-logo {
    width: 210px;
    height: 55px;
    object-fit: contain;
    object-position: center;
    background: transparent;
    border-radius: 0;
    padding: 0;
}

.header h1 {
    font-size: 2rem;
    font-weight: 600;
    text-align: center;
}

/* Language Toggle */
.language-toggle {
    background-color: var(--secondary-color);
    border: 2px solid #d8bb88;
    color: #102a43;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-weight: 600;
    transition: var(--transition);
    font-size: 0.9rem;
    position: absolute;
    right: 0;
}

html[lang="ar"] .language-toggle {
    right: auto;
    left: 0;
}

.language-toggle:hover {
    background-color: #d0ad72;
    transform: scale(1.05);
}

/* Container */
.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* Form Container */
.form-container {
    background: rgba(239, 233, 221, 0.96);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 2rem;
}

/* Section */
.section {
    margin-bottom: 2.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.section:last-child {
    border-bottom: none;
}

.section-label {
    display: block;
    font-weight: 600;
    margin-bottom: 1rem;
    color: var(--primary-color);
    font-size: 1.05rem;
}

/* Form Controls */
.form-select,
.form-input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 4px;
    font-size: 1rem;
    transition: var(--transition);
    font-family: inherit;
}

.form-select:focus,
.form-input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-select {
    cursor: pointer;
    background-color: white;
}

/* Question Block */
.question-block {
    background-color: var(--light-bg);
    border-left: 4px solid var(--secondary-color);
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-radius: 4px;
    transition: var(--transition);
}

html[lang="ar"] .question-block {
    border-left: none;
    border-right: 4px solid var(--secondary-color);
}

.question-block:hover {
    box-shadow: var(--shadow);
    transform: translateY(-2px);
}

.question-number {
    display: inline-block;
    background-color: var(--primary-color);
    color: white;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    margin-bottom: 0.5rem;
    flex-shrink: 0;
}

.question-text {
    font-weight: 600;
    margin-bottom: 0.75rem;
    font-size: 1rem;
    color: var(--text-dark);
}

.question-text.english {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-light);
    margin-top: 0.25rem;
}

/* Main Answer Options */
.answer-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .answer-options {
        grid-template-columns: 1fr;
    }
}

.radio-group {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition);
}

.radio-group:hover {
    background-color: rgba(59, 130, 246, 0.05);
    border-color: var(--secondary-color);
}

.radio-group:has(input:disabled) {
    opacity: 0.55;
    cursor: not-allowed;
}

.radio-group input:disabled {
    cursor: not-allowed;
}

.radio-group input[type="radio"] {
    cursor: pointer;
    margin-right: 0.75rem;
    width: 1.25rem;
    height: 1.25rem;
    accent-color: var(--secondary-color);
}

html[lang="ar"] .radio-group input[type="radio"] {
    margin-right: 0;
    margin-left: 0.75rem;
}

.radio-label {
    cursor: pointer;
    flex: 1;
}

.radio-label .answer-text {
    font-weight: 500;
    color: var(--text-dark);
}

.radio-label .answer-score {
    font-size: 0.85rem;
    color: var(--text-light);
    display: block;
    margin-top: 0.25rem;
}

/* Sub-questions */
.sub-questions {
    background-color: #faf8f4;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 1rem;
    margin-top: 1rem;
}

.sub-question-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: flex-start;
}

.sub-question-item:last-child {
    border-bottom: none;
}

.sub-question-number {
    background-color: var(--secondary-color);
    color: white;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: bold;
    flex-shrink: 0;
    margin-right: 0.75rem;
    margin-top: 0.1rem;
}

html[lang="ar"] .sub-question-number {
    margin-right: 0;
    margin-left: 0.75rem;
}

.sub-question-content {
    flex: 1;
}

.sub-question-text {
    font-size: 0.95rem;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.sub-answer-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 0.5rem;
}

.sub-radio-group {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.sub-radio-group:hover {
    background-color: rgba(59, 130, 246, 0.05);
}

.sub-radio-group input[type="radio"] {
    margin-right: 0.5rem;
    cursor: pointer;
    width: 1rem;
    height: 1rem;
    accent-color: var(--secondary-color);
}

html[lang="ar"] .sub-radio-group input[type="radio"] {
    margin-right: 0;
    margin-left: 0.5rem;
}

/* Form Actions */
.form-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-color);
}

html[lang="ar"] .form-actions {
    justify-content: flex-start;
}

@media (max-width: 768px) {
    .form-actions {
        flex-direction: column-reverse;
    }
}

/* Buttons */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #1d4ed8;
}

.btn-secondary {
    background-color: var(--light-bg);
    color: var(--text-dark);
    border: 2px solid var(--border-color);
}

.btn-secondary:hover {
    background-color: var(--border-color);
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #059669;
}

/* Progress Bar */
.progress-container {
    background: rgba(239, 233, 221, 0.96);
    border-radius: 8px;
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 2rem;
    position: sticky;
    bottom: 1rem;
    z-index: 100;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background-color: var(--light-bg);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

@media (max-width: 768px) {
    .header {
        padding: 1.25rem;
    }

    .header-content {
        gap: 1rem;
        align-items: center;
    }

    .brand {
        gap: 0.75rem;
        min-width: 0;
        width: auto;
    }

    .brand-logo {
        width: 165px;
        height: 44px;
    }

    .header h1 {
        font-size: 1.25rem;
        text-align: center;
    }

    .language-toggle {
        position: static;
    }
}

.progress-bar::after {
    content: '';
    display: block;
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color) 0%, var(--success-color) 100%);
    width: 0%;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    font-weight: 600;
    color: var(--primary-color);
}

/* Loading Spinner */
.spinner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner.hidden {
    display: none;
}

.spinner-ring {
    display: inline-block;
    position: relative;
    width: 80px;
    height: 80px;
}

.spinner-ring:after {
    content: " ";
    display: block;
    width: 64px;
    height: 64px;
    margin: 8px;
    border-radius: 50%;
    border: 6px solid #fff;
    border-color: #fff transparent #fff transparent;
    animation: spinner 1.2s linear infinite;
}

@keyframes spinner {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

#loadingText {
    color: white;
    font-weight: 600;
    margin-top: 1rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .header h1 {
        font-size: 1.5rem;
    }

    .form-container {
        padding: 1rem;
    }

    .question-block {
        padding: 1rem;
    }

    .answer-options {
        gap: 0.75rem;
    }

    .radio-group {
        padding: 0.5rem;
    }
}

/* Print Styles */
@media print {
    .header,
    .progress-container,
    .form-actions,
    .language-toggle {
        display: none;
    }

    .form-container {
        box-shadow: none;
        page-break-inside: avoid;
    }

    .question-block {
        page-break-inside: avoid;
    }
}

/* Accessibility */
.radio-group:focus-within {
    outline: 2px solid var(--secondary-color);
    outline-offset: 2px;
}

/* Animation */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.question-block {
    animation: slideIn 0.3s ease-out;
}

/* Message Box */
.message-box {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.message-box.success {
    background-color: #d1fae5;
    border-left: 4px solid var(--success-color);
    color: #065f46;
}

.message-box.error {
    background-color: #fee2e2;
    border-left: 4px solid var(--danger-color);
    color: #991b1b;
}

.message-box.hidden {
    display: none;
}
