/* ============================================================
   مكتب التميز - مولّد الدراسات التسويقية
   ============================================================ */

:root {
    /* ✨ v7.2: لوحة هوية معيار — أزرق #0099FF / داكن #1E1E1E / رمادي #4A4A4A */
    --primary: #0099FF;
    --primary-dark: #1C5089;
    --primary-light: #E5F4FF;
    --primary-darker: #143A63;
    --accent: #1E1E1E;
    --text: #1E1E1E;
    --text-light: #6B7280;
    --bg: #F7FAFD;
    --bg-card: #FFFFFF;
    --border: #E5E7EB;
    --shadow: 0 1px 3px rgba(0,0,0,0.05), 0 4px 12px rgba(0,0,0,0.04);
    --shadow-hover: 0 4px 16px rgba(0,153,255,0.18);
    --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Segoe UI', 'Tahoma', 'Arial', sans-serif;
    background: var(--bg);
    color: var(--text);
    direction: rtl;
    line-height: 1.6;
    min-height: 100vh;
}

/* ============ Header ============ */
.app-header {
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
    color: white;
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 12px rgba(0,153,255,0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header .container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.brand-icon {
    background: white;
    border-radius: 10px;
    padding: 0.4rem 0.6rem;
    display: flex; align-items: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.brand-icon img {
    height: 38px;
    width: auto;
}

.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 1.3rem; font-weight: 700; line-height: 1.2; }
.brand-tagline { font-size: 0.8rem; opacity: 0.85; line-height: 1.2; }

.nav-menu {
    display: flex; gap: 0.5rem;
    list-style: none;
    flex-wrap: wrap;
}

.nav-link {
    color: white;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: background 0.2s;
    font-weight: 500;
    font-size: 0.95rem;
}

.nav-link:hover, .nav-link.active {
    background: rgba(255,255,255,0.15);
}

/* ============ Container ============ */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

/* ============ Cards ============ */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 2rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border);
}

.card h2 {
    color: var(--primary-dark);
    margin-bottom: 1rem;
    font-size: 1.5rem;
    display: flex; align-items: center; gap: 0.5rem;
}

.card h3 {
    color: var(--text);
    margin: 1rem 0 0.75rem;
    font-size: 1.1rem;
}

/* ============ Hero ============ */
.hero {
    text-align: center;
    padding: 3rem 2rem;
    background: linear-gradient(135deg, var(--primary-light) 0%, white 100%);
    border-radius: var(--radius);
    margin-bottom: 2rem;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
}

.hero::before {
    content: '';
    position: absolute;
    top: -50px;
    left: -50px;
    width: 200px;
    height: 200px;
    background: var(--primary);
    border-radius: 50%;
    opacity: 0.08;
}

.hero::after {
    content: '';
    position: absolute;
    bottom: -80px;
    right: -80px;
    width: 250px;
    height: 250px;
    background: var(--primary-dark);
    border-radius: 50%;
    opacity: 0.05;
}

.hero h1 {
    font-size: 2.2rem;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    position: relative;
    z-index: 1;
}

.hero p {
    font-size: 1.1rem;
    color: var(--text-light);
    max-width: 700px;
    margin: 0 auto 1.5rem;
    position: relative;
    z-index: 1;
}

.hero .btn { position: relative; z-index: 1; }

/* ============ Buttons ============ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.7rem 1.5rem;
    border-radius: 10px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background: white;
    color: var(--primary);
    border: 2px solid var(--primary);
}

.btn-secondary:hover {
    background: var(--primary-light);
}

.btn-danger {
    background: #DC2626;
    color: white;
}

.btn-danger:hover { background: #B91C1C; }

.btn-large { padding: 1rem 2rem; font-size: 1.1rem; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ============ Form ============ */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.form-group .hint {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-bottom: 0.5rem;
}

input[type="text"], textarea, select {
    width: 100%;
    padding: 0.7rem 1rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="text"]:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,153,255,0.1);
}

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

/* ============ Tag Input ============ */
.tag-container {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 0.5rem;
    min-height: 50px;
    display: flex; flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.tag-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0,153,255,0.1);
}

.tag {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex; align-items: center; gap: 0.3rem;
}

.tag .remove {
    cursor: pointer;
    background: rgba(31,78,44,0.2);
    border-radius: 50%;
    width: 18px; height: 18px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem;
}

.tag .remove:hover { background: var(--primary); color: white; }

.tag-input {
    border: none;
    flex: 1;
    min-width: 120px;
    padding: 0.3rem;
    outline: none;
    font-size: 0.95rem;
    background: transparent;
}

