/* pwa_styles.css - Single main stylesheet for the PWA */
/* Change --base-size to make everything bigger/smaller */

:root {
    --base-size: .65;   /* ← Increase this to make the whole site larger */
    --color-primary: #0066cc;
    --color-primary-hover: #0055aa;
    --color-primary-soft: #f0f7ff;
}

/* ====================== GLOBAL / HEADER ====================== */

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.dcw-logged-in {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: nowrap;
    overflow: visible;
    position: relative;     /* ← Added */
    z-index: 10;            /* ← Added */
    padding: calc(14px * var(--base-size)) calc(16px * var(--base-size));
    background: #f8f8f8;
    border-bottom: 1px solid #ddd;
    font-size: calc(1.4rem * var(--base-size));
}

.dcw-header-left {
    display: flex;
    align-items: center;
    gap: calc(16px * var(--base-size));
    flex: 1 1 auto;
    min-width: 0;
}

.job-queue-badge-root {
    flex: 0 1 auto;
    min-width: 0;
    max-width: min(52vw, 28rem);
}

.job-queue-badge-root--stale .job-queue-badge {
    opacity: 0.75;
}

.job-queue-badge {
    font-size: calc(1.05rem * var(--base-size));
    line-height: 1.35;
    color: #333;
    padding: calc(6px * var(--base-size)) calc(10px * var(--base-size));
    background: #fff;
    border: 1px solid #ccc;
    border-radius: calc(8px * var(--base-size));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.job-queue-badge__queue {
    font-weight: 600;
}

.job-queue-badge__sep {
    opacity: 0.5;
}

.job-queue-badge__running {
    color: #0a5;
}

.job-queue-badge__pending {
    color: #a60;
    font-weight: 600;
}

.job-queue-badge--idle {
    border-style: dashed;
    border-color: #bbb;
    background: #fafafa;
}

.job-queue-badge__idle {
    color: #666;
    font-weight: 600;
}

.job-queue-badge--error {
    color: #b00;
    font-size: calc(0.95rem * var(--base-size));
}

@media (max-width: 640px) {
    .job-queue-badge {
        white-space: normal;
        max-height: 3.2em;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
}

/* Logo sizing - responsive */
.dcw-logged-in img {
    height: 80px;      /* Default for larger screens */
    width: auto;
    max-width: 100%;   /* Prevents it from overflowing if needed */
}

/* Make logo smaller on phones */
@media (max-width: 640px) {
    .dcw-logged-in img {
        height: 55px;     /* Good size for mobile - adjust if you want bigger/smaller */
    }
}

.dcw-logged-in h5, 
.dcw-logged-in h6 {
    margin: 0;
    font-size: calc(1.4rem * var(--base-size));
}

.breadcrumbs {
	 z-index: 10;            /* ← Added */
    padding: calc(14px * var(--base-size)) calc(16px * var(--base-size));
    font-size: calc(1.5rem * var(--base-size));
    background: #f9f9f9;
    border-bottom: 1px solid #eee;
}

h1 {
    font-size: calc(2.9rem * var(--base-size));
    margin: calc(24px * var(--base-size)) calc(16px * var(--base-size));
    color: #111;
    font-weight: 700;
}

/* ====================== COMMON CARD BASE ====================== */

.list-card {
    display: block;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: calc(18px * var(--base-size));
    margin-bottom: calc(28px * var(--base-size));
    padding: calc(20px * var(--base-size)) calc(24px * var(--base-size));
    text-decoration: none;
    color: inherit;
    box-shadow: 0 4px 14px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
    position: relative;
    cursor: default;
}

/* Navigable list rows and home menu links */
.list-card[data-url],
a.list-card {
    cursor: pointer;
}

.list-card[data-url]:active,
a.list-card:active {
    background: #f9f9f9;
    transform: translateY(-2px);
}

/* Visual cue for selected cards */
.list-card.selected {
    border-color: var(--color-primary);
    background-color: var(--color-primary-soft);
}

/* ====================== CONFIRM POPUP ======================= */

.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: calc(20px * var(--base-size));
    box-sizing: border-box;
}

.modal-content.list-card {
    width: 90%;
    max-width: 450px;
    margin: 0 auto;
    padding: calc(32px * var(--base-size)) calc(24px * var(--base-size));
    box-sizing: border-box;
    cursor: default;
}

#confirm-message {
    font-size: calc(1.8rem * var(--base-size));
    margin-bottom: calc(30px * var(--base-size));
    line-height: 1.4;
    white-space: pre-wrap;
}

