:root {
    --bg-color: #f8f9fb;
    --navy-deep: #0f172a;
    --navy-light: #1e293b;
    --gold: #d4af37;
    --gold-light: #f1e4bc;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --white: #ffffff;
    --accent: #2563eb;
    --user-msg-bg: #e2e8f0;
    --assistant-msg-bg: transparent;
    --border-color: #e2e8f0;
    --glass-bg: rgba(255, 255, 255, 0.8);
}

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

body {
    font-family: 'IBM Plex Sans Arabic', 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(at 0% 0%, hsla(220, 100%, 95%, 1) 0, transparent 50%),
        radial-gradient(at 100% 100%, hsla(220, 100%, 98%, 1) 0, transparent 50%);
    color: var(--text-primary);
    height: 100vh;
    width: 100vw;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Navbar */
.navbar {
    width: 100%;
    padding: 1.25rem 5%;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    z-index: 100;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.parliament-logo {
    height: 3.5rem;
    width: auto;
    object-fit: contain;
}

.logo-text {
    font-family: 'IBM Plex Sans Arabic', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--navy-deep);
    letter-spacing: -0.5px;
}

.nav-tagline {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    flex: 1;
    text-align: left;
}

/* Container */
.main-container {
    width: 100%;
    max-width: 900px;
    flex: 1;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding-top: 80px;
    position: relative;
    min-height: 0;
}

/* Chat History */
.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-thumb {
    background-color: var(--border-color);
    border-radius: 10px;
}

/* Messages */
.message {
    max-width: 85%;
    padding: 1.25rem 1.5rem;
    font-size: 1.05rem;
    line-height: 1.7;
    position: relative;
    animation: fadeIn 0.3s ease-out;
}

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

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

.user-message {
    align-self: flex-start;
    /* Since it's RTL by default, flex-start is right */
    background: var(--navy-deep);
    color: white;
    border-radius: 1.5rem 1.5rem 0.25rem 1.5rem;
    box-shadow: 0 4px 15px rgba(15, 23, 42, 0.1);
}

.assistant-message {
    align-self: flex-end;
    background: var(--white);
    color: var(--text-primary);
    border-radius: 1.5rem 1.5rem 1.5rem 0.25rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

/* Intro Message Special Styling */
.intro-message {
    max-width: 100%;
    margin: auto;
    text-align: center;
    background: transparent;
    border: none;
    box-shadow: none;
}

.intro-content h1 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--navy-deep);
    font-weight: 800;
}

.intro-content p {
    color: var(--text-secondary);
    font-size: 1.2rem;
    max-width: 700px;
    margin: 0 auto 1.5rem auto;
}

.intro-subtitle {
    font-weight: 500;
}

.features-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    text-align: right;
    margin-bottom: 2rem;
    background: rgba(255, 255, 255, 0.5);
    padding: 2rem;
    border-radius: 1.5rem;
    border: 1px solid var(--border-color);
}

.feature-section h3 {
    font-size: 1rem;
    color: var(--navy-deep);
    margin-bottom: 1rem;
    font-weight: 700;
}

.feature-list {
    list-style: none;
    padding: 0;
}

.feature-list li {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    position: relative;
    padding-right: 1.25rem;
}

.feature-list li::before {
    content: "•";
    position: absolute;
    right: 0;
    color: var(--gold);
    font-weight: bold;
}

.poc-note {
    background: #fffbeb;
    border: 1px solid #fef3c7;
    padding: 1rem;
    border-radius: 1rem;
    margin-bottom: 2rem;
    font-size: 0.9rem;
    color: #b45309;
}

.poc-note a {
    color: var(--accent);
    text-decoration: none;
    font-weight: 600;
}

.suggestions-label {
    font-weight: 600;
    font-size: 0.9rem !important;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 1rem !important;
}

.suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}

.suggestion-btn {
    background: var(--white);
    border: 1px solid var(--border-color);
    padding: 0.6rem 1.25rem;
    border-radius: 2rem;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--navy-light);
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-btn:hover {
    border-color: var(--navy-deep);
    background: var(--navy-deep);
    color: white;
    transform: translateY(-2px);
}

/* Markdown Styling in Assistant Messages */
.assistant-message h1,
.assistant-message h2,
.assistant-message h3 {
    margin: 1.5rem 0 0.75rem 0;
    color: var(--navy-deep);
}

.assistant-message p {
    margin-bottom: 1rem;
}

.assistant-message ul,
.assistant-message ol {
    margin-bottom: 1rem;
    padding-right: 1.5rem;
}

.assistant-message li {
    margin-bottom: 0.5rem;
}

.assistant-message hr {
    border: 0;
    border-top: 1px solid var(--border-color);
    margin: 1.5rem 0;
}

/* Input Area */
.input-area-wrapper {
    padding: 1.5rem 1rem 3rem 1rem;
    background: transparent;
}

.input-container {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    padding: 0.6rem 1rem;
    display: flex;
    align-items: flex-end;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-container:focus-within {
    border-color: var(--navy-deep);
    box-shadow: 0 10px 25px rgba(15, 23, 42, 0.1);
}

#message-input {
    flex: 1;
    border: none;
    outline: none;
    padding: 0.75rem 0.5rem;
    font-size: 1.1rem;
    font-family: inherit;
    background: transparent;
    resize: none;
    max-height: 150px;
}