/* ============ Sections Selector ============ */
.sections-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--bg);
    padding: 1rem;
    border-radius: var(--radius);
    border: 1.5px dashed var(--border);
}

.section-item {
    background: white;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
}

.section-item:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-hover);
}

.section-item.dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.section-item.dragover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.section-item .drag-handle {
    color: var(--text-light);
    font-size: 1.3rem;
    cursor: grab;
}

.section-item input[type="checkbox"] {
    width: 20px; height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}

.section-item .section-icon {
    font-size: 1.4rem;
    width: 36px;
    text-align: center;
}

.section-item .section-content { flex: 1; }

.section-item .section-title {
    font-weight: 600;
    color: var(--text);
    font-size: 1rem;
}

.section-item .section-desc {
    font-size: 0.85rem;
    color: var(--text-light);
    margin-top: 0.15rem;
}

.section-item .section-order {
    background: var(--primary);
    color: white;
    width: 28px; height: 28px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
}

.section-item:not(.selected) .section-order {
    visibility: hidden;
}

/* الأقسام المختارة افتراضياً - 11 قسم رئيسي */
.recommended-banner {
    background: linear-gradient(135deg, var(--primary-light) 0%, white 100%);
    border: 1px solid var(--primary);
    border-radius: 10px;
    padding: 1rem 1.5rem;
    margin-bottom: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.recommended-banner strong { color: var(--primary-dark); }

/* ============ Progress ============ */
.progress-container {
    background: white;
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow);
}

.progress-bar {
    height: 14px;
    background: var(--border);
    border-radius: 10px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    transition: width 0.4s;
    border-radius: 10px;
}

.progress-text {
    text-align: center;
    font-weight: 600;
    color: var(--primary-dark);
    font-size: 1.1rem;
}

.logs-container {
    background: #1E293B;
    color: #E2E8F0;
    border-radius: var(--radius);
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    direction: ltr;
    text-align: right;
    margin-top: 1rem;
}

.log-entry {
    padding: 0.3rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.log-time { color: #64748B; margin-left: 0.5rem; }

/* ============ Library ============ */
.studies-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.study-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.study-card::before {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 5px;
    height: 100%;
    background: var(--primary);
}

.study-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-2px);
}

.study-card .product-title {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.study-card .study-meta {
    color: var(--text-light);
    font-size: 0.9rem;
    margin: 0.25rem 0;
}

.study-card .study-meta strong { color: var(--text); }

.study-card .card-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.study-card .btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-light);
}

.empty-state .icon { font-size: 4rem; margin-bottom: 1rem; opacity: 0.5; }

/* ============ Edit Section Page ============ */
.section-edit-card {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.section-edit-card:hover { border-color: var(--primary); }

.section-edit-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 0.75rem;
    flex-wrap: wrap;
}

.section-edit-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

.section-edit-preview {
    color: var(--text-light);
    font-size: 0.9rem;
    line-height: 1.6;
    background: var(--bg);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin: 0.5rem 0;
    border-right: 3px solid var(--primary);
    max-height: 150px;
    overflow-y: auto;
}

.edit-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--border);
    display: none;
}

.edit-form.active { display: block; }

.modified-badge {
    background: #FEF3C7;
    color: #92400E;
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* ============ Compare ============ */
.compare-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.compare-table th, .compare-table td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.compare-table th {
    background: var(--primary);
    color: white;
    font-weight: 700;
}

.compare-table tr:hover { background: var(--bg); }

/* ============ Alerts ============ */
.alert {
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    display: flex; gap: 0.75rem; align-items: flex-start;
}

.alert-info {
    background: #DBEAFE;
    color: #1E40AF;
    border: 1px solid #93C5FD;
}

.alert-success {
    background: var(--primary-light);
    color: var(--primary-dark);
    border: 1px solid var(--primary);
}

.alert-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #FCA5A5;
}

/* ============ Spinner ============ */
.spinner {
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    width: 32px; height: 32px;
    animation: spin 1s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============ Misc ============ */
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.gap-2 { gap: 1rem; }
.justify-between { justify-content: space-between; align-items: center; flex-wrap: wrap; }

.badge {
    background: var(--primary-light);
    color: var(--primary-dark);
    padding: 0.2rem 0.7rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
}

/* ============ Footer ============ */
.app-footer {
    background: var(--primary-dark);
    color: white;
    padding: 1.5rem;
    margin-top: 3rem;
    text-align: center;
}

.app-footer .contact-info {
    display: flex;
    justify-content: center;
    gap: 2rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
    .container { padding: 1rem; }
    .hero h1 { font-size: 1.6rem; }
    .nav-menu { width: 100%; justify-content: center; }
    .studies-grid { grid-template-columns: 1fr; }
    .brand-name { font-size: 1.1rem; }
}

/* ============================================================
   v3 - أنماط جديدة
   ============================================================ */

/* === Dashboard === */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-top: 1rem;
}