/* ====================== BUTTON ROWS (modals, floating bar) ====================== */

.button-row {
    display: flex;
    gap: calc(12px * var(--base-size));
    flex-wrap: nowrap;
}

/* Equal-width buttons in confirm modals only (not list card actions) */
#custom-confirm .button-row button,
.modal-content .button-row button {
    flex: 1 1 auto;
    min-width: 110px;
    white-space: nowrap;
}

/* Compact actions on list cards (Download, Transcribe, etc.) */
.list-card .card-meta.button-row {
    flex-wrap: wrap;
    gap: calc(8px * var(--base-size));
    align-items: center;
}

.list-card .card-meta.button-row .small-btn,
.list-card .card-meta.button-row a.small-btn,
.list-card .card-meta.button-row button.small-btn {
    flex: 0 0 auto;
    min-width: 0;
    width: auto !important;
    max-width: none;
    margin: 0 !important;
}

.button-row--end {
    justify-content: flex-end;
}

.button-row #cancel-btn {
    background: transparent;
    color: var(--color-primary);
    border: 2px solid var(--color-primary);
}

.button-row #proceed-btn {
    background: var(--color-primary);
    color: #fff;
    border: none;
}

/* ====================== LIST CARD CONTENT ====================== */

.card-title {
    font-size: calc(2rem * var(--base-size));
    font-weight: 700;
    color: #111;
    line-height: 1.25;
}

.card-body {
    font-size: calc(1.6rem * var(--base-size));
    line-height: 1.5;
    color: #444;
}

.card-body + .card-body {
    margin-top: calc(10px * var(--base-size));
}

.card-label {
    font-weight: 600;
    color: #1976d2;
    margin-bottom: calc(6px * var(--base-size));
    font-size: calc(1.5rem * var(--base-size));
}

.card-meta {
    margin-top: calc(15px * var(--base-size));
    font-size: calc(1.4rem * var(--base-size));
    color: #555;
}

.card-meta--divider {
    padding-top: calc(10px * var(--base-size));
    border-top: 1px dashed #eee;
    font-size: calc(1.3rem * var(--base-size));
    color: #888;
}

.card-meta--highlight {
    color: var(--color-primary);
    font-weight: 600;
}

.urgency { font-weight: 700; }

/* ====================== TAGS & STATUS ====================== */

.client-tag, .user-tag {
    display: inline-block;
    background: #e0f2fe;
    color: #0369a1;
    padding: calc(4px * var(--base-size)) calc(10px * var(--base-size));
    border-radius: calc(6px * var(--base-size));
    font-size: calc(1.2rem * var(--base-size));
    font-weight: 800;
    border: 1px solid #bae6fd;
    text-transform: uppercase;
    margin-bottom: calc(10px * var(--base-size));
    letter-spacing: 0.5px;
}

/* ====================== CHECKBOX / BULK SELECT ====================== */

.checkbox-container {
    position: absolute;
    top: calc(15px * var(--base-size));
    right: calc(15px * var(--base-size));
    z-index: 20;
}

.row-check {
    cursor: pointer;
    transform: scale(1.5);
    margin: 0;
}

.tts-audio-player {
    display: block;
    width: 100%;
    max-width: 28rem;
    margin-top: calc(10px * var(--base-size));
}

.bulk-select-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 12px;
    padding: 0 calc(16px * var(--base-size));
    margin: 0 calc(16px * var(--base-size)) calc(15px * var(--base-size));
    font-size: calc(1.6rem * var(--base-size));
    font-weight: 600;
}

