/* =====================================================
   Noor Search — Chat UI Overrides  v4
   Professional, clean, modern AI-chat design
   ===================================================== */

/* ── Thread container ── */
.page-search .noor-search-thread-wrap {
    margin-top: 24px;
    padding-top: 0;
    border-top: none;
}

.page-search .noor-search-thread {
    display: flex;
    flex-direction: column;
    gap: 16px;
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
    max-height: none;
    overflow: visible;
}

/* ── Base message row ── */
.noor-msg {
    display: flex;
    align-items: flex-start;
    gap: 0;
    animation: noorMsgIn 0.25s ease both;
}

@keyframes noorMsgIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── User bubble (right-aligned) ── */
.noor-msg-user {
    justify-content: flex-end;
}

.noor-msg-user .noor-msg-body {
    max-width: min(72%, 680px);
    background: linear-gradient(135deg, rgba(212, 165, 116, 0.22) 0%, rgba(212, 165, 116, 0.12) 100%);
    border: 1px solid rgba(212, 165, 116, 0.5);
    border-radius: 20px 20px 4px 20px;
    padding: 12px 18px;
    font-size: 0.92rem;
    line-height: 1.6;
    color: var(--text-primary);
    font-weight: 500;
}

/* ── Assistant message (left-aligned, full card) ── */
.noor-msg-assistant {
    justify-content: flex-start;
    flex-direction: column;
    align-items: flex-start;
    max-width: min(100%, 820px);
    width: 100%;
}

.noor-msg-assistant .noor-msg-body {
    width: 100%;
    max-width: 100%;
    background: rgba(248, 250, 255, 0.97);
    border: 1px solid rgba(66, 86, 130, 0.16);
    border-radius: 4px 20px 20px 20px;
    padding: 18px 22px 16px;
    font-size: 0.92rem;
    line-height: 1.72;
    color: #1e2535;
    white-space: pre-wrap;
    box-shadow: 0 2px 12px rgba(50, 70, 120, 0.07);
}

.noor-msg-assistant .noor-msg-mode {
    margin-top: 0;
    margin-bottom: 8px;
}

/* Dark theme override */
[data-theme="dark"] .noor-msg-assistant .noor-msg-body {
    background: rgba(28, 36, 58, 0.95);
    border-color: rgba(100, 130, 200, 0.2);
    color: rgba(220, 228, 245, 0.93);
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.25);
}

/* ── Pending / thinking state ── */
.noor-msg-pending .noor-msg-body {
    color: var(--text-muted) !important;
    font-style: italic;
    border-style: dashed !important;
    opacity: 0.85;
    animation: noorBlink 1.8s ease-in-out infinite;
}

@keyframes noorBlink {

    0%,
    100% {
        opacity: 0.85;
    }

    50% {
        opacity: 0.55;
    }
}

/* ── Mode badge ── */
.noor-msg-mode {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-top: 8px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    background: rgba(66, 86, 130, 0.08);
    border: 1px solid rgba(66, 86, 130, 0.18);
    color: rgba(66, 86, 130, 0.75);
}

.noor-msg-mode::before {
    content: "✦";
    font-size: 0.65rem;
}

[data-theme="dark"] .noor-msg-mode {
    background: rgba(100, 130, 200, 0.12);
    border-color: rgba(100, 130, 200, 0.25);
    color: rgba(150, 180, 240, 0.7);
}

/* ── Sources block ── */
.noor-msg-sources {
    margin-top: 10px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(66, 86, 130, 0.04);
    border: 1px solid rgba(66, 86, 130, 0.12);
}

[data-theme="dark"] .noor-msg-sources {
    background: rgba(100, 130, 200, 0.07);
    border-color: rgba(100, 130, 200, 0.18);
}

.noor-msg-sources-title {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted);
    flex: 0 0 100%;
    margin-bottom: 2px;
}

.noor-msg-sources-title::before {
    content: "📚 ";
}

/* Source links row — premium 2-column grid */
.noor-msg-sources .noor-source-links-row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.noor-source-link {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 14px 38px 14px 16px;
    border-radius: 14px;
    border: 1px solid rgba(66, 86, 130, 0.18);
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.85) 0%, rgba(248, 250, 255, 0.95) 100%);
    text-decoration: none;
    transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

