/* === متغيرات الأنماط من الصفحة الرئيسية === */
:root {
    --primary: #1f6f78;
    --primary-dark: #155a61;
    --accent: #2aa79b;
    --accent-light: #3bc0b3;
    --bg: #f6fbfb;
    --card: #ffffff;
    --text: #0b2b33;
    --text-light: #6b7c86;
    --danger: #c94a4a;
    --warning: #e6a23c;
    --success: #67c23a;
    --radius: 14px;
    --shadow: 0 8px 24px rgba(11, 43, 46, 0.08);
    --shadow-hover: 0 12px 32px rgba(11, 43, 46, 0.12);
    --transition: all 0.3s ease;
}

[data-theme="dark"] {
    --primary: #2aa79b;
    --primary-dark: #1f6f78;
    --accent: #3bc0b3;
    --accent-light: #4dd8ca;
    --bg: #0c1a1c;
    --card: #14282c;
    --text: #e6f6f4;
    --text-light: #8ba6ab;
    --danger: #f56c6c;
    --warning: #e6a23c;
    --success: #67c23a;
}

/* === إعادة الضبط الأساسية === */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    scroll-behavior: smooth;
}

body {
    font-family: 'Cairo', 'Tajawal', sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.7;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: var(--transition);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* === مؤشر التقدم === */
.progress-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background-color: rgba(31, 111, 120, 0.1);
    z-index: 9999;
}

.loading-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    width: 0%;
    transition: width 0.3s ease;
}

/* === إضافة مؤشر حالة الاتصال === */
.connection-status {
    position: fixed;
    bottom: 80px;
    left: 20px;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: fadeIn 0.3s ease;
}

.connection-status.online {
    background-color: rgba(103, 194, 58, 0.2);
    color: var(--success);
    border: 1px solid rgba(103, 194, 58, 0.3);
}

.connection-status.offline {
    background-color: rgba(230, 162, 60, 0.2);
    color: var(--warning);
    border: 1px solid rgba(230, 162, 60, 0.3);
}

.server-online .test-card {
    border-left: 4px solid var(--success);
}

.server-offline .test-card {
    border-left: 4px solid var(--warning);
}

.server-offline .test-feature i.fa-paper-plane {
    color: var(--warning) !important;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* === الرأس === */
.page-header {
    background-color: var(--card);
    box-shadow: 0 2px 12px rgba(11, 43, 46, 0.06);
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(11, 43, 46, 0.03);
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: var(--text);
}

.logo-icon {
    font-size: 28px;
    color: var(--primary);
}

.logo-text {
    font-size: 20px;
    font-weight: 800;
}

.logo-highlight {
    color: var(--accent);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.sync-results {
    background-color: transparent;
    color: var(--primary);
    padding: 10px 18px;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    border: 2px solid var(--primary);
    cursor: pointer;
    font-family: inherit;
}

.sync-results:hover {
    background-color: rgba(31, 111, 120, 0.1);
    transform: translateY(-2px);
}

.sync-results:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.back-home {
    background-color: var(--primary);
    color: white;
    padding: 10px 18px;
    border-radius: var(--radius);
    text-decoration: none;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
}

.back-home:hover {
    background-color: var(--primary-dark);
    transform: translateY(-2px);
}

.theme-toggle {
    background: transparent;
    border: 1px solid rgba(11, 43, 46, 0.1);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text);
    transition: var(--transition);
}

.theme-toggle:hover {
    background-color: rgba(11, 43, 46, 0.05);
}

/* === محتوى الصفحة الرئيسية === */
.page-hero {
    padding: 60px 0 40px;
    text-align: center;
    background: linear-gradient(135deg, rgba(31, 111, 120, 0.05) 0%, rgba(42, 167, 155, 0.05) 100%);
    border-radius: 0 0 var(--radius) var(--radius);
    margin-bottom: 40px;
}

.page-title {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 15px;
    font-weight: 800;
}

.page-subtitle {
    font-size: 1.2rem;
    color: var(--text-light);
    max-width: 800px;
    margin: 0 auto 30px;
}

/* === قسمي الاختبارات === */
.tests-section {
    margin-bottom: 60px;
}

.section-header {
    text-align: center;
    margin-bottom: 40px;
}

.section-title {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 15px;
    font-weight: 800;
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -8px;
    right: 0;
    width: 60%;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), transparent);
    border-radius: 2px;
}

.section-subtitle {
    font-size: 1.1rem;
    color: var(--text-light);
    max-width: 700px;
    margin: 0 auto;
}