.bulk-select-header label {
    cursor: pointer;
    font-weight: 700;
    font-size: calc(1.8rem * var(--base-size));
    display: flex;
    align-items: center;
    gap: 12px;
    color: #333;
    user-select: none;
}

#select-all {
    transform: scale(1.6);
    margin: 0;
    cursor: pointer;
}

/* ====================== PAGE HEADER ====================== */

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: calc(15px * var(--base-size));
    margin: 0 calc(16px * var(--base-size)) calc(20px * var(--base-size));
}

.page-header h1 {
    margin: 0;
}

.page-header--stacked {
    display: block;
}

.page-header--stacked h1 {
    margin-bottom: calc(10px * var(--base-size));
}

.header-main {
    flex: 1 1 auto;
}

.header-main h1 {
    margin: 0 0 calc(10px * var(--base-size)) 0;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-size: calc(1.4rem * var(--base-size));
    font-weight: bold;
    color: #666;
}

.filter-group select {
    width: auto;
    min-width: 180px;
    max-width: 280px;
    padding: calc(8px * var(--base-size));
    border-radius: 8px;
    border: 1px solid #ccc;
}

.toolbar-actions {
    flex: 0 0 auto;
    margin-bottom: calc(2px * var(--base-size));
    display: flex;
    align-items: center;
    gap: calc(10px * var(--base-size));
    flex-wrap: wrap;
}

.toolbar-actions .toolbar-sync-form {
    display: inline-flex;
    margin: 0;
}

/* Mobile: Stack them but keep button full width if screen is tiny */
@media (max-width: 500px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .toolbar-actions,
    .toolbar-actions a {
        width: 100%;
    }
}

.status-pending { color: orange; }

.status-completed { color: green; }

.status-failed { color: red; }

/* ====================== USER DROPDOWN MENU ====================== */

.user-dropdown {
    position: relative;
    display: inline-block;
    flex-shrink: 0;
    z-index: 20;                    /* Higher than the header itself */
}

.dropdown-trigger {
    cursor: pointer;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    font-size: calc(1.4rem * var(--base-size));
    font-weight: bold;
    color: #333;
    user-select: none;
    white-space: nowrap;
}

.arrow {
    font-size: 0.75em;
    margin-left: 6px;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: #ffffff;
    min-width: 180px;
    max-width: 260px;
    width: auto;
    box-shadow: 0 8px 25px rgba(0,0,0,0.22);
    z-index: 1000;                  /* Very high so it pops over everything */
    border: 1px solid #ddd;
    border-radius: 12px;
    overflow: hidden;
    margin-top: 6px;
    list-style: none;
    padding: 0;
}

.user-dropdown.active .dropdown-menu {
    display: block;
}

.dropdown-menu li a {
    color: #333;
    padding: 5px 20px;
    text-decoration: none;
    display: flex;
    align-items: center;
    font-size: calc(1.55rem * var(--base-size));
    border-bottom: 1px solid #eee;
    min-height: 38px;
    white-space: nowrap;
}

.dropdown-menu li:last-child a {
    border-bottom: none;
}

.dropdown-menu li a:hover,
.dropdown-menu li a:active {
    background-color: var(--color-primary-soft);
}

.dropdown-menu li a.logout-link {
    color: #8d070e;
    font-weight: 600;
}

/* Model selector in chat header */
#model_selector {
    border: none;
    background: transparent;
    font-weight: bold;
    cursor: pointer;
    color: var(--color-primary);
    font-size: 1em;
    max-width: 150px;
}

.toolbar-actions .small-btn,
.toolbar-actions a.small-btn {
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    height: 40px;
    width: auto !important;
    max-width: none;
    margin: 0 !important;
}

@media (max-width: 600px) {
    .page-header:not(.page-header--stacked) {
        flex-direction: column;
        align-items: flex-start;
    }

    .toolbar-actions {
        width: 100%;
        justify-content: space-between;
    }

    @media (max-width: 380px) {
        .toolbar-actions {
            flex-direction: column;
            align-items: stretch;
        }
        .user-tag {
            justify-content: center;
        }
    }
}