#send-btn {
    background: var(--navy-deep);
    color: white;
    border: none;
    border-radius: 1rem;
    width: 3.5rem;
    height: 3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0.2rem;
}

#send-btn:hover {
    background: var(--navy-light);
    transform: scale(1.02);
}

#send-btn:active {
    transform: scale(0.95);
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    gap: 0.5rem;
    padding: 1.25rem 1.5rem;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 1.5rem;
    width: fit-content;
    margin-right: auto;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: var(--navy-deep);
    border-radius: 50%;
    opacity: 0.3;
    animation: pulse 1.4s infinite ease-in-out both;
}

.dot:nth-child(1) {
    animation-delay: -0.32s;
}

.dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes pulse {

    0%,
    80%,
    100% {
        transform: scale(0.6);
        opacity: 0.3;
    }

    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* RTL/LTR Utils */
[dir="rtl"] .user-message {
    border-radius: 1.5rem 1.5rem 0.25rem 1.5rem;
    align-self: flex-start;
}

[dir="rtl"] .assistant-message {
    border-radius: 1.5rem 1.5rem 1.5rem 0.25rem;
    align-self: flex-end;
}

.rtl {
    direction: rtl;
    text-align: right;
}

.ltr {
    direction: ltr;
    text-align: left;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .navbar {
        padding: 0.75rem 4%;
        flex-direction: column;
        gap: 0.5rem;
        height: auto;
    }

    .parliament-logo {
        height: 2.5rem;
    }

    .logo-text {
        font-size: 1.1rem;
    }

    .nav-tagline {
        display: none;
    }

    .nav-tabs {
        width: 100%;
        justify-content: center;
        gap: 0.5rem;
    }

    .tab-btn {
        font-size: 0.9rem;
        padding: 0.4rem 0.8rem;
    }

    .main-container {
        padding-top: 130px;
        /* More space for stacked navbar */
    }

    .intro-content h1 {
        font-size: 1.75rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
        padding: 1.25rem;
    }

    .message {
        max-width: 92%;
        padding: 1rem;
        font-size: 0.95rem;
    }

    .input-area-wrapper {
        padding: 1rem 0.5rem 2rem 0.5rem;
    }

    .input-container {
        padding: 0.4rem 0.75rem;
    }

    #message-input {
        font-size: 1rem;
    }

    #send-btn {
        width: 3rem;
        height: 2.8rem;
    }

    /* How it works mobile */
    .how-container {
        padding-top: 140px;
    }

    .how-hero h1 {
        font-size: 1.8rem;
    }

    .pipeline-step {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 1.5rem;
    }

    .step-arrow {
        display: none;
    }

    .tech-badges {
        justify-content: center;
    }

    .stack-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Tabs */
.nav-tabs {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex: 2;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 2rem;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: var(--navy-deep);
    background: rgba(15, 23, 42, 0.05);
}

.tab-btn.active {
    color: white;
    background: var(--navy-deep);
}

.hidden {
    display: none !important;
}

/* How It Works Section */
.how-container {
    width: 100%;
    max-width: 1000px;
    flex: 1;
    margin: 0 auto;
    overflow-y: auto;
    padding: 100px 2rem 3rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 3rem;
    scrollbar-width: thin;
    min-height: 0;
}

.how-hero {
    text-align: center;
    margin-bottom: 1rem;
}

.how-hero-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
}

.how-hero h1 {
    font-size: 2.5rem;
    color: var(--navy-deep);
    margin-bottom: 0.5rem;
}

.how-hero p {
    font-size: 1.2rem;
    color: var(--text-secondary);
}

/* Pipeline */
.how-pipeline {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
}

.pipeline-step {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
    background: var(--white);
    padding: 2rem;
    border-radius: 1.5rem;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.03);
    position: relative;
    z-index: 1;
}

.step-number {
    background: var(--gold);
    color: white;
    width: 2.5rem;
    height: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-weight: bold;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.step-icon {
    font-size: 2.5rem;
    flex-shrink: 0;
}

.step-content {
    flex: 1;
}

.step-content h3 {
    color: var(--navy-deep);
    margin-bottom: 0.5rem;
    font-size: 1.3rem;
}

.step-content p {
    color: var(--text-secondary);
    line-height: 1.6;
}

.step-arrow {
    position: absolute;
    bottom: -2rem;
    left: 50%;
    transform: translateX(-50%) rotate(-90deg);
    font-size: 1.5rem;
    color: var(--gold);
    z-index: 0;
}

.pipeline-step.last .step-arrow {
    display: none;
}

/* Badges */
.tech-badges {
    display: flex;
    gap: 0.5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 1rem;
    font-size: 0.85rem;
    font-weight: 600;
}

.badge-blue {
    background: #e0f2fe;
    color: #0369a1;
}

.badge-green {
    background: #dcfce7;
    color: #15803d;
}

.badge-purple {
    background: #f3e8ff;
    color: #7e22ce;
}

.badge-orange {
    background: #ffedd5;
    color: #c2410c;
}

.mt-sm {
    margin-top: 0.5rem;
}

/* Stack Grid */
.how-stack {
    margin-top: 2rem;
}

.how-stack h2 {
    text-align: center;
    color: var(--navy-deep);
    margin-bottom: 2rem;
    font-size: 1.8rem;
}

.stack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.stack-card {
    background: var(--white);
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid var(--border-color);
    text-align: center;
    transition: transform 0.2s;
}

.stack-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.05);
}

