:root {
    --bg-main: #f0f4f8;
    --text-main: #334155;
    --nav-bg: linear-gradient(135deg, #0f172a 0%, #1e1b4b 100%);
    --card-bg: rgba(255, 255, 255, 0.85);
    --card-border: rgba(255, 255, 255, 0.6);
    --card-header: linear-gradient(to right, #ffffff, #f8fafc);
    --drop-border: #cbd5e1;
    --drop-bg: #ffffff;
    --drop-hover-bg: #eff6ff;
    --diff-bg: #fff;
    --diff-hdr: #f8fafc;
    --diff-border: #e9ecef;
}

[data-theme="dark"] {
    --bg-main: #0f172a;
    /* Slate 900 */
    --text-main: #e2e8f0;
    /* Slate 200 */
    --nav-bg: linear-gradient(135deg, #020617 0%, #0f172a 100%);
    /* Much darker slate */
    --card-bg: rgba(30, 41, 59, 0.85);
    /* Slate 800 */
    --card-border: rgba(51, 65, 85, 0.8);
    /* Slate 700 */
    --card-header: linear-gradient(to right, rgba(30, 41, 59, 1), rgba(15, 23, 42, 1));
    --drop-border: #475569;
    /* Slate 600 */
    --drop-bg: #1e293b;
    /* Slate 800 */
    --drop-hover-bg: #334155;
    /* Slate 700 */
    --diff-bg: #1e293b;
    --diff-hdr: #0f172a;
    --diff-border: #334155;
}

/* Dark mode: Tutorial card & Orama modal text visibility */
[data-theme="dark"] #tutorial-card .card-body,
[data-theme="dark"] #orama-explainer-modal .modal-body {
    color: #e2e8f0;
}

[data-theme="dark"] #tutorial-card .card-body p,
[data-theme="dark"] #tutorial-card .card-body h6,
[data-theme="dark"] #tutorial-card .card-body small,
[data-theme="dark"] #tutorial-card .card-body .text-muted,
[data-theme="dark"] #orama-explainer-modal .modal-body p,
[data-theme="dark"] #orama-explainer-modal .modal-body h6,
[data-theme="dark"] #orama-explainer-modal .modal-body small,
[data-theme="dark"] #orama-explainer-modal .modal-body .text-muted,
[data-theme="dark"] #orama-explainer-modal .modal-body td,
[data-theme="dark"] #orama-explainer-modal .modal-body th {
    color: #cbd5e1 !important;
}

[data-theme="dark"] #tutorial-card .card-body .fw-bold,
[data-theme="dark"] #orama-explainer-modal .modal-body .fw-bold {
    color: #f1f5f9 !important;
}

[data-theme="dark"] #orama-explainer-modal .modal-content {
    background: #1e293b;
}

[data-theme="dark"] #orama-explainer-modal .modal-body [style*="background: #f8fafc"],
[data-theme="dark"] #orama-explainer-modal .modal-body [style*="background: #f1f5f9"] {
    background: #334155 !important;
    border-color: #475569 !important;
}

[data-theme="dark"] #orama-explainer-modal .modal-body [style*="background: linear-gradient"] {
    background: linear-gradient(135deg, #1e3a5f, #1a3d2e) !important;
}

[data-theme="dark"] #orama-explainer-modal .modal-footer {
    background: #0f172a !important;
}

[data-theme="dark"] #orama-explainer-modal .table {
    --bs-table-bg: #1e293b;
    --bs-table-border-color: #475569;
}

[data-theme="dark"] #orama-explainer-modal .table-light {
    --bs-table-bg: #334155;
    color: #e2e8f0;
}

body {
    background-color: var(--bg-main);
    /* Softer, cooler off-white */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--text-main);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* RTL support for Hebrew */
[dir="rtl"] .me-2 {
    margin-right: 0 !important;
    margin-left: 0.5rem !important;
}

[dir="rtl"] .me-3 {
    margin-right: 0 !important;
    margin-left: 1rem !important;
}

[dir="rtl"] .ms-auto {
    margin-left: unset !important;
    margin-right: auto !important;
}