/* ====================== SHARED PAGE LAYOUT ====================== */

.filter-toolbar {
    display: flex;
    gap: calc(15px * var(--base-size));
    flex-wrap: wrap;
    margin-top: calc(15px * var(--base-size));
}

.search-row,
.action-row {
    margin: 0 calc(16px * var(--base-size)) calc(15px * var(--base-size));
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: calc(10px * var(--base-size));
}

.action-row {
    margin-bottom: calc(20px * var(--base-size));
}

.search-row form {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: flex-end;
}

.search-row .form-input {
    width: 100%;
    max-width: 250px;
    padding: calc(8px * var(--base-size));
}

.filter-row {
    margin: 0 calc(16px * var(--base-size)) calc(25px * var(--base-size));
    padding-top: calc(15px * var(--base-size));
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
}

.filter-group--align-end {
    text-align: right;
}

.filter-group--align-end label {
    font-size: calc(1.4rem * var(--base-size));
    font-weight: bold;
    color: #666;
    margin-bottom: 5px;
    display: block;
}

.filter-group--align-end .form-input,
.filter-group--wide .form-input {
    min-width: 250px;
    padding: calc(8px * var(--base-size));
}

.tag-row {
    display: flex;
    gap: calc(8px * var(--base-size));
    flex-wrap: wrap;
    margin-bottom: calc(8px * var(--base-size));
}

.toolbar-count {
    margin: 0;
    font-size: calc(1.4rem * var(--base-size));
    color: #666;
}

.list-stack {
    margin: 0 calc(16px * var(--base-size));
}

.pagination-bar {
    margin: calc(30px * var(--base-size)) calc(16px * var(--base-size));
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.btn-pagination {
    padding: 6px 12px;
    border-radius: 4px;
    text-decoration: none;
    border: 1px solid #ddd;
    background: #fff;
    color: #333;
    font-size: calc(1.4rem * var(--base-size));
}

.btn-pagination.active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.list-card--spaced {
    margin-bottom: calc(20px * var(--base-size));
}

.card-section-heading {
    margin-top: 0;
    font-size: calc(1.8rem * var(--base-size));
}

.card-accent {
    border-left: 5px solid var(--color-primary);
}

.model-selector-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f4f4f4;
    padding: 5px 10px;
    border-radius: 5px;
    margin-bottom: 0;
}

.model-selector-bar label {
    font-size: 0.8em;
    font-weight: bold;
    color: #666;
}

.btn-danger {
    color: #d32f2f !important;
    border-color: #d32f2f !important;
}

.btn-danger:hover {
    background: #ffebee !important;
}

.login-text {
    margin: 0;
}

.text-muted {
    color: #666;
    font-weight: normal;
}

.form-help {
    display: block;
    color: #555;
    margin-top: calc(4px * var(--base-size));
    font-size: calc(1.3rem * var(--base-size));
}

.page-intro {
    margin: 0 calc(16px * var(--base-size)) calc(15px * var(--base-size));
}

.page-intro-text {
    margin-top: 0;
}

.config-form.form-group--none {
    margin-bottom: 0;
}

.qa-item {
    margin-bottom: calc(6px * var(--base-size));
}

.qa-item:last-child {
    margin-bottom: 0;
}

.status-tag {
    text-transform: capitalize;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: calc(1.4rem * var(--base-size));
}

.data-table th,
.data-table td {
    padding: calc(10px * var(--base-size));
    border-bottom: 1px solid #eee;
    text-align: left;
}

.data-table th {
    border-bottom-width: 2px;
}

.data-table td.text-right,
.data-table th.text-right {
    text-align: right;
}

.table-scroll {
    overflow-x: auto;
}

.form-inline {
    margin: 0;
}

.session-ip {
    font-size: 0.85em;
}

.page-actions {
    margin: calc(25px * var(--base-size)) calc(16px * var(--base-size));
}

/* ====================== FORM ====================== */

.config-form .form-group {
    margin-bottom: calc(16px * var(--base-size));
}

.config-form .form-group--tight {
    margin-bottom: calc(12px * var(--base-size));
}

