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

:root {
    --primary-color: #0066cc;
    --secondary-color: #00a651;
    --accent-color: #ff6b35;
    --text-primary: #333333;
    --text-secondary: #666666;
    --border-color: #dddddd;
    --bg-light: #f8f9fa;
    --bg-white: #ffffff;
    --success-color: #28a745;
    --error-color: #dc3545;
    --warning-color: #ffc107;
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);
    --border-radius: 8px;
    --transition: all 0.3s ease;
}

body {
    font-family: 'Tajawal', 'Segoe UI', Arial, sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #f5f7fa 0%, #e8eef5 100%);
    min-height: 100vh;
    direction: rtl;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header Styles */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0052a3 100%);
    color: white;
    padding: 30px 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    margin-bottom: 30px;
    text-align: center;
}

.logo-section {
    margin-bottom: 20px;
}

.main-title {
    font-size: 2.5em;
    font-weight: 700;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

.sub-title {
    font-size: 1.4em;
    font-weight: 400;
    opacity: 0.95;
    font-style: italic;
}

.version-info {
    font-size: 0.9em;
    opacity: 0.9;
    margin-top: 10px;
}

.institution-info {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid rgba(255, 255, 255, 0.3);
}

.institution-ar, .institution-en {
    font-size: 1.1em;
    font-weight: 500;
    margin: 5px 0;
}

.college-ar, .college-en {
    font-size: 0.95em;
    opacity: 0.9;
    margin: 3px 0;
}

/* Main Content */
.main-content {
    background: var(--bg-white);
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    margin-bottom: 30px;
}

/* Section Styles */
.welcome-section, .action-section, .info-section {
    margin-bottom: 40px;
}

.section-title {
    font-size: 1.8em;
    color: var(--primary-color);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 3px solid var(--primary-color);
}

.study-info {
    background: var(--bg-light);
    padding: 25px;
    border-radius: var(--border-radius);
    border-right: 5px solid var(--secondary-color);
}

.study-title-ar {
    font-size: 1.2em;
    color: var(--text-primary);
    font-weight: 600;
    margin-bottom: 10px;
    line-height: 1.8;
}

.study-title-en {
    font-size: 1em;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 20px;
    line-height: 1.6;
}

.researcher-info {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid var(--border-color);
}

.researcher-info p {
    margin: 8px 0;
    font-size: 1em;
}

/* Card Styles */
.card-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.action-card {
    background: white;
    padding: 30px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-md);
    text-align: center;
    transition: var(--transition);
    border: 2px solid transparent;
}

.action-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
    border-color: var(--primary-color);
}

.card-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.5em;
    color: var(--primary-color);
    font-weight: 600;
    margin-bottom: 8px;
}

.card-title-en {
    font-size: 1.1em;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 15px;
}

.card-description {
    color: var(--text-secondary);
    margin-bottom: 10px;
    line-height: 1.6;
}

.card-description-en {
    color: var(--text-secondary);
    font-size: 0.95em;
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Info Box */
.info-box {
    background: linear-gradient(135deg, #fff8e1 0%, #ffe082 100%);
    padding: 25px;
    border-radius: var(--border-radius);
    border-right: 5px solid var(--warning-color);
}

.info-title {
    font-size: 1.3em;
    color: var(--text-primary);
    margin-bottom: 15px;
    font-weight: 600;
}

.info-list {
    list-style-position: inside;
    color: var(--text-primary);
}

.info-list li {
    margin: 10px 0;
    padding-right: 10px;
    line-height: 1.7;
}

/* Button Styles */
.btn {
    display: inline-block;
    padding: 12px 30px;
    border-radius: 50px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1em;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0052a3 100%);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #008741 100%);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-large {
    padding: 15px 40px;
    font-size: 1.1em;
    margin: 10px;
}

.btn-small {
    padding: 8px 20px;
    font-size: 0.9em;
}

/* Form Styles */
.questionnaire-form {
    max-width: 900px;
    margin: 0 auto;
}

.form-section {
    background: white;
    padding: 30px;
    margin-bottom: 30px;
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
}

.form-section:hover {
    box-shadow: var(--shadow-sm);
}

.highlight-section {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 2px solid var(--primary-color);
}

.section-content {
    color: var(--text-primary);
    line-height: 1.8;
}

.section-content p {
    margin-bottom: 15px;
}

.text-en {
    color: var(--text-secondary);
    font-size: 0.95em;
    font-style: italic;
}

.procedures-list {
    margin-right: 20px;
    margin-top: 15px;
}

.procedures-list li {
    margin-bottom: 20px;
}

.note {
    background: #fffde7;
    padding: 15px;
    border-right: 4px solid var(--warning-color);
    border-radius: 4px;
    margin-top: 15px;
}

.section-instructions {
    background: var(--bg-light);
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 25px;
    border-right: 4px solid var(--primary-color);
}

/* Question Group Styles */
.question-group {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-light);
    border-radius: var(--border-radius);
}