.stat-box {
    background: white;
    padding: 1.2rem;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-label {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 0.3rem;
}

.stat-sub {
    color: var(--text-light);
    font-size: 0.75rem;
    margin-top: 0.2rem;
    opacity: 0.7;
}

.country-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.country-chip {
    background: white;
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    border: 1px solid var(--primary);
    font-size: 0.9rem;
    color: var(--primary-dark);
}

.country-chip strong {
    color: var(--primary);
}

.recent-list {
    display: grid;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.recent-item {
    background: white;
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-decoration: none;
    color: var(--text);
    transition: all 0.2s;
}

.recent-item:hover {
    border-color: var(--primary);
    transform: translateX(-3px);
    box-shadow: var(--shadow-hover);
}

.recent-item small {
    color: var(--text-light);
}

/* === Model modes selector === */
.model-modes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.mode-option {
    display: block;
    cursor: pointer;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem;
    transition: all 0.2s;
    background: white;
}

.mode-option:hover:not(.disabled) {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.mode-option input[type="radio"] {
    display: none;
}

.mode-option:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: var(--shadow-hover);
}

.mode-option.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mode-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.mode-desc {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.mode-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--text);
}

.mode-stats span {
    background: rgba(0, 169, 80, 0.08);
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
}

.key-missing-badge {
    background: #FEE2E2;
    color: #DC2626;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

.badge-success { background: #10B981; color: white; }
.badge-info { background: #3B82F6; color: white; }
.badge-warning { background: #F59E0B; color: white; }

/* === Section tags === */
.tag-mini {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-right: 0.5rem;
}

.tag-claude {
    background: #F3E8FF;
    color: #7C3AED;
}

.tag-gemini {
    background: #DBEAFE;
    color: #2563EB;
}

/* === Preview page === */
.preview-toc {
    position: sticky;
    top: 90px;
    z-index: 50;
    background: white;
    max-height: 60vh;
    overflow-y: auto;
}

.toc-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 0.4rem;
    margin-top: 0.5rem;
}

.toc-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    text-decoration: none;
    color: var(--text);
    background: var(--bg);
    font-size: 0.95rem;
    transition: all 0.15s;
}

.toc-link:hover {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.toc-num {
    color: var(--primary);
    font-weight: 700;
    min-width: 1.5rem;
}

.model-badge {
    margin-right: auto;
    font-size: 0.75rem;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
}

.model-claude { background: #F3E8FF; }
.model-gemini { background: #DBEAFE; }

.preview-section {
    scroll-margin-top: 100px;
}

.preview-section-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid var(--primary-light);
    flex-wrap: wrap;
}

.preview-section-header h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.section-num {
    background: var(--primary);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
}

/* Markdown styling in preview */
.markdown-content {
    line-height: 1.9;
    color: var(--text);
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3 {
    color: var(--primary-dark);
    margin: 1.5rem 0 0.8rem;
}

.markdown-content h1 { font-size: 1.6rem; }
.markdown-content h2 { font-size: 1.3rem; color: var(--primary); }
.markdown-content h3 { font-size: 1.1rem; }

.markdown-content p {
    margin-bottom: 0.8rem;
    text-align: justify;
}

.markdown-content strong {
    color: var(--primary-dark);
}

.markdown-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 1rem 0;
    background: white;
    box-shadow: var(--shadow);
    border-radius: var(--radius);
    overflow: hidden;
}

.markdown-content thead {
    background: var(--primary);
    color: white;
}

.markdown-content th,
.markdown-content td {
    padding: 0.7rem 1rem;
    text-align: right;
    border: 1px solid var(--border);
}

.markdown-content tbody tr:nth-child(even) {
    background: var(--bg);
}

.markdown-content ul, .markdown-content ol {
    margin: 0.5rem 1.5rem 1rem;
}

.markdown-content li {
    margin-bottom: 0.4rem;
}

.markdown-content code {
    background: var(--light-gray);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

/* === Modal === */
.modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background: white;
    border-radius: var(--radius);
    padding: 1.5rem;
    max-width: 900px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    padding: 0.5rem;
}

.modal-close:hover { color: var(--text); }

/* === Library filters === */
.library-filters .filter-form {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-end;
}

.library-filters .form-group { margin-bottom: 0; }

.mode-pill {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
}

.mode-hybrid { background: #DCFCE7; color: #15803D; }
.mode-claude_only { background: #F3E8FF; color: #7C3AED; }
.mode-gemini_only { background: #DBEAFE; color: #2563EB; }
.mode-gemini_pro { background: #FEF3C7; color: #A16207; }

/* === Range slider === */
input[type="range"] {
    width: 100%;
    height: 8px;
    border-radius: 4px;
    background: var(--border);
    outline: none;
    margin: 0.5rem 0;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 3px solid white;
    box-shadow: var(--shadow);
}

input[type="range"]::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 3px solid white;
}

/* === Responsive === */
@media (max-width: 768px) {
    .model-modes { grid-template-columns: 1fr; }
    .dashboard-stats { grid-template-columns: repeat(2, 1fr); }
    .preview-toc { position: relative; top: auto; max-height: none; }
    .filter-form { flex-direction: column; }
    .filter-form .form-group { width: 100%; }
}

/* ============================================================
   AI Review styling
   ============================================================ */
.review-summary {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.5rem;
}

.review-score {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-weight: 700;
}

.review-issue {
    background: white;
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    border-right: 3px solid #F59E0B;
}

.issue-type {
    background: #FEF3C7;
    color: #A16207;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.5rem;
}

.review-issue .suggestion {
    background: #ECFDF5;
    padding: 0.5rem 0.8rem;
    border-radius: 6px;
    color: #166534;
    margin-top: 0.5rem;
}

/* Suggestions box */
.suggestions-box {
    background: linear-gradient(135deg, #FEF3C7 0%, #FFFBEB 100%);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    border-right: 3px solid #F59E0B;
}

.suggestion-item {
    background: white;
    padding: 0.8rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.suggestion-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.4rem;
    flex-wrap: wrap;
}

.suggestion-item .impact {
    color: var(--primary-dark);
    margin-top: 0.4rem;
    font-size: 0.9rem;
}

/* AI Comparison */
.ai-overview {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 1.05rem;
    line-height: 1.7;
}

.diff-item {
    background: white;
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    border-right: 3px solid #3B82F6;
}

.diff-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin: 0.5rem 0;
    padding: 0.5rem;
    background: #F9FAFB;
    border-radius: 6px;
}

.diff-impact {
    background: #DBEAFE;
    color: #1E40AF;
    padding: 0.4rem 0.7rem;
    border-radius: 6px;
    margin-top: 0.4rem;
    font-size: 0.9rem;
}

/* ============================================================
   Toast notifications
   ============================================================ */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--primary-dark);
    color: white;
    padding: 0.9rem 1.5rem;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
    font-weight: 600;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-success { background: #10B981; }
.toast-error { background: #DC2626; }
.toast-info { background: #3B82F6; }

/* ============================================================
   Dark Mode
   ============================================================ */
[data-theme="dark"] {
    --bg: #0F172A;
    --text: #E2E8F0;
    --text-light: #94A3B8;
    --light-gray: #1E293B;
    --border: #334155;
    --primary-light: #064E3B;
}

[data-theme="dark"] body {
    background: var(--bg);
    color: var(--text);
}

[data-theme="dark"] .card,
[data-theme="dark"] .stat-box,
[data-theme="dark"] .mode-option,
[data-theme="dark"] .recent-item,
[data-theme="dark"] .study-card,
[data-theme="dark"] .review-summary,
[data-theme="dark"] .review-issue,
[data-theme="dark"] .suggestion-item,
[data-theme="dark"] .diff-item,
[data-theme="dark"] .ai-overview,
[data-theme="dark"] .modal-content {
    background: #1E293B !important;
    color: var(--text);
    border-color: #334155;
}

[data-theme="dark"] .markdown-content table {
    background: #1E293B;
}

[data-theme="dark"] .markdown-content tbody tr:nth-child(even) {
    background: #0F172A;
}

[data-theme="dark"] input,
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: #0F172A;
    color: var(--text);
    border-color: #334155;
}

[data-theme="dark"] .country-chip,
[data-theme="dark"] .toc-link {
    background: #1E293B;
    color: var(--text);
}

[data-theme="dark"] .preview-toc {
    background: #1E293B;
}

[data-theme="dark"] .diff-row { background: #0F172A; }

[data-theme="dark"] .btn-secondary {
    background: #334155;
    color: var(--text);
}

[data-theme="dark"] .btn-secondary:hover {
    background: #475569;
}

[data-theme="dark"] .progress-bar {
    background: #334155;
}

/* Theme toggle button */
.theme-toggle {
    background: none;
    border: 1px solid currentColor;
    color: white;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.15);
    transform: scale(1.1);
}

/* Print mode */
@media print {
    .nav-menu, .app-footer, .btn, .preview-section-header > div:last-child,
    .suggestions-box, #ai-review-box, .toast {
        display: none !important;
    }
    .card {
        box-shadow: none;
        border: 1px solid #ccc;
    }
}

/* === AI Suggestion box in edit page === */
.ai-sug-box {
    background: linear-gradient(135deg, #FEF3C7 0%, #FFFBEB 100%);
    padding: 0.8rem 1rem;
    border-radius: 8px;
    margin-bottom: 0.8rem;
    border-right: 3px solid #F59E0B;
}

.sug-list {
    display: grid;
    gap: 0.5rem;
}

.sug-item {
    background: white;
    padding: 0.7rem 0.9rem;
    border-radius: 6px;
}

/* btn-accent (للأزرار الذكية) */
.btn-accent {
    background: #F59E0B;
    color: white;
}

.btn-accent:hover {
    background: #D97706;
}

/* ============================================================
   v3.5 - Templates + References
   ============================================================ */

/* === Templates Grid === */
.templates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.8rem;
    margin-top: 1rem;
}

.template-card {
    background: white;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    gap: 0.7rem;
    align-items: flex-start;
}

.template-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
}

.template-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: var(--shadow-hover);
}

.template-icon {
    font-size: 2.2rem;
    line-height: 1;
}

.template-info {
    flex: 1;
}

.template-name {
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.2rem;
}

.template-desc {
    color: var(--text-light);
    font-size: 0.85rem;
    line-height: 1.4;
    margin-bottom: 0.4rem;
}

.template-meta {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.template-category {
    background: var(--bg);
    color: var(--text-light);
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
}

/* === Tips Toast === */
.tips-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #FEF3C7 0%, #FFFBEB 100%);
    border: 2px solid #F59E0B;
    border-radius: var(--radius);
    padding: 1rem 1.2rem;
    max-width: 400px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.15);
    z-index: 1000;
    transform: translateY(120%);
    transition: transform 0.4s ease;
}

.tips-toast.show {
    transform: translateY(0);
}

.tips-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.tips-header button {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    color: var(--text-light);
    padding: 0.2rem 0.5rem;
}

.tips-toast ul {
    margin: 0;
    padding-right: 1.5rem;
    line-height: 1.7;
    font-size: 0.9rem;
}

/* === References Page === */
.refs-summary {
    background: linear-gradient(135deg, var(--primary-light) 0%, #fff 100%);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    border-right: 4px solid var(--primary);
    margin-bottom: 1.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
}

.refs-stat {
    text-align: center;
}

.refs-stat-value {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary);
}

.refs-stat-label {
    color: var(--text-light);
    font-size: 0.85rem;
}

.ref-item {
    background: white;
    padding: 1rem 1.2rem;
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
    border-right: 3px solid var(--primary);
    box-shadow: var(--shadow);
}

.ref-num {
    background: var(--primary);
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    margin-left: 0.5rem;
    font-size: 0.85rem;
}

.ref-title {
    font-weight: 700;
    color: var(--text);
    font-size: 1.05rem;
}

.ref-url {
    margin-top: 0.4rem;
    direction: ltr;
    text-align: left;
}

.ref-url a {
    color: var(--primary);
    text-decoration: none;
    word-break: break-all;
    font-size: 0.85rem;
}

.ref-url a:hover {
    text-decoration: underline;
}

.ref-sections {
    margin-top: 0.5rem;
    color: var(--text-light);
    font-size: 0.85rem;
    font-style: italic;
}

.ref-type-badge {
    display: inline-block;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-right: 0.5rem;
}

.ref-type-web { background: #DBEAFE; color: #1E40AF; }
.ref-type-citation { background: #DCFCE7; color: #166534; }
.ref-type-listed { background: #FEF3C7; color: #92400E; }

/* === Numbers Consistency Report === */
.numbers-report {
    background: linear-gradient(135deg, #FEF3C7 0%, #FFFBEB 100%);
    border-right: 4px solid #F59E0B;
}

.inconsistency-item {
    background: white;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.6rem;
}

.inconsistency-topic {
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.inconsistency-values {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.7rem;
    margin: 0.5rem 0;
    background: #F9FAFB;
    padding: 0.6rem;
    border-radius: 6px;
}

.inconsistency-suggestion {
    background: #ECFDF5;
    padding: 0.5rem 0.7rem;
    border-radius: 6px;
    color: #166534;
    margin-top: 0.5rem;
    font-size: 0.9rem;
}

.severity-عالية { color: #DC2626; }
.severity-متوسطة { color: #F59E0B; }
.severity-منخفضة { color: #10B981; }