.config-form .form-group--none {
    margin-bottom: 0;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: calc(12px * var(--base-size));
    margin-top: calc(20px * var(--base-size));
}

.form-actions > div {
    display: flex;
    flex-wrap: wrap;
    gap: calc(10px * var(--base-size));
    align-items: center;
}

.form-label {
    font-size: calc(1.6rem * var(--base-size));
    font-weight: 600;
    margin-top: 8px;
    margin-bottom: 2px;
    display: inline-block;
}

.form-input {
    width: 100%;
    padding: calc(16px * var(--base-size)) calc(14px * var(--base-size));
    font-size: calc(1.55rem * var(--base-size));
    border: 1px solid #ccc;
    border-radius: 10px;
    box-sizing: border-box;
}

.form-textarea {
    width: 100%;
    padding: calc(16px * var(--base-size)) calc(14px * var(--base-size));
    font-size: calc(1.55rem * var(--base-size));
    border: 1px solid #ccc;
    border-radius: 10px;
    box-sizing: border-box;
    resize: vertical;
    field-sizing: content;
}

.btn-primary {
    padding: calc(20px * var(--base-size)) calc(28px * var(--base-size));
    font-size: calc(1.6rem * var(--base-size));
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 12px;
}

.btn-cancel {
    padding: calc(16px * var(--base-size)) calc(26px * var(--base-size));
    font-size: calc(1.5rem * var(--base-size));
    color: var(--color-primary);
    text-decoration: none;
    border: 2px solid var(--color-primary);
    border-radius: 12px;
    display: inline-block;
    text-align: center;
}

.checkbox-group {
    padding: calc(20px * var(--base-size)) calc(28px * var(--base-size));
    font-size: calc(1.6rem * var(--base-size));
    display: inline-block;
}

.checkbox-group input[type="checkbox"] {
    transform: scale(1.6);
    margin-right: 12px;
    font-weight: 600;
    margin-top: 8px;
    margin-bottom: 8px;
}

.required {
    color: #d32f2f;
}

/* Floating Action Bar */
.floating-bar {
    display: none; /* Hidden by default */
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 500px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: calc(20px * var(--base-size));
    box-shadow: 0 10px 30px rgba(0,0,0,0.25);
    padding: calc(15px * var(--base-size));
    z-index: 9999;
}

.bar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: calc(12px * var(--base-size));
    min-width: 0;
}

#selected-count {
    font-size: calc(1.6rem * var(--base-size));
    font-weight: bold;
    color: #333;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Floating bar: actions align right (same as Q&A / Documents lists) */
.floating-bar .button-row {
    justify-content: flex-end;
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: wrap;
}

.floating-bar .button-row button {
    flex: 0 1 auto;
    min-width: 0;
    max-width: 100%;
}

.u-hidden {
    display: none !important;
}

/* Override your 100% width buttons for the floating bar */
.small-btn {
    width: auto !important;
    margin: 0 !important;
    padding: calc(10px * var(--base-size)) calc(20px * var(--base-size)) !important;
    font-size: calc(1.4rem * var(--base-size)) !important;
}

@media (max-width: 640px) {
    .floating-bar {
        width: calc(100% - 24px);
        max-width: none;
        left: 12px;
        transform: none;
        bottom: max(12px, env(safe-area-inset-bottom, 12px));
        padding: calc(12px * var(--base-size));
    }

    .floating-bar .bar-content {
        flex-wrap: wrap;
    }

    .floating-bar .button-row {
        width: 100%;
        justify-content: flex-end;
    }

    .floating-bar .button-row button {
        white-space: nowrap;
    }
}


/* ====================== BUTTONS ====================== */

/* === Primary buttons (.add-button and .btn-primary) === */
.add-button,
.btn-primary {
    background: var(--color-primary);
    color: white;
    font-weight: 600;
}

/* === Secondary / Cancel buttons (.btn-cancel and .cancel-button) === */
.btn-cancel,
.cancel-button {
    background: transparent;
    color: var(--color-primary);
    font-weight: 500;
}