.stack-icon {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.stack-card h4 {
    color: var(--navy-deep);
    margin-bottom: 0.5rem;
}

.stack-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Disclaimer */
.how-disclaimer {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: #fffbeb;
    border: 1px solid #fef3c7;
    padding: 1.5rem;
    border-radius: 1rem;
    margin-top: 2rem;
}

.disclaimer-icon {
    font-size: 1.5rem;
}

.how-disclaimer p {
    color: #b45309;
    font-weight: 500;
    margin: 0;
}

/* Footer */
.app-footer {
    width: 100%;
    background: var(--glass-bg);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-top: 1px solid var(--border-color);
    padding: 0.75rem 2rem;
    z-index: 100;
}

.footer-content {
    max-width: 900px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-secondary);
}

.copyright-note {
    font-size: 1rem;
    font-weight: 500;
}

.holonox-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1rem;
    font-weight: 600;
}

.holonox-logo {
    height: 1.5rem;
    width: auto;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.holonox-logo:hover {
    opacity: 1;
}

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
}
/* Source tags (law / parliament) */
.source-tags {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    max-width: 900px;
    margin: 0 auto 0.6rem auto;
    padding: 0 0.25rem;
}

.source-tags-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.source-tags-hint {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.source-tag {
    --tag-bg: #f3e8ff;
    --tag-fg: #7e22ce;
    display: inline-flex;
    align-items: center;
    padding: 0.3rem 0.85rem;
    border-radius: 1rem;
    border: 1px solid var(--tag-fg);
    background: var(--white);
    color: var(--tag-fg);
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.source-tag[data-source="parliament"] {
    --tag-bg: #ffedd5;
    --tag-fg: #c2410c;
}

.source-tag:hover,
.source-tag.active,
.source-tag.static {
    background: var(--tag-bg);
}

.source-tag.active {
    box-shadow: 0 0 0 2px var(--tag-fg);
}

.source-tag.static {
    cursor: default;
}

.message-sources {
    display: flex;
    gap: 0.4rem;
    margin-bottom: 0.4rem;
}

.message-sources .source-tag {
    font-size: 0.8rem;
    padding: 0.15rem 0.6rem;
}

.inline-tag {
    background: var(--gold-light);
    color: var(--navy-deep);
    border-radius: 0.4rem;
    padding: 0 0.3rem;
    font-weight: 600;
}

.sources-overview {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.source-card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 0.9rem 1rem;
}

.source-card p {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.sources-help {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

/* ---------- Phone layout: compact header, tags, input; no footer ---------- */
@media (max-width: 768px) {
    body {
        height: 100dvh;
    }

    .navbar {
        flex-direction: row;
        padding: 0.4rem 0.75rem;
        gap: 0.5rem;
    }

    .logo-container {
        gap: 0.4rem;
        flex: 0 0 auto;
    }

    .parliament-logo {
        height: 2rem;
    }

    .logo-text {
        font-size: 1rem;
    }

    .nav-tabs {
        width: auto;
        justify-content: flex-end;
        gap: 0.25rem;
    }

    .tab-btn {
        font-size: 0.85rem;
        padding: 0.3rem 0.75rem;
    }

    .main-container {
        padding-top: 52px;
    }

    .how-container {
        padding-top: 64px;
    }

    .chat-history {
        padding: 0.75rem 0.6rem;
        gap: 0.9rem;
    }

    .message {
        max-width: 94%;
        padding: 0.7rem 0.9rem;
        font-size: 0.95rem;
        line-height: 1.6;
    }

    .message-sources {
        margin-bottom: 0.25rem;
    }

    .input-area-wrapper {
        padding: 0.4rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom));
    }

    .source-tags {
        gap: 0.35rem;
        margin-bottom: 0.35rem;
    }

    .source-tags-label,
    .source-tags-hint {
        display: none;
    }

    .source-tag {
        font-size: 0.8rem;
        padding: 0.2rem 0.65rem;
    }

    .input-container {
        padding: 0.25rem 0.4rem 0.25rem 0.6rem;
        border-radius: 1.25rem;
    }

    #message-input {
        /* 16px keeps iOS from zooming into the field */
        font-size: 16px;
        padding: 0.55rem 0.4rem;
    }

    #send-btn {
        width: 2.6rem;
        height: 2.6rem;
        border-radius: 0.9rem;
    }

    .app-footer {
        display: none;
    }

    .sources-overview {
        margin: 0.75rem 0;
        gap: 0.5rem;
    }

    .source-card {
        padding: 0.7rem 0.8rem;
    }
}