.question-label {
    display: block;
    font-weight: 600;
    font-size: 1.1em;
    color: var(--text-primary);
    margin-bottom: 15px;
}

.question-label.required::after {
    content: " *";
    color: var(--error-color);
}

.question-description {
    color: var(--text-secondary);
    font-size: 0.95em;
    margin-bottom: 15px;
    font-style: italic;
}

/* Radio and Checkbox Groups */
.radio-group, .checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.radio-label, .checkbox-label {
    display: flex;
    align-items: flex-start;
    padding: 15px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
}

.radio-label:hover, .checkbox-label:hover {
    border-color: var(--primary-color);
    background: #f0f7ff;
}

.radio-label input[type="radio"],
.checkbox-label input[type="checkbox"] {
    margin-left: 12px;
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.radio-label input[type="radio"]:checked + span,
.checkbox-label input[type="checkbox"]:checked + span {
    color: var(--primary-color);
    font-weight: 600;
}

/* Form Inputs */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.form-label.required::after {
    content: " *";
    color: var(--error-color);
}

.form-input, .form-select, .form-textarea {
    padding: 12px;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1em;
    font-family: inherit;
    transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

/* VAS Scale Styles */
.vas-instructions {
    background: white;
    padding: 20px;
    border-radius: var(--border-radius);
    margin-bottom: 30px;
    border: 2px solid var(--primary-color);
}

.vas-instructions p {
    margin-bottom: 10px;
    line-height: 1.7;
}

.vas-container {
    background: white;
    padding: 40px;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.vas-scale {
    margin-bottom: 30px;
}

#vasSlider {
    height: 10px;
    margin: 30px 0;
}

.vas-value-display {
    text-align: center;
    margin-top: 20px;
}

.vas-current-value {
    display: inline-block;
    font-size: 3em;
    font-weight: 700;
    color: var(--primary-color);
    padding: 20px 40px;
    background: var(--bg-light);
    border-radius: var(--border-radius);
    min-width: 120px;
}

.vas-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
}

.vas-label-min, .vas-label-max {
    font-weight: 600;
    text-align: center;
    line-height: 1.6;
}

.vas-label-min {
    color: var(--error-color);
}

.vas-label-max {
    color: var(--success-color);
}

/* Signature Canvas */
#signatureCanvas {
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: crosshair;
    background: white;
    display: block;
    margin: 15px 0;
    width: 100%;
    max-width: 600px;
    height: 150px;
}

/* Form Actions */
.form-actions {
    text-align: center;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
}

/* Message Styles */
.message {
    padding: 15px 20px;
    border-radius: var(--border-radius);
    margin: 20px 0;
    font-weight: 500;
    text-align: center;
}

.message.success {
    background: #d4edda;
    color: #155724;
    border: 2px solid #c3e6cb;
}

.message.error {
    background: #f8d7da;
    color: #721c24;
    border: 2px solid #f5c6cb;
}