/* === Common styles for ALL buttons === */
.add-button,
.btn-primary,
.btn-cancel,
.cancel-button {
    display: inline-block;
    padding: calc(18px * var(--base-size)) calc(28px * var(--base-size));
    font-size: calc(1.55rem * var(--base-size));
    border-radius: 12px;
    text-decoration: none;
    text-align: center;
    cursor: pointer;
    margin: 10px 0;
    width: 100%;
    max-width: 420px;
    box-sizing: border-box;
    transition: all 0.2s ease;
    border: 2px solid var(--color-primary);
}

/* Hover & Active states */
.add-button:hover,
.btn-primary:hover {
    background: #0055aa;
}

.btn-cancel:hover,
.cancel-button:hover {
    background: #f0f7ff;
}

.add-button:active,
.btn-primary:active {
    background: #004499;
    transform: translateY(1px);
}

.btn-cancel:active,
.cancel-button:active {
    transform: translateY(1px);
}

/* ====================== AI CHAT UI ====================== */
.chat-container {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: calc(18px * var(--base-size));
    margin-bottom: calc(28px * var(--base-size));
    padding: calc(20px * var(--base-size)) calc(24px * var(--base-size));
    box-shadow: 0 4px 14px rgba(0,0,0,0.1);
    overflow: hidden;
    /*max-width: 800px;*/
}

#chat-window {
    height: 500px;
    overflow-y: auto;
    padding: calc(10px * var(--base-size));
    background: #fafafa;
    display: flex;
    flex-direction: column;
    gap: calc(16px * var(--base-size));
}

/* Chat Bubbles */
.chat-bubble {
    padding: calc(8px * var(--base-size)) calc(10px * var(--base-size));
    border-radius: calc(15px * var(--base-size));
    font-size: calc(1.7rem * var(--base-size));
    line-height: 1.3;
    max-width: 85%;
    word-wrap: break-word;
    position: relative;
}

.bot-msg {
    align-self: flex-start;
    background: #e8e8e8;
    color: #333;
    border-bottom-left-radius: 2px;
    display: flex;
    flex-direction: column;
}

.bot-msg strong {
    font-weight: 600;
    display: block;
    margin-bottom: 4px;
}

.user-msg {
    align-self: flex-end;
    background: var(--color-primary);
    color: white;
    border-bottom-right-radius: 2px;
}

/* Input Area */
.chat-input-area {
    display: flex;
    gap: 10px;
    padding: calc(16px * var(--base-size));
    border-top: 1px solid #eee;
    background: #fff;
    align-items: center;
    /* NEW: Ensures the padding doesn't push the container wider than the screen */
    box-sizing: border-box; 
    width: 100%;
}

/* Updated Input Logic */
.chat-input-area input {
    flex-grow: 1;
    /* CRITICAL FIX: Allows the input to shrink smaller than its default 
       browser size to make room for buttons on mobile */
    min-width: 0; 
    border: 1px solid #ccc;
    border-radius: calc(10px * var(--base-size));
    padding: calc(14px * var(--base-size));
    font-size: calc(1.6rem * var(--base-size));
}

/* The Paperclip Button (if you added one) */
#attach-btn {
    flex-shrink: 0; /* Prevents the icon from being squashed */
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0 5px;
}

/* Overriding global button width for the chat send button */
.chat-input-area .send-btn {
    flex-shrink: 0; /* NEW: Ensures the button stays its full size and doesn't disappear */
    width: auto !important;
    margin: 0 !important;
    padding: calc(12px * var(--base-size)) calc(20px * var(--base-size)) !important;
    white-space: nowrap; /* Prevents "Send" from breaking into two lines */
}
/* Mobile Adjustments */
@media (max-width: 640px) {
    #chat-window { height: 60vh; }
    .chat-bubble { max-width: 90%; }
}

