﻿:root {
    --bg: #0b1020;
    --bg2: #0f1630;
    --panel: rgba(255,255,255,0.05);
    --panel2: rgba(255,255,255,0.03);
    --line: rgba(255,255,255,0.09);
    --text: #eef3ff;
    --muted: #afbad8;
    --primary: #6ea8fe;
    --primary2: #8f7cff;
    --success: #22c55e;
    --danger: #ff6b6b;
    --radius: 22px;
    --radius-sm: 16px;
    --shadow: 0 18px 45px rgba(0,0,0,0.28);
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
    background: linear-gradient(160deg, var(--bg) 0%, var(--bg2) 100%);
    color: var(--text);
}
.master-link {
    color: #2563eb;
    font-weight: 700;
    text-decoration: none;
}

    .master-link:hover {
        text-decoration: underline;
    }
body {
    font-family: "Inter", "Cairo", sans-serif;
    overflow-x: hidden;
}

    body.rtl {
        font-family: "Cairo", "Inter", sans-serif;
    }

a {
    color: inherit;
    text-decoration: none;
}

button, input, textarea, select {
    font: inherit;
}

.app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    min-height: 100vh;
}

body.rtl .app-shell {
    grid-template-columns: 1fr 280px;
}

.sidebar {
    padding: 28px;
    border-right: 1px solid var(--line);
    background: rgba(8, 12, 25, 0.78);
    backdrop-filter: blur(14px);
    position: sticky;
    top: 0;
    height: 100vh;
}

body.rtl .sidebar {
    border-right: 0;
    border-left: 1px solid var(--line);
    grid-column: 2;
}

body.rtl .main-content {
    grid-column: 1;
}

.brand-box {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 28px;
}

.brand-logo {
    width: 56px;
    height: 56px;
    border-radius: 18px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    color: #fff;
    font-size: 1.35rem;
    font-weight: 800;
    box-shadow: var(--shadow);
}

.brand-title {
    font-weight: 800;
    font-size: 1.08rem;
}

.brand-subtitle {
    color: var(--muted);
    font-size: .9rem;
}