[dir="rtl"] .ms-1 {
    margin-left: 0 !important;
    margin-right: 0.25rem !important;
}

[dir="rtl"] .text-start {
    text-align: right !important;
}

[dir="rtl"] code {
    direction: ltr;
    display: inline-block;
}

.navbar {
    background: var(--nav-bg);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.navbar-brand {
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* Premium Tabs Styling */
.custom-tabs {
    border-bottom: 2px solid #e2e8f0;
}

.custom-tabs .nav-link {
    color: #64748b;
    font-weight: 600;
    border: none;
    border-bottom: 3px solid transparent;
    padding: 0.75rem 1.5rem;
    transition: all 0.3s ease;
    background: transparent;
    border-radius: 0;
}

.custom-tabs .nav-link:hover {
    color: #3b82f6;
    border-color: transparent;
}

.custom-tabs .nav-link.active {
    color: #2563eb;
    background: transparent;
    border-bottom: 3px solid #2563eb;
}

/* Subtab Question Pills */
.subtab-pills {
    border: none;
    padding: 0.5rem 0;
}

.subtab-pills .subtab-link {
    color: #64748b;
    font-weight: 600;
    font-size: 0.85rem;
    padding: 0.4rem 1rem;
    border-radius: 50px;
    background: transparent;
    border: 2px solid transparent;
    transition: all 0.25s ease;
}

.subtab-pills .subtab-link:hover {
    color: #6366f1;
    background: rgba(99, 102, 241, 0.08);
}

.subtab-pills .subtab-link.active {
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border-color: transparent;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

[data-theme="dark"] .subtab-pills .subtab-link {
    color: #94a3b8;
}

[data-theme="dark"] .subtab-pills .subtab-link:hover {
    color: #a5b4fc;
    background: rgba(99, 102, 241, 0.15);
}

[data-theme="dark"] .subtab-pills .subtab-link.active {
    color: #fff;
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
}

/* Tab / Subtab Close Buttons */
.tab-close-btn,
.subtab-close-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 18px;
    height: 18px;
    font-size: 14px;
    line-height: 16px;
    text-align: center;
    border-radius: 50%;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background-color 0.2s ease, color 0.2s ease;
    color: #64748b;
    background: transparent;
    z-index: 5;
}

.nav-item:hover .tab-close-btn,
.nav-item:hover .subtab-close-btn {
    opacity: 0.7;
}

.tab-close-btn:hover,
.subtab-close-btn:hover {
    opacity: 1 !important;
    background: #ef4444;
    color: #fff;
}

/* Tutorial Collapse Chevron */
.tutorial-chevron {
    transition: transform 0.3s ease;
}

[aria-expanded="false"] .tutorial-chevron {
    transform: rotate(-90deg);
}

.tab-pane {
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Drop Areas */
.drop-area {
    border: 2px dashed var(--drop-border);
    border-radius: 12px;
    text-align: center;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    cursor: pointer;
    background: var(--drop-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 80px;
    font-weight: 500;
}

.drop-area:hover,
.drop-area.over {
    border-color: #3b82f6;
    background-color: var(--drop-hover-bg);
    box-shadow: 0 8px 16px rgba(59, 130, 246, 0.12);
    color: #3b82f6 !important;
    transform: translateY(-2px);
}

.drop-area.border-success {
    border-color: #10b981 !important;
    border-style: solid;
    color: #10b981 !important;
    background-color: rgba(16, 185, 129, 0.1) !important;
    transform: none;
    box-shadow: none;
}

/* Cards */
.card {
    border-radius: 16px;
    border: 1px solid var(--card-border);
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    overflow: hidden;
    transition: all 0.3s ease;
}

.card:hover {
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

.card-header {
    border-bottom: 1px solid var(--card-border);
    background: var(--card-header);
}

.card-header.bg-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important;
    border: none;
}

.result {
    border: 1px solid #e2e8f0;
    transition: background-color 0.3s ease;
}

/* Diff table styling */
.diff-table-wrapper {
    background: var(--diff-bg);
    border-radius: 8px;
    padding: 1rem;
    transition: background-color 0.3s ease;
}

table.diff {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

table.diff th,
table.diff td {
    border: 1px solid var(--diff-border);
    padding: 10px 12px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 13px;
    vertical-align: top;
    white-space: pre-wrap;
    word-break: break-all;
    color: var(--text-main);
}

.diff_header {
    background-color: var(--diff-hdr);
    font-weight: bold;
    text-align: right;
    width: 40px;
    color: #94a3b8;
}

.diff_next {
    background-color: var(--diff-hdr);
    width: 15px;
}

.diff_add {
    background-color: rgba(22, 163, 74, 0.2);
    color: #22c55e;
}

.diff_chg {
    background-color: rgba(202, 138, 4, 0.2);
    color: #eab308;
}

.diff_sub {
    background-color: rgba(220, 38, 38, 0.2);
    color: #ef4444;
}

/* Dark theme specific overrides */
[data-theme="dark"] .modal-content,
[data-theme="dark"] .modal-header,
[data-theme="dark"] .modal-body {
    background-color: var(--bg-main) !important;
    border-color: var(--card-border) !important;
}

[data-theme="dark"] .text-dark {
    color: var(--text-main) !important;
}

[data-theme="dark"] .bg-white,
[data-theme="dark"] .bg-light {
    background-color: var(--card-bg) !important;
}

/* Alert Styling for Dark Mode */
[data-theme="dark"] .alert-primary {
    background-color: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: var(--text-main);
}

[data-theme="dark"] .alert-primary strong {
    color: #93c5fd;
}

[data-theme="dark"] .alert-primary .bi-info-circle-fill {
    color: #60a5fa;
}

[data-theme="dark"] .alert-primary code,
[data-theme="dark"] .alert-primary .bg-light {
    background-color: rgba(15, 23, 42, 0.5) !important;
    color: #fca5a5 !important;
    border: 1px solid rgba(51, 65, 85, 0.6);
}

/* Primary Button Enhancements */
.btn-primary {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    border: none;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.3);
}

.btn-primary:active {
    transform: translateY(1px);
}

/* Nav Social Icons */
.transition-transform {
    transition: transform 0.2s ease, filter 0.2s ease;
}

.hover-scale:hover {
    transform: scale(1.15) translateY(-2px);
    filter: brightness(1.2);
}

.opacity-75 {
    opacity: 0.75;
}

.opacity-75:hover {
    opacity: 1;
}

/* Pulsing dot for tutoring badge */
@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.4;
        transform: scale(0.7);
    }
}

/* ─── Code Editor (VS Code Style) ──────────────────────────────── */
.code-editor-wrapper {
    border-radius: 0 0 12px 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    border-top: none;
}

.code-editor-toolbar {
    background: #1e1e1e;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.code-editor-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.code-editor-filename {
    color: #ccc;
    font-size: 0.8rem;
    margin-left: 12px;
    font-family: 'Consolas', 'Courier New', monospace;
}

.code-editor-lang {
    color: #888;
    font-size: 0.7rem;
    margin-left: auto;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.code-editor-body {
    display: flex;
    background: #1e1e1e;
    min-height: 300px;
    max-height: 500px;
}

.code-editor-lines {
    background: #252526;
    color: #858585;
    padding: 16px 12px;
    text-align: right;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    user-select: none;
    min-width: 48px;
    overflow: hidden;
    border-right: 1px solid #333;
}

.code-editor-textarea {
    flex: 1;
    background: #1e1e1e;
    color: #d4d4d4;
    border: none;
    outline: none;
    resize: none;
    padding: 16px;
    font-family: 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    tab-size: 4;
    white-space: pre;
    overflow-x: auto;
    overflow-y: auto;
    min-height: 300px;
    max-height: 500px;
}

.code-editor-textarea::placeholder {
    color: #555;
}

.code-editor-textarea:focus {
    box-shadow: inset 0 0 0 1px #264f78;
}

[data-theme="dark"] .code-editor-wrapper {
    border-color: #475569;
}