/* ====================== MOBILE BUTTONS ====================== */
@media (max-width: 640px) {
    .add-button,
    .btn-primary,
    .btn-cancel,
    .cancel-button {
        padding: calc(20px * var(--base-size)) calc(24px * var(--base-size));
        font-size: calc(1.6rem * var(--base-size));
        max-width: none;           /* Full width on mobile */
    }

    /* Keep list card row actions compact on mobile */
    .list-card .card-meta.button-row .btn-primary,
    .list-card .card-meta.button-row .btn-cancel {
        width: auto !important;
        padding: calc(10px * var(--base-size)) calc(16px * var(--base-size)) !important;
        font-size: calc(1.4rem * var(--base-size)) !important;
    }
}

/* ====================== CHAT TYPING ANIMATION ====================== */

/* Typing indicator - three bouncing dots */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding-left: 6px;
}

.dot {
    display: inline-block;
    width: 7px;
    height: 7px;
    background-color: #666;           /* Matches your bot text color */
    border-radius: 50%;
    animation: typingBounce 1.35s infinite ease-in-out;
}

.dot:nth-child(2) { animation-delay: 0.15s; }
.dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Make the typing bubble consistent with normal bot messages */
.typing-bubble {
    align-self: flex-start;
    background: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 2px;
    padding: calc(16px * var(--base-size)) calc(20px * var(--base-size));
}

/* Optional: Slightly smaller dots on very small screens */
@media (max-width: 480px) {
    .dot {
        width: 6px;
        height: 6px;
    }
}

/* ====================== MARKDOWN CONTENT STYLES ====================== */

.bot-content {
    /* Changed from pre-wrap to normal because Marked.js handles the layout now */
    white-space: normal; 
    word-break: break-word;
    line-height: 1.6;
    color: #333;
}

/* Paragraphs: Standard spacing between blocks */
.bot-content p {
    white-space: normal !important;
    display: block;
    margin: 0 0 calc(10px * var(--base-size)) 0;
}

.bot-content p:last-child {
    margin-bottom: 0;
}

/* Lists: Ensure bullets are inside the bubble and visible */
.bot-content ul, 
.bot-content ol {
    margin: calc(8px * var(--base-size)) 0;
    padding-left: calc(20px * var(--base-size));
    list-style-position: outside;
}

.bot-content li {
    margin-bottom: calc(4px * var(--base-size));
}

/* Bold text: Keep it subtle but readable */
.bot-content strong {
    display: inline;
    font-weight: 700;
    color: #000;
}

/* Inline Code: (e.g., `variable_name`) */
.bot-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.95em;
    color: #d63384; /* Classic code pink/red */
}

/* Multi-line Code Blocks */
.bot-content pre {
    background: #1e1e1e; /* Dark terminal look */
    color: #dcdcdc;
    padding: calc(12px * var(--base-size));
    border-radius: 8px;
    overflow-x: auto;
    margin: 15px 0;
    border: 1px solid #333;
}

/* Ensure code inside pre doesn't inherit the pink color from inline code */
.bot-content pre code {
    background: transparent;
    padding: 0;
    color: #75beff; /* Light blue for code block text */
    font-size: 0.9em;
    display: block;
    line-height: 1.4;
}

/* PWA / iOS safeguards */
html, body {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

@supports (-webkit-touch-callout: none) {
    body {
        -webkit-tap-highlight-color: transparent;
    }
}

/* ====================== EXTERNAL CHAT IFRAME ====================== */

body.external-chat-body {
    margin: 0;
    padding: 0;
    background: transparent;
}

body.external-chat-body .chat-container {
    height: 100vh;
    margin-bottom: 0;
    border-radius: 0;
}

body.external-chat-body #chat-window {
    height: auto;
    flex: 1;
}

body.external-chat-body .chat-input-area .send-btn,
body.external-chat-body #send-btn {
    flex-shrink: 0;
    width: auto !important;
    margin: 0 !important;
    padding: calc(12px * var(--base-size)) calc(20px * var(--base-size)) !important;
    border-radius: 12px;
}

.chat-attach-hidden {
    display: none;
}

.chat-image-preview {
    padding: calc(10px * var(--base-size));
    border-top: 1px solid #eee;
}