.noor-source-link::before {
    /* gold accent stripe on the left edge */
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: linear-gradient(180deg, var(--gold, #d4a574) 0%, var(--gold-light, #c8985a) 100%);
    opacity: 0;
    transition: opacity 0.22s ease;
}

.noor-source-link::after {
    /* discrete arrow indicator on the right */
    content: "→";
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.95rem;
    color: var(--text-muted, rgba(120, 140, 175, 0.55));
    opacity: 0.55;
    transition: all 0.22s ease;
}

.noor-source-link .noor-source-ar {
    font-family: "Noto Naskh Arabic", "Amiri", serif;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.45;
    color: #1a2950;
    direction: rtl;
    text-align: right;
}

.noor-source-link .noor-source-local {
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.35;
    color: rgba(80, 100, 140, 0.85);
    letter-spacing: 0.01em;
}

.noor-source-link:hover {
    border-color: rgba(212, 165, 116, 0.55);
    background: linear-gradient(135deg, rgba(255, 250, 240, 0.95) 0%, rgba(252, 245, 232, 1) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(40, 60, 110, 0.1), 0 2px 6px rgba(212, 165, 116, 0.15);
    text-decoration: none;
}

.noor-source-link:hover::before {
    opacity: 1;
}

.noor-source-link:hover::after {
    color: var(--gold, #d4a574);
    opacity: 1;
    transform: translateY(-50%) translateX(3px);
}

[data-theme="dark"] .noor-source-link {
    background: linear-gradient(135deg, rgba(26, 31, 56, 0.7) 0%, rgba(18, 22, 42, 0.85) 100%);
    border-color: rgba(100, 130, 200, 0.18);
}

[data-theme="dark"] .noor-source-link .noor-source-ar {
    color: rgba(200, 218, 255, 0.96);
}

[data-theme="dark"] .noor-source-link .noor-source-local {
    color: rgba(170, 190, 225, 0.78);
}

[data-theme="dark"] .noor-source-link:hover {
    border-color: rgba(212, 165, 116, 0.5);
    background: linear-gradient(135deg, rgba(36, 42, 70, 0.8) 0%, rgba(28, 33, 58, 0.9) 100%);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(212, 165, 116, 0.2);
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .noor-msg-user .noor-msg-body {
        max-width: 88%;
    }

    .noor-msg-assistant {
        max-width: 100%;
    }

    .noor-msg-assistant .noor-msg-body {
        padding: 14px 16px 12px;
    }
}

/* =====================================================
   Noor Search Pillar — Premium card (theme-aware)
   ===================================================== */
.noor-search-pillar {
    margin-top: 28px;
    padding: 28px 28px 24px;
    border-radius: 20px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    box-shadow: 0 8px 30px rgba(40, 60, 110, 0.08);
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .noor-search-pillar {
    background: linear-gradient(180deg, rgba(26, 31, 56, 0.7) 0%, rgba(18, 22, 42, 0.85) 100%);
    border-color: rgba(100, 130, 200, 0.18);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
}

.noor-search-pillar::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, transparent 0%, var(--gold) 30%, var(--gold-light) 50%, var(--gold) 70%, transparent 100%);
    opacity: 0.7;
}

.noor-search-head {
    margin-bottom: 18px;
}

.noor-search-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 11px;
    border-radius: 999px;
    background: var(--gold-tint-soft, rgba(212, 165, 116, 0.12));
    color: var(--gold);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    margin-bottom: 10px;
}

.noor-search-title {
    font-size: 1.45rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.25;
    margin: 4px 0 6px;
    letter-spacing: -0.01em;
}

.noor-search-sub {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0 0 12px;
    max-width: 640px;
}

.noor-search-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.noor-meta-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.72rem;
    font-weight: 500;
}

[data-theme="dark"] .noor-meta-chip {
    background: rgba(100, 130, 200, 0.08);
    border-color: rgba(100, 130, 200, 0.18);
}

/* Composer */
.noor-search-composer {
    margin-top: 18px;
}

.noor-search-input {
    width: 100%;
    min-height: 78px;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 0.95rem;
    line-height: 1.55;
    resize: vertical;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.noor-search-input::placeholder {
    color: var(--text-muted);
}

.noor-search-input:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px var(--gold-tint-soft, rgba(212, 165, 116, 0.18));
}

[data-theme="dark"] .noor-search-input {
    background: rgba(11, 14, 24, 0.6);
}

.noor-search-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.noor-search-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
}

.noor-search-btn:hover {
    border-color: var(--gold);
    color: var(--gold);
    transform: translateY(-1px);
}

.noor-search-btn-primary {
    background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
    color: #0B0E18;
    border-color: transparent;
    box-shadow: 0 4px 14px rgba(212, 165, 116, 0.28);
}

.noor-search-btn-primary:hover {
    color: #0B0E18;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(212, 165, 116, 0.4);
}

[data-theme="light"] .noor-search-btn-primary {
    color: #FFFFFF;
}

[data-theme="light"] .noor-search-btn-primary:hover {
    color: #FFFFFF;
}

/* Suggestions */
.noor-suggest-label {
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px dashed var(--border);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.noor-suggest-label.is-smart {
    color: var(--gold);
}

.noor-search-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.noor-suggest {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
    text-align: start;
}

.noor-suggest:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--gold-tint-soft, rgba(212, 165, 116, 0.08));
}

[data-theme="dark"] .noor-suggest {
    background: rgba(11, 14, 24, 0.5);
}

/* Empty thread state */
.noor-search-empty {
    text-align: center;
    color: var(--text-muted);
    font-style: italic;
    padding: 18px 0;
    font-size: 0.9rem;
}

/* Responsive */
@media (max-width: 640px) {
    .noor-search-pillar {
        padding: 22px 18px 18px;
        border-radius: 16px;
    }

    .noor-search-title {
        font-size: 1.2rem;
    }
}

/* =====================================================
   Empty-state explore (no search results)
   ===================================================== */
.search-empty-explore {
    margin-top: 28px;
    padding: 24px;
    border-radius: 18px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    box-shadow: 0 6px 24px rgba(40, 60, 110, 0.06);
}

[data-theme="dark"] .search-empty-explore {
    background: linear-gradient(180deg, rgba(26, 31, 56, 0.55) 0%, rgba(18, 22, 42, 0.7) 100%);
    border-color: rgba(100, 130, 200, 0.15);
}

.search-empty-explore-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--gold);
    margin: 0 0 16px;
}

.search-empty-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
}

.search-empty-group-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0 0 8px;
    padding-bottom: 6px;
    border-bottom: 1px dashed var(--border);
}

.search-empty-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.search-empty-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 12px;
    border-radius: 999px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.18s ease;
}

.search-empty-chip:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--gold-tint-soft, rgba(212, 165, 116, 0.08));
    text-decoration: none;
    transform: translateY(-1px);
}

[data-theme="dark"] .search-empty-chip {
    background: rgba(11, 14, 24, 0.5);
}

@media (max-width: 640px) {
    .search-empty-explore {
        padding: 18px 14px;
        border-radius: 14px;
    }

    .search-empty-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }
}

/* (source-link styles consolidated above) */