/* === التبويبات للتنقل بين الأقسام === */
.tabs-container {
    display: flex;
    justify-content: center;
    margin-bottom: 40px;
    border-bottom: 1px solid rgba(11, 43, 46, 0.1);
    padding-bottom: 5px;
}

.tab-btn {
    background: transparent;
    border: none;
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-light);
    cursor: pointer;
    position: relative;
    transition: var(--transition);
    margin: 0 5px;
}

.tab-btn:hover {
    color: var(--primary);
}

.tab-btn.active {
    color: var(--primary);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 0;
    width: 100%;
    height: 3px;
    background-color: var(--accent);
    border-radius: 2px;
}

/* === نظام التصفية === */
.filters-container {
    background-color: var(--card);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 30px;
}

.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.filter-group {
    flex: 1;
    min-width: 200px;
}

.filter-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--primary);
}

.filter-select, .filter-input {
    width: 100%;
    padding: 12px 15px;
    border-radius: 10px;
    border: 1px solid rgba(11, 43, 46, 0.1);
    background-color: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
}

.filter-select:focus, .filter-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(42, 167, 155, 0.1);
}

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

.btn {
    padding: 12px 24px;
    border-radius: 10px;
    border: none;
    font-family: inherit;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary {
    background-color: var(--accent);
    color: white;
}

.btn-primary:hover {
    background-color: var(--accent-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.btn-outline {
    background-color: transparent;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-outline:hover {
    background-color: rgba(31, 111, 120, 0.1);
}

/* === شبكة الاختبارات === */
.tests-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    margin-bottom: 40px;
}

.test-card {
    background-color: var(--card);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    transition: var(--transition);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.test-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
}

.test-header {
    padding: 20px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    position: relative;
}

.test-icon {
    font-size: 28px;
    margin-bottom: 10px;
}

.test-title {
    font-size: 1.3rem;
    font-weight: 800;
    margin-bottom: 5px;
}

.test-meta {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 0.9rem;
    opacity: 0.9;
}

.test-meta i {
    margin-left: 5px;
}

.test-content {
    padding: 20px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.test-description {
    color: var(--text-light);
    margin-bottom: 20px;
    flex-grow: 1;
}

.test-features {
    margin-bottom: 20px;
}

.test-feature {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.test-feature i {
    color: var(--accent);
}

.test-actions {
    display: flex;
    gap: 10px;
    margin-top: auto;
}

.test-actions .btn {
    flex: 1;
}

/* === مؤشر حالة === */
.no-results {
    grid-column: 1 / -1;
    text-align: center;
    padding: 50px;
    background-color: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.no-results i {
    font-size: 3rem;
    color: var(--text-light);
    margin-bottom: 20px;
}

.no-results h3 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 10px;
}

.no-results p {
    color: var(--text-light);
}

/* === الطوارئ والدعم === */
.emergency-section {
    background: linear-gradient(135deg, rgba(201, 74, 74, 0.1) 0%, rgba(201, 74, 74, 0.05) 100%);
    border-radius: var(--radius);
    padding: 30px;
    margin: 60px 0;
    text-align: center;
    border: 2px solid rgba(201, 74, 74, 0.2);
}

.emergency-title {
    color: var(--danger);
    font-size: 1.8rem;
    margin-bottom: 15px;
}

.emergency-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 25px;
}

.emergency-item {
    background-color: var(--card);
    padding: 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    flex: 1;
    min-width: 250px;
    max-width: 350px;
}

.emergency-item i {
    font-size: 2.5rem;
    color: var(--danger);
    margin-bottom: 15px;
}

.emergency-item h4 {
    color: var(--danger);
    margin-bottom: 10px;
}

/* === النافذة المنبثقة للاختبار === */
.modal-overlay {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(11, 43, 46, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal {
    background-color: var(--card);
    border-radius: var(--radius);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(11, 43, 46, 0.25);
    animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    padding: 25px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-radius: var(--radius) var(--radius) 0 0;
}

.modal-title {
    font-size: 1.5rem;
    font-weight: 800;
}

.modal-close {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.modal-body {
    padding: 25px;
}

.progress-bar {
    width: 100%;
    height: 10px;
    background-color: rgba(11, 43, 46, 0.1);
    border-radius: 5px;
    margin: 20px 0;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--accent), var(--primary));
    width: 0%;
    transition: width 0.5s ease;
    border-radius: 5px;
}

.question-container {
    margin-bottom: 30px;
}

.question-text {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text);
}

.options-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.option {
    padding: 15px;
    border-radius: 10px;
    border: 2px solid rgba(11, 43, 46, 0.1);
    background-color: var(--bg);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
}

.option:hover {
    border-color: var(--accent);
    background-color: rgba(42, 167, 155, 0.05);
}

.option input[type="radio"] {
    transform: scale(1.2);
}

.modal-footer {
    padding: 20px 25px;
    border-top: 1px solid rgba(11, 43, 46, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.result-container {
    padding: 25px;
    display: none;
}

.result-header {
    text-align: center;
    margin-bottom: 30px;
}

.result-score {
    font-size: 3rem;
    font-weight: 800;
    color: var(--primary);
    margin-bottom: 10px;
}

.result-level {
    font-size: 1.5rem;
    font-weight: 700;
    padding: 8px 20px;
    border-radius: 30px;
    display: inline-block;
    margin-bottom: 20px;
}

.level-low { background-color: rgba(103, 194, 58, 0.2); color: var(--success); }
.level-medium { background-color: rgba(230, 162, 60, 0.2); color: var(--warning); }
.level-high { background-color: rgba(201, 74, 74, 0.2); color: var(--danger); }

.result-details {
    background-color: rgba(11, 43, 46, 0.05);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 30px;
}

.result-actions {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

/* === قسم موافقة المريض === */
.consent-container {
    margin: 20px 0;
    padding: 20px;
    background-color: rgba(31, 111, 120, 0.05);
    border-radius: var(--radius);
    border: 1px solid rgba(31, 111, 120, 0.1);
}

.consent-checkbox {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 15px;
}

.consent-checkbox input[type="checkbox"] {
    margin-top: 5px;
    transform: scale(1.2);
}

.consent-label {
    cursor: pointer;
}

.consent-label strong {
    display: block;
    margin-bottom: 5px;
    color: var(--primary);
}

.consent-label small {
    color: var(--text-light);
    font-size: 0.9rem;
}

.send-status {
    margin-top: 15px;
    text-align: center;
    padding: 10px;
    border-radius: var(--radius);
    display: none;
}

.send-status.success {
    background-color: rgba(103, 194, 58, 0.1);
    color: var(--success);
    border: 1px solid rgba(103, 194, 58, 0.2);
}

.send-status.error {
    background-color: rgba(201, 74, 74, 0.1);
    color: var(--danger);
    border: 1px solid rgba(201, 74, 74, 0.2);
}

.send-status.warning {
    background-color: rgba(230, 162, 60, 0.1);
    color: var(--warning);
    border: 1px solid rgba(230, 162, 60, 0.2);
}

/* === التذييل === */
.page-footer {
    background-color: var(--card);
    padding: 40px 0 20px;
    margin-top: 60px;
    border-top: 1px solid rgba(11, 43, 46, 0.1);
}

.footer-content {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 30px;
    margin-bottom: 30px;
}

.footer-section {
    flex: 1;
    min-width: 250px;
}

.footer-title {
    font-size: 1.2rem;
    color: var(--primary);
    margin-bottom: 20px;
    font-weight: 700;
}

.footer-links {
    list-style: none;
}

.footer-links li {
    margin-bottom: 10px;
}

.footer-links a {
    color: var(--text-light);
    text-decoration: none;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 8px;
}

.footer-links a:hover {
    color: var(--accent);
    padding-right: 5px;
}

.footer-bottom {
    text-align: center;
    padding-top: 20px;
    border-top: 1px solid rgba(11, 43, 46, 0.1);
    color: var(--text-light);
    font-size: 0.9rem;
}

/* === زر العودة للأعلى === */
.scroll-top {
    position: fixed;
    bottom: 30px;
    left: 30px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(31, 111, 120, 0.3);
    transition: var(--transition);
}

.scroll-top:hover {
    background-color: var(--primary-dark);
    transform: translateY(-3px);
}

/* === تجاوبية === */
@media (max-width: 768px) {
    .page-title { font-size: 2rem; }
    .section-title { font-size: 1.7rem; }
    .tests-grid { grid-template-columns: 1fr; }
    .filters-row { flex-direction: column; }
    .filter-group { width: 100%; }
    .header-container { flex-direction: column; gap: 15px; }
    .tabs-container { flex-direction: column; }
    .tab-btn { width: 100%; margin: 5px 0; }
    .result-actions { flex-direction: column; }
    .emergency-content { flex-direction: column; }
    .scroll-top { bottom: 20px; left: 20px; width: 45px; height: 45px; }
    .connection-status { bottom: 70px; left: 15px; font-size: 10px; }
}

@media (max-width: 480px) {
    .container { padding: 0 15px; }
    .page-hero { padding: 40px 0 30px; }
    .modal-body { padding: 20px; }
    .modal-header { padding: 20px; }
}