.chat-image-preview-inner {
    position: relative;
    display: inline-block;
}

.chat-image-preview img {
    max-height: 80px;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.chat-remove-image {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #d32f2f;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
}

#attach-btn {
    flex-shrink: 0;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 0 10px;
}

/* ====================== CHAT PAGE ====================== */

.form-textarea--embed {
    font-family: monospace;
    font-size: 12px;
    height: 120px;
    margin-bottom: calc(20px * var(--base-size));
}

/* ====================== DOCUMENT PAGE ====================== */

.doc-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: -1px;
}

.doc-tab {
    padding: 10px 20px;
    cursor: pointer;
    background: #e0e0e0;
    border-radius: 8px 8px 0 0;
    border: 1px solid #ccc;
    font-weight: bold;
    color: #666;
}

.doc-tab.active {
    background: #fff;
    border-bottom: 1px solid #fff;
    color: var(--color-primary);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.list-card--tab-panel-flush {
    border-top-left-radius: 0;
}

.form-input--readonly {
    background-color: #f8f9fa;
}

.meta-grid {
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 10px;
    font-size: 0.9rem;
    align-items: baseline;
}

.meta-grid dt {
    color: #666;
    font-weight: 600;
    margin: 0;
}

.meta-grid dd {
    color: #333;
    margin: 0;
}

.meta-grid a {
    color: var(--color-primary);
    text-decoration: underline;
    word-break: break-all;
}

.meta-grid code {
    background: #eee;
    padding: 2px 4px;
    border-radius: 4px;
    font-size: 0.8rem;
}

.meta-grid .meta-failure-reason {
    color: #8b1a1a;
    word-break: break-word;
    white-space: pre-wrap;
}

.meta-grid__row {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    grid-column: 1 / -1;
}

.meta-grid__spacer {
    grid-column: 1 / -1;
}

.section-heading {
    margin: calc(30px * var(--base-size)) 0 calc(15px * var(--base-size));
}

.list-card--preview {
    background: #f9f9f9;
    border-left: 4px solid #ccc;
}

.preview-label {
    font-size: 0.8rem;
    color: #888;
    margin-bottom: 8px;
    font-weight: bold;
}

.preview-body {
    font-size: 0.9rem;
    color: #555;
    font-style: italic;
    line-height: 1.4;
}

.preview-note {
    margin-top: 15px;
    font-size: 0.85rem;
    color: var(--color-primary);
}

.chunks-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.chunk-card {
    border-left: 4px solid var(--color-primary);
    padding: 15px;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    cursor: default;
}

.chunk-card:active {
    transform: none;
}

.chunk-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.chunk-index {
    font-size: 0.8rem;
    color: #888;
    font-weight: bold;
}

.chunk-indexed {
    font-size: 0.75rem;
    color: #aaa;
    font-style: italic;
}

.enrichment-box {
    background: #f8f9fa;
    border: 1px dashed #d1d8dd;
    border-radius: 6px;
    padding: 10px;
    margin-bottom: 15px;
}

.enrichment-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    margin-bottom: 5px;
    font-weight: bold;
}

.enrichment-text {
    font-size: 0.85rem;
    color: #495057;
    font-style: italic;
    line-height: 1.4;
}

.chunk-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    margin-bottom: 5px;
    font-weight: bold;
}

.chunk-text {
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
    color: #333;
}

.danger-zone {
    margin-top: calc(40px * var(--base-size));
    border: 1px solid #ecc;
    background-color: #fff5f5;
    padding: calc(20px * var(--base-size));
    border-radius: 8px;
    cursor: default;
}

.danger-zone:active {
    transform: none;
}

.danger-zone h3 {
    color: #d32f2f;
    margin-top: 0;
    font-size: calc(1.8rem * var(--base-size));
}

.danger-zone p {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 15px;
}

button.btn-delete,
.btn-delete {
    background: #d32f2f;
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 5px;
    cursor: pointer;
    font-weight: 600;
    width: auto !important;
    max-width: none;
    margin: 0 !important;
}

.form-hidden {
    display: none !important;
}

.approval-label.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}