.main-nav {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

    .main-nav a {
        padding: 14px 16px;
        border-radius: 16px;
        color: var(--muted);
        transition: .2s ease;
    }

        .main-nav a:hover {
            background: rgba(255,255,255,.05);
            color: #fff;
        }

.lang-switch {
    display: flex;
    gap: 10px;
    margin-top: 24px;
}

.lang-btn {
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(255,255,255,.04);
    border: 1px solid var(--line);
    color: var(--muted);
}

    .lang-btn.active {
        background: linear-gradient(135deg, var(--primary), var(--primary2));
        color: white;
        border-color: transparent;
    }

.main-content {
    padding: 26px;
    min-width: 0;
}

.topbar {
    margin-bottom: 18px;
}

.page-title {
    margin: 0;
    font-size: 2rem;
    font-weight: 800;
}

.page-subtitle {
    margin-top: 6px;
    color: var(--muted);
}

.page-body {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.section-card,
.hero-card,
.doc-card,
.chunk-card,
.artifact-card,
.stat-card {
    background: linear-gradient(180deg, rgba(255,255,255,.045), rgba(255,255,255,.025));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.section-card,
.hero-card {
    padding: 24px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 20px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.doc-grid,
.chunk-list,
.artifact-list,
.checkbox-grid {
    display: grid;
    gap: 16px;
}

.doc-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.chunk-list {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.artifact-list {
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
}

.checkbox-grid {
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.doc-card,
.chunk-card,
.stat-card {
    padding: 18px;
}

.doc-card {
    transition: transform .2s ease;
}

    .doc-card:hover {
        transform: translateY(-3px);
    }

.doc-type {
    color: #bfd7ff;
    font-size: .82rem;
    font-weight: 700;
    text-transform: uppercase;
}

.section-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
    min-width: 0;
}

    .section-head > div {
        min-width: 0;
        flex: 1 1 auto;
    }

    .section-head h2,
    .section-head h3 {
        margin: 0;
        min-width: 0;
        max-width: 100%;
        overflow-wrap: anywhere;
        word-break: break-word;
        white-space: normal;
        line-height: 1.5;
    }

.pill {
    flex-shrink: 0;
}
.section-card.card-limit {
    max-height: 420px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

    .section-card.card-limit .card-scroll {
        overflow-y: auto;
        overflow-x: hidden;
        max-height: 340px;
        padding-right: 6px;
    }

    .section-card.card-limit * {
        overflow-wrap: anywhere;
        word-break: break-word;
    }
body.rtl .section-head {
    flex-direction: row-reverse;
}



.muted {
    color: var(--muted);
}

.info-list {
    display: grid;
    gap: 10px;
    line-height: 1.75;
    color: #dbe5ff;
}

.chips-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

body.rtl .chips-wrap {
    justify-content: flex-start;
}

.chip,
.hero-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
}

.chip {
    background: rgba(255,255,255,.06);
    color: #e7efff;
    padding: 8px 12px;
    font-size: .88rem;
}

.pill {
    background: rgba(143,124,255,.18);
    color: #ddd5ff;
    padding: 7px 12px;
    font-size: .82rem;
    font-weight: 700;
}

.hero-badge {
    background: rgba(110,168,254,.16);
    color: #cfe0ff;
    padding: 8px 14px;
    font-size: .84rem;
    font-weight: 700;
}

.action-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 18px;
}

body.rtl .action-row {
    flex-direction: row-reverse;
}

.btn {
    border: 0;
    border-radius: 16px;
    padding: 13px 18px;
    font-weight: 800;
    cursor: pointer;
    transition: .2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

    .btn:hover {
        transform: translateY(-1px);
    }

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, var(--primary), var(--primary2));
}

.btn-secondary {
    color: #fff;
    background: rgba(255,255,255,.08);
    border: 1px solid var(--line);
}

.btn-ghost {
    color: #d9e6ff;
    background: transparent;
    border: 1px solid var(--line);
}

.upload-wrap {
    max-width: 900px;
}

.upload-form {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.upload-zone {
    padding: 26px;
    border-radius: 20px;
    border: 2px dashed rgba(255,255,255,.12);
    background: rgba(255,255,255,.03);
}

.upload-label {
    display: block;
    margin-bottom: 10px;
    font-weight: 700;
}

.file-input,
.master-input-row input[type="text"] {
    width: 100%;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.04);
    color: white;
    padding: 14px;
    outline: none;
}

    .file-input::file-selector-button {
        border: 0;
        border-radius: 12px;
        padding: 10px 12px;
        margin-right: 10px;
        background: linear-gradient(135deg, var(--primary), var(--primary2));
        color: white;
        cursor: pointer;
    }

body.rtl .file-input::file-selector-button {
    margin-right: 0;
    margin-left: 10px;
}

.status-box,
.empty-box {
    padding: 18px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.03);
}

    .status-box.success {
        border-color: rgba(34,197,94,.35);
    }

    .status-box.error {
        border-color: rgba(255,107,107,.35);
    }

.check-card {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 68px;
    padding: 16px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.03);
}

body.rtl .check-card {
    flex-direction: row-reverse;
}

.check-card input {
    transform: scale(1.15);
    accent-color: var(--primary);
}

.workspace-grid {
    display: grid;
    grid-template-columns: 360px 1fr;
    gap: 20px;
    align-items: start;
}

body.rtl .workspace-grid {
    grid-template-columns: 1fr 360px;
}

.sticky-panel {
    position: sticky;
    top: 20px;
}

body.rtl .sticky-panel {
    order: 2;
}

.artifact-card {
    padding: 0;
    min-height: 420px;
    max-height: 420px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.artifact-top {
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: rgba(255,255,255,.02);
    flex-shrink: 0;
}

body.rtl .artifact-top {
    flex-direction: row-reverse;
}

.artifact-body {
    padding: 16px 18px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: 360px;
    font-size: .95rem;
    line-height: 1.7;
}


.chunk-card {
    min-height: 260px;
    display: flex;
    flex-direction: column;
}

.scroll-box {
    overflow: auto;
    max-height: 220px;
    line-height: 1.8;
    padding-right: 6px;
    color: #e3ebff;
    white-space: pre-wrap;
    word-break: break-word;
}

body.rtl .scroll-box {
    padding-right: 0;
    padding-left: 6px;
}

.compact-scroll {
    overflow: auto;
    max-height: 280px;
}

pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    font-size: .95rem;
    line-height: 1.8;
}

.render-block {
    display: grid;
    gap: 14px;
}

.render-section {
    background: rgba(255,255,255,.03);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 14px;
}

    .render-section h4 {
        margin: 0 0 10px;
        font-size: 1rem;
        font-weight: 700;
    }

    .render-section p {
        margin: 0 0 10px;
        font-size: .95rem;
        line-height: 1.8;
        color: #e5edff;
    }

    .render-section ul {
        margin: 0;
        padding-left: 18px;
    }

    .render-section li {
        font-size: .95rem;
        line-height: 1.8;
        color: #e5edff;
    }

body.rtl .render-section ul {
    padding-left: 0;
    padding-right: 18px;
}

.master-fab {
    position: fixed;
    right: 22px;
    bottom: 22px;
    width: 66px;
    height: 66px;
    border-radius: 22px;
    border: 0;
    z-index: 1200;
    color: white;
    font-weight: 800;
    font-size: 1.15rem;
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    box-shadow: 0 20px 40px rgba(0,0,0,.35);
    cursor: pointer;
}

body.rtl .master-fab {
    right: auto;
    left: 22px;
}

.master-panel {
    position: fixed;
    right: 22px;
    bottom: 100px;
    width: 390px;
    max-width: calc(100vw - 24px);
    height: 560px;
    z-index: 1200;
    display: none;
    flex-direction: column;
    padding: 18px;
    border-radius: 24px;
    border: 1px solid var(--line);
    background: rgba(10,15,30,.93);
    backdrop-filter: blur(18px);
    box-shadow: 0 25px 60px rgba(0,0,0,.45);
}

body.rtl .master-panel {
    right: auto;
    left: 22px;
}

.master-panel.open {
    display: flex;
}

.master-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 14px;
}