.message.warning {
    background: #fff3cd;
    color: #856404;
    border: 2px solid #ffeaa7;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

/* Loading Spinner - Only affect form content, not buttons */
.loading .form-input,
.loading .form-select,
.loading .form-textarea,
.loading .radio-label,
.loading .checkbox-label {
    pointer-events: none;
    opacity: 0.6;
}

/* Loading spinner overlay - only show when form has loading class */
.loading::after {
    content: "";
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 5px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

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

    .header {
        padding: 20px;
    }

    .main-title {
        font-size: 1.8em;
    }

    .sub-title {
        font-size: 1.1em;
    }

    .main-content {
        padding: 20px;
    }

    .form-section {
        padding: 20px;
    }

    .card-container {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .vas-current-value {
        font-size: 2em;
        padding: 15px 30px;
    }

    #signatureCanvas {
        width: 100%;
        height: 120px;
    }

    .btn-large {
        padding: 12px 30px;
        font-size: 1em;
    }
}

/* Print Styles */
@media print {
    .btn, .form-actions {
        display: none;
    }

    .header, .main-content, .form-section {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* noUiSlider Custom Styles */
.noUi-target {
    background: var(--bg-light);
    border: 2px solid var(--border-color);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.noUi-connect {
    background: linear-gradient(90deg, var(--error-color) 0%, var(--warning-color) 50%, var(--success-color) 100%);
}

.noUi-handle {
    border: 3px solid var(--primary-color);
    background: white;
    box-shadow: var(--shadow-md);
    cursor: grab;
    width: 30px;
    height: 30px;
    border-radius: 50%;
}

.noUi-handle:active {
    cursor: grabbing;
}

.noUi-handle::before,
.noUi-handle::after {
    display: none;
}

/* Enhanced Submit Button Loading States */
.btn.loading {
    position: relative;
    cursor: not-allowed;
    opacity: 0.7;
    transition: all 0.3s ease;
    display: inline-block !important; /* Prevent hiding */
    visibility: visible !important; /* Prevent hiding */
}

.btn.loading:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
    display: inline-block !important; /* Prevent hiding */
    visibility: visible !important; /* Prevent hiding */
}

.btn:disabled:hover {
    transform: none;
    box-shadow: var(--shadow-sm);
}

/* Ensure buttons remain visible when form has loading class */
.loading .btn,
.loading .btn.loading,
.loading .btn:disabled {
    pointer-events: auto !important; /* Override form loading pointer-events */
    opacity: inherit !important; /* Override form loading opacity */
    display: inline-block !important;
    visibility: visible !important;
}

/* Ensure both primary and secondary buttons remain visible during loading */
.loading .btn-primary,
.loading .btn-secondary,
.loading .btn-primary.loading,
.loading .btn-secondary.loading,
.loading .btn-primary:disabled,
.loading .btn-secondary:disabled {
    pointer-events: auto !important;
    opacity: inherit !important;
    display: inline-block !important;
    visibility: visible !important;
}

/* Ensure form-actions container stays visible during loading */
.form-actions:has(.btn.loading),
.form-actions:has(.btn:disabled),
.loading .form-actions {
    display: block !important;
    visibility: visible !important;
    pointer-events: auto !important;
    opacity: 1 !important;
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-left: 8px;
    vertical-align: middle;
}

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

/* Enhanced submit button styling */
.btn-primary.loading {
    background: linear-gradient(45deg, var(--primary-color), #0052a3);
    border-color: var(--primary-color);
}

.btn-primary.loading .loading-spinner {
    border-top-color: #ffffff;
}

/* Smooth fade transition for optional hide effect */
.btn.fade-out {
    opacity: 0;
    transform: scale(0.95);
    transition: all 0.3s ease;
    pointer-events: none;
}

.btn.fade-in {
    opacity: 1;
    transform: scale(1);
    transition: all 0.3s ease;
}

/* Override print media query for loading buttons */
@media print {
    .btn.loading,
    .btn:disabled {
        display: inline-block !important;
    }
    
    .form-actions:has(.btn.loading),
    .form-actions:has(.btn:disabled) {
        display: block !important;
    }
}

/* ============================================ */
/* Questionnaire-Specific Styles              */
/* ============================================ */

/* Additional styles for new question types */
.likert-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.likert-group .radio-label {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f9f9f9;
    transition: all 0.2s ease;
}

.likert-group .radio-label:hover {
    background: #e9ecef;
    border-color: #007bff;
}

.likert-group input[type="radio"]:checked + span {
    font-weight: 500;
    color: #007bff;
}

.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.checkbox-label {
    display: flex;
    align-items: flex-start;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #f9f9f9;
    transition: all 0.2s ease;
    cursor: pointer;
}

.checkbox-label:hover {
    background: #e9ecef;
    border-color: #007bff;
}

.checkbox-label input[type="checkbox"] {
    margin-top: 2px;
}

.question-description {
    font-size: 0.9em;
    color: #666;
    margin-top: 5px;
    margin-bottom: 10px;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 15px;
}

@media (max-width: 768px) {
    .form-grid-2, .form-grid-3 {
        grid-template-columns: 1fr;
    }
}

/* ============================================ */
/* BMI Calculator Styles                     */
/* ============================================ */

.bmi-display {
    background: var(--bg-light);
    padding: 20px;
    border-radius: var(--border-radius);
    border: 2px solid var(--border-color);
    text-align: center;
    margin-top: 10px;
}

.bmi-value {
    display: block;
    font-size: 2em;
    font-weight: 700;
    margin-bottom: 10px;
    padding: 15px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.bmi-category {
    display: block;
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 10px;
    padding: 10px;
    background: white;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
}

.bmi-description {
    font-size: 0.95em;
    line-height: 1.5;
    padding: 10px;
    background: white;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
}

/* BMI Color Indicators */
.bmi-value.severely-underweight { color: var(--error-color); }
.bmi-value.underweight { color: var(--warning-color); }
.bmi-value.normal { color: var(--success-color); }
.bmi-value.overweight { color: var(--warning-color); }
.bmi-value.obese { color: var(--error-color); }