body.rtl .master-header {
    flex-direction: row-reverse;
}

.master-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

body.rtl .master-header-left {
    flex-direction: row-reverse;
}

.master-icon {
    width: 46px;
    height: 46px;
    border-radius: 16px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--primary), var(--primary2));
    font-weight: 800;
}

.master-close {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.06);
    color: #fff;
    cursor: pointer;
}

.master-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 12px;
}
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 18px;
}

    .typing-indicator span {
        width: 6px;
        height: 6px;
        background: #2563eb;
        border-radius: 50%;
        display: inline-block;
        animation: typingBounce 1.2s infinite ease-in-out;
    }

        .typing-indicator span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .typing-indicator span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.5);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}
body.rtl .master-suggestions {
    flex-direction: row-reverse;
}
.master-link {
    color: #2563eb;
    font-weight: 700;
    text-decoration: none;
}

    .master-link:hover {
        text-decoration: underline;
    }

.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 18px;
}

    .typing-indicator span {
        width: 6px;
        height: 6px;
        background: #2563eb;
        border-radius: 50%;
        display: inline-block;
        animation: typingBounce 1.2s infinite ease-in-out;
    }

        .typing-indicator span:nth-child(2) {
            animation-delay: 0.2s;
        }

        .typing-indicator span:nth-child(3) {
            animation-delay: 0.4s;
        }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0.5);
        opacity: 0.4;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}
.master-suggestion {
    border: 1px solid var(--line);
    background: rgba(255,255,255,.04);
    color: #dde8ff;
    padding: 8px 10px;
    border-radius: 999px;
    cursor: pointer;
    font-size: .84rem;
}

.master-messages {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 10px 2px;
}

.msg {
    max-width: 84%;
    padding: 14px 16px;
    border-radius: 18px;
    line-height: 1.7;
    white-space: pre-wrap;
}

    .msg.user {
        align-self: flex-end;
        background: rgba(110,168,254,.18);
    }

    .msg.assistant {
        align-self: flex-start;
        background: rgba(255,255,255,.06);
    }

body.rtl .msg.user {
    align-self: flex-start;
}

body.rtl .msg.assistant {
    align-self: flex-end;
}

.master-input-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
}

.list-clean {
    margin: 0;
    padding-left: 18px;
    line-height: 1.8;
}

body.rtl .list-clean {
    padding-left: 0;
    padding-right: 18px;
}

.mt-16 {
    margin-top: 16px;
}

.mt-20 {
    margin-top: 20px;
}

@media (max-width: 1200px) {
    .workspace-grid {
        grid-template-columns: 1fr;
    }

    body.rtl .workspace-grid {
        grid-template-columns: 1fr;
    }

    .sticky-panel {
        position: static;
    }
}

@media (max-width: 980px) {
    .app-shell {
        grid-template-columns: 1fr;
    }

    body.rtl .app-shell {
        grid-template-columns: 1fr;
    }

    .sidebar {
        position: static;
        height: auto;
        border-right: 0;
        border-bottom: 1px solid var(--line);
    }

    body.rtl .sidebar {
        border-left: 0;
    }

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }

    .artifact-list {
        grid-template-columns: 1fr;
    }

    .master-panel {
        width: auto;
        right: 12px;
        left: 12px;
        height: 70vh;
    }

    body.rtl .master-panel {
        right: 12px;
        left: 12px;
    }

    .master-fab {
        right: 12px;
        bottom: 12px;
    }

    body.rtl .master-fab {
        left: 12px;
        right: auto;
    }

    .chunk-paragraph {
        margin: 0 0 2px;
        line-height: 1.5;
        font-size: .95rem;
        color: #e5edff;
        white-space: normal;
    }

        .chunk-paragraph:last-child {
            margin-bottom: 0;
        }

    .chunk-card h4 {
        margin: 0 0 12px;
        font-size: 1rem;
        line-height: 1.5;
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    .scroll-box {
        overflow-y: auto;
        overflow-x: hidden;
        max-height: 220px;
        padding-right: 4px;
        line-height: 1.6;
        word-break: break-word;
        overflow-wrap: anywhere;
    }

    .chip-ai {
        background: linear-gradient(135deg, #6366f1, #8b5cf6);
        color: #fff;
        font-weight: 700;
        border: none;
    }
    .doc-card-shell {
        padding: 0;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .doc-card-main {
        display: block;
        padding: 18px;
        flex: 1;
        transition: background .2s ease;
    }

        .doc-card-main:hover {
            background: rgba(255,255,255,.02);
        }

    .doc-card-shell:hover {
        transform: translateY(-3px);
    }

    .doc-card-actions {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
        padding: 14px 18px 18px;
        border-top: 1px solid var(--line);
    }

    body.rtl .doc-card-actions {
        flex-direction: row-reverse;
    }

    .doc-delete-form {
        margin: 0;
    }

    .btn-sm {
        padding: 10px 14px;
        border-radius: 14px;
        font-size: .88rem;
        font-weight: 700;
    }

    .btn-danger {
        color: #fff;
        background: linear-gradient(135deg, #ef4444, #dc2626);
    }
}
