/* ── AI Intake Assistant — Split Layout Redesign ──────────── */

/* ═══ Layout ═══ */

/* Make the plugin container a flex column so .ia-main fills remaining space */
#intakeTool.plugin-container.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    overflow: hidden;
}

.ia-main {
    display: flex;
    flex-direction: column;
    flex: 1 1 0%;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    padding: 0;
}

/* Lock the parent chain so the viewport doesn't scroll when intake is active.
   The height must propagate unbroken from .app-main → .app-content → #pluginViewport → #intakeTool.
   .app-content is normally a block element, so #pluginViewport has no definite height
   and #intakeTool's height:100% resolves to auto (content height → clipped).
   Fix: make .app-content a flex column so #pluginViewport stretches to fill it.

   These rules are NOT media-query-gated — the height chain must hold at every width.
   Only viewport-specific tweaks (hiding mobile nav, padding resets) are inside MQs. */

/* ── Height chain fix (all viewports) ── */
.app-shell:has(#intakeTool.active) .app-main {
    height: 100dvh;
    min-height: 100dvh;
    max-height: 100dvh;
    padding: 0 !important; /* strip mobile-nav padding clearance */
    overflow: hidden;
    background: var(--bg);
}
.app-shell:has(#intakeTool.active) .app-content {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: var(--bg);
}
#pluginViewport.plugin-viewport.active {
    display: flex !important; /* sidebar.css loads after us and keeps winning */
    flex-direction: column;
    flex: 1 1 0%;
    min-height: 0;
    overflow: hidden;
}

/* At 768–1023px the sidebar is off-screen (position:fixed, left:-260px) but
   body.sidebar-collapsed .app-shell still sets a 64px ghost column via higher
   specificity. Override that so the main content fills the full width. */
@media (min-width: 768px) and (max-width: 1023px) {
    .app-shell:has(#intakeTool.active) {
        grid-template-columns: 1fr !important;
    }
}

/* ── Mobile tweaks (<768px) ── */
@media (max-width: 767px) {
    .app-shell:has(#intakeTool.active) .app-content {
        /* Remove the normal bottom-nav padding — we handle it inside the chat input row */
        padding-bottom: 0;
    }

    /* Hide the mobile bottom nav when AI Intake is active —
       the tab bar + input row replace its function */
    .app-shell:has(#intakeTool.active) ~ .mobile-bottom-nav {
        display: none;
    }
}

.ia-layout {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

@media (min-width: 768px) {
    .ia-layout {
        display: grid;
        grid-template-columns: 1fr 380px;
        grid-template-rows: minmax(0, 1fr);
        gap: 0;
    }
}

@media (min-width: 1024px) {
    .ia-layout {
        grid-template-columns: 1fr 420px;
    }
}

/* ═══ Mobile Tab Bar ═══ */

.ia-tab-bar {
    display: flex;
    gap: 4px;
    padding: 6px 10px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
}

@media (min-width: 768px) {
    .ia-tab-bar { display: none !important; }
}

.ia-tab {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}
.ia-tab.ia-tab-active {
    background: var(--bg-card);
    color: var(--apple-blue);
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
body.dark-mode .ia-tab.ia-tab-active {
    background: #1C1C1E;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.ia-tab:hover:not(.ia-tab-active) {
    color: var(--text);
    background: rgba(0, 0, 0, 0.02);
}
body.dark-mode .ia-tab:hover:not(.ia-tab-active) {
    background: rgba(255, 255, 255, 0.04);
}

.ia-tab-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
    background: var(--apple-blue);
    color: #fff;
    min-width: 20px;
    text-align: center;
}

/* Mobile: show/hide panes based on active tab */
@media (max-width: 767px) {
    .ia-layout[data-active-tab="data"] .ia-chat-pane { display: none; }
    .ia-layout[data-active-tab="data"] .ia-sidebar-pane {
        display: flex;
        flex: 1;
        min-height: 0;
    }
    .ia-layout[data-active-tab="chat"] .ia-chat-pane {
        display: flex;
        flex: 1;
        min-height: 0;
    }
    .ia-layout[data-active-tab="chat"] .ia-sidebar-pane { display: none; }
    .ia-layout:not([data-active-tab]) .ia-sidebar-pane { display: none; }
    .ia-layout:not([data-active-tab]) .ia-chat-pane {
        flex: 1;
        min-height: 0;
    }
}

/* ═══ Chat Pane ═══ */

.ia-chat-pane {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    min-height: 0;
    overflow: hidden;
    padding: 10px;
}

@media (min-width: 768px) {
    .ia-chat-pane {
        border-right: 1px solid var(--border);
        padding: 12px;
    }
}

.ia-chat-card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.ia-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 0 0 1px rgba(0, 0, 0, 0.02);
}
body.dark-mode .ia-card {
    border-color: #2C2C2E;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.ia-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px;
    background: linear-gradient(180deg, rgba(0, 122, 255, 0.03) 0%, transparent 100%);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
body.dark-mode .ia-card-header {
    background: linear-gradient(180deg, rgba(10, 132, 255, 0.06) 0%, transparent 100%);
}

.ia-card-icon { font-size: 18px; }

.ia-card-title {
    font-weight: 700;
    font-size: 13px;
    color: var(--text-secondary);
    flex: 1;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.ia-clear-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    transition: color 0.2s, background 0.2s, transform 0.15s;
}
.ia-clear-btn:hover {
    color: var(--danger, #FF3B30);
    background: rgba(255, 59, 48, 0.08);
    transform: scale(1.05);
}
.ia-clear-btn:active {
    transform: scale(0.95);
}

/* Messages */
.ia-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px 18px;
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

.ia-msg {
    max-width: 82%;
    padding: 11px 15px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    animation: iaMsgIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes iaMsgIn {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.ia-msg-ai {
    align-self: flex-start;
    background: var(--bg-input);
    color: var(--text);
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
body.dark-mode .ia-msg-ai {
    background: #1C1C1E;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.ia-msg-user {
    align-self: flex-end;
    background: linear-gradient(135deg, #007AFF 0%, #0066D6 100%);
    color: #fff;
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 6px rgba(0, 122, 255, 0.2);
}
body.dark-mode .ia-msg-user {
    background: linear-gradient(135deg, #0A84FF 0%, #0066D6 100%);
    box-shadow: 0 2px 8px rgba(10, 132, 255, 0.25);
}

.ia-msg-ai strong { color: var(--apple-blue); }
.ia-msg-ai code {
    background: rgba(0,0,0,0.06);
    padding: 2px 6px;
    border-radius: 5px;
    font-size: 12px;
    font-weight: 500;
}
body.dark-mode .ia-msg-ai code {
    background: rgba(255,255,255,0.08);
}

/* Hide any remaining code blocks in chat (JSON data) */
.ia-msg .ia-code { display: none; }

/* Typing dots */
.ia-typing {
    display: flex !important;
    gap: 5px;
    align-items: center;
    padding: 14px 18px;
}

.ia-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: iaBounce 1.3s infinite;
}
.ia-dot:nth-child(2) { animation-delay: 0.18s; }
.ia-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes iaBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-7px); opacity: 1; }
}

/* Suggestion chips */
.ia-chip-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 10px 18px 14px;
    flex-shrink: 0;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ia-chip-row.ia-chips-visible {
    opacity: 1;
    transform: translateY(0);
}

.ia-chip {
    padding: 9px 18px;
    border-radius: 22px;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--transition-smooth, ease);
    white-space: nowrap;
    letter-spacing: -0.01em;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.ia-chip:hover {
    border-color: var(--apple-blue);
    color: var(--apple-blue);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 122, 255, 0.12);
}
.ia-chip:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 122, 255, 0.08);
}
body.dark-mode .ia-chip {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}
body.dark-mode .ia-chip:hover {
    box-shadow: 0 4px 14px rgba(10, 132, 255, 0.18);
}

/* Start / quick-start chips — prominent hero pills */
.ia-chip-start {
    background: rgba(0, 122, 255, 0.08);
    border-color: rgba(0, 122, 255, 0.25);
    color: var(--apple-blue);
    font-size: 14px;
    padding: 10px 22px;
}
.ia-chip-start:hover {
    background: var(--apple-blue);
    border-color: var(--apple-blue);
    color: #fff;
    box-shadow: 0 4px 14px rgba(0, 122, 255, 0.25);
}
body.dark-mode .ia-chip-start {
    background: rgba(10, 132, 255, 0.12);
    border-color: rgba(10, 132, 255, 0.3);
}
body.dark-mode .ia-chip-start:hover {
    background: #0A84FF;
    border-color: #0A84FF;
    color: #fff;
}

.ia-chip-suggestion {
    border-color: rgba(0, 122, 255, 0.3);
    color: var(--apple-blue);
    background: rgba(0, 122, 255, 0.05);
}
.ia-chip-suggestion:hover {
    background: var(--apple-blue);
    border-color: var(--apple-blue);
    color: #fff;
}
body.dark-mode .ia-chip-suggestion {
    background: rgba(10, 132, 255, 0.08);
    border-color: rgba(10, 132, 255, 0.3);
}

.ia-chip-done {
    border-color: rgba(52, 199, 89, 0.35);
    color: var(--success);
    background: rgba(52, 199, 89, 0.06);
}
.ia-chip-done:hover {
    background: var(--success);
    border-color: var(--success);
    color: #fff;
    box-shadow: 0 4px 14px rgba(52, 199, 89, 0.2);
}
body.dark-mode .ia-chip-done {
    background: rgba(50, 215, 75, 0.08);
    border-color: rgba(50, 215, 75, 0.3);
}

/* Input row */
.ia-input-row {
    display: flex;
    gap: 8px;
    padding: 12px 18px 14px;
    border-top: 1px solid var(--border);
    background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.01) 100%);
    align-items: flex-end;
    flex-shrink: 0;
}
body.dark-mode .ia-input-row {
    background: linear-gradient(180deg, transparent 0%, rgba(255, 255, 255, 0.01) 100%);
}

.ia-input {
    flex: 1;
    padding: 10px 16px;
    border: 1.5px solid var(--border);
    border-radius: 22px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    overflow: hidden;
    min-height: 20px;
    max-height: 120px;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.ia-input:focus {
    outline: none;
    border-color: var(--apple-blue);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, 0.1), 0 2px 8px rgba(0, 122, 255, 0.06);
}
body.dark-mode .ia-input:focus {
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.15), 0 2px 8px rgba(10, 132, 255, 0.08);
}
.ia-input::placeholder { color: var(--text-tertiary); }
.ia-input:disabled { opacity: 0.5; }

.ia-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #007AFF 0%, #0066D6 100%);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0, 122, 255, 0.25);
}
body.dark-mode .ia-send-btn {
    background: linear-gradient(135deg, #0A84FF 0%, #0066D6 100%);
    box-shadow: 0 2px 10px rgba(10, 132, 255, 0.3);
}
.ia-send-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 14px rgba(0, 122, 255, 0.3);
}
.ia-send-btn:active {
    transform: scale(0.95);
    box-shadow: 0 1px 4px rgba(0, 122, 255, 0.2);
}
.ia-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }


/* ═══ Sidebar Pane ═══ */

.ia-sidebar-pane {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg);
    min-height: 0;
}
body.dark-mode .ia-sidebar-pane {
    background: #0A0A0A;
}

@media (min-width: 768px) {
    .ia-sidebar-pane {
        display: flex;
        padding: 14px;
    }
}

/* Sidebar Header: compact progress + actions */
.ia-sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
body.dark-mode .ia-sidebar-header {
    border-color: #2C2C2E;
    background: #1C1C1E;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.ia-sidebar-progress {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ia-ring-sm {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
}

.ia-sidebar-pct {
    font-size: 15px;
    font-weight: 800;
    color: var(--text);
    letter-spacing: -0.02em;
}

.ia-sidebar-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

.ia-export-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    border-radius: 8px;
    border: 1.5px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
}
.ia-export-btn:hover {
    border-color: var(--apple-blue);
    color: var(--apple-blue);
}

.ia-populate-btn-sm {
    padding: 6px 12px;
    border-radius: 8px;
    border: none;
    background: var(--success, #34C759);
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: filter 0.15s;
}
.ia-populate-btn-sm:hover { filter: brightness(1.1); }

/* Sidebar empty state */
.ia-sidebar-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 24px;
    text-align: center;
    flex: 1;
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: 14px;
}
body.dark-mode .ia-sidebar-empty {
    background: #111111;
    border-color: #2C2C2E;
}
.ia-sidebar-empty-icon {
    font-size: 40px;
    opacity: 0.3;
    animation: iaEmptyPulse 3s ease-in-out infinite;
}
@keyframes iaEmptyPulse {
    0%, 100% { transform: scale(1); opacity: 0.3; }
    50% { transform: scale(1.05); opacity: 0.45; }
}
.ia-sidebar-empty-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-secondary);
    letter-spacing: -0.01em;
}
.ia-sidebar-empty-text {
    font-size: 13px;
    color: var(--text-tertiary);
    font-weight: 500;
    line-height: 1.6;
    max-width: 200px;
}


/* ═══ Collapsible Data Sections ═══ */

.ia-sections-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-shrink: 0; /* Prevent collapse in sidebar flex column */
}

.ia-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    animation: iaSectionIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    flex-shrink: 0; /* Prevent collapse — overflow:hidden makes min-height:0 in flex */
}
body.dark-mode .ia-section {
    border-color: #2C2C2E;
    background: #1C1C1E;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

@keyframes iaSectionIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ia-section-done {
    border-color: rgba(52, 199, 89, 0.3);
}
body.dark-mode .ia-section-done {
    border-color: rgba(50, 215, 75, 0.25);
    box-shadow: 0 0 0 1px rgba(50, 215, 75, 0.08), 0 1px 4px rgba(0, 0, 0, 0.2);
}

.ia-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 11px 14px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text);
    font-size: 13px;
    font-weight: 700;
    text-align: left;
    transition: background 0.15s;
}
.ia-section-header:hover {
    background: rgba(0, 0, 0, 0.02);
}
body.dark-mode .ia-section-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.ia-section-icon { font-size: 15px; flex-shrink: 0; }

.ia-section-title { flex: 1; }

.ia-section-badge {
    font-size: 11px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text-secondary);
}
.ia-section-done .ia-section-badge {
    background: rgba(52, 199, 89, 0.12);
    color: var(--success, #34C759);
}
.ia-section-partial .ia-section-badge {
    background: rgba(0, 122, 255, 0.08);
    color: var(--apple-blue);
}

.ia-section-chevron {
    flex-shrink: 0;
    transition: transform 0.2s ease;
    color: var(--text-secondary);
}

/* Collapsed state */
.ia-section.ia-collapsed .ia-section-body {
    display: none;
}
.ia-section.ia-collapsed .ia-section-chevron {
    transform: rotate(-90deg);
}

.ia-section-body {
    border-top: 1px solid var(--border);
    padding: 6px 0;
}

.ia-section-field {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 14px;
    gap: 10px;
    transition: background 0.15s;
}
.ia-section-field:hover {
    background: rgba(0, 0, 0, 0.015);
}
body.dark-mode .ia-section-field:hover {
    background: rgba(255, 255, 255, 0.02);
}
.ia-section-field + .ia-section-field {
    border-top: 1px solid rgba(0,0,0,0.04);
}
body.dark-mode .ia-section-field + .ia-section-field {
    border-top-color: rgba(255,255,255,0.05);
}

.ia-section-field-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
    flex-shrink: 0;
}

.ia-section-field-value {
    font-size: 13px;
    color: var(--text);
    font-weight: 600;
    text-align: right;
    word-break: break-word;
    min-width: 0;
}


/* ═══ Sidebar Cards (Maps, Vehicles) ═══ */

.ia-sidebar-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
    flex-shrink: 0; /* Prevent collapse — overflow:hidden makes min-height:0 in flex */
}
body.dark-mode .ia-sidebar-card {
    border-color: #2C2C2E;
    background: #1C1C1E;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.ia-sidebar-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 11px 14px;
    background: transparent;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* Map views */
.ia-map-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    background: var(--border);
}

.ia-map-frame {
    position: relative;
    background: var(--bg-input);
    min-height: 110px;
    overflow: hidden;
}

.ia-map-label {
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 2;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.55);
    color: #fff;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.ia-map-img {
    display: none;
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.ia-map-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100px;
    font-size: 12px;
    color: var(--text-secondary);
    font-style: italic;
}

.ia-map-address {
    padding: 8px 14px;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 4px;
}
.ia-map-address::before {
    content: '📍';
    font-size: 13px;
}

.ia-map-expand-btn {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: color 0.15s;
}
.ia-map-expand-btn:hover {
    color: var(--apple-blue);
}

/* Vehicle panel */
.ia-vehicle-info {
    padding: 10px 14px;
}

.ia-vehicle-row {
    padding: 6px 0;
}
.ia-vehicle-row + .ia-vehicle-row {
    border-top: 1px solid var(--border);
}

.ia-vehicle-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 2px;
}

.ia-vehicle-vin {
    font-size: 12px;
    color: var(--text-secondary);
}
.ia-vehicle-vin code {
    background: var(--bg-input);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 11px;
    letter-spacing: 0.5px;
}

/* ═══ Responsive ═══ */

@media (max-width: 480px) {
    .ia-map-grid { grid-template-columns: 1fr; }
}

/* ── Mobile: full-bleed chat, no clipping ── */
@media (max-width: 767px) {
    #intakeTool.plugin-container.active {
        /* Fill parent completely — no outer rounding or margin */
        border-radius: 0;
    }

    .ia-chat-pane {
        padding: 0;
    }

    .ia-card.ia-chat-card {
        /* Remove card border/radius on mobile — go edge to edge */
        border: none;
        border-radius: 0;
        box-shadow: none;
        background: var(--bg);
    }

    .ia-card-header {
        padding: 10px 14px;
        background: transparent;
    }

    .ia-messages {
        padding: 10px 12px;
        gap: 8px;
    }

    .ia-chip-row {
        padding: 8px 12px 10px;
        gap: 6px;
    }

    .ia-chip {
        padding: 8px 14px;
        font-size: 12px;
    }

    .ia-input-row {
        padding: 8px 10px 10px;
    }

    .ia-input {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }

    .ia-sidebar-pane {
        padding: 8px;
    }

    .ia-msg {
        max-width: 90%;
        font-size: 14px;
    }
}

/* ═══ Legacy compat (keep for any external references) ═══ */
.ia-intel-panel { display: none !important; }
.ia-extracted-card { display: none !important; }
.ia-populate-btn { display: none; }
.ia-code { display: none; }


/* ═══ Phase 3: Document Upload Button ═══ */

.ia-input-icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    background: var(--bg-input);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}
.ia-input-icon-btn:hover {
    border-color: var(--apple-blue);
    color: var(--apple-blue);
    background: rgba(0, 122, 255, 0.06);
    transform: scale(1.05);
}
body.dark-mode .ia-input-icon-btn:hover {
    background: rgba(10, 132, 255, 0.1);
}
.ia-input-icon-btn:focus-visible {
    outline: 2px solid var(--apple-blue);
    outline-offset: 2px;
}


/* ═══ Phase 6b: Copy Button ═══ */

.ia-copy-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}
.ia-copy-btn:hover {
    border-color: var(--apple-blue);
    color: var(--apple-blue);
    background: rgba(0, 122, 255, 0.06);
    transform: scale(1.05);
}
.ia-copy-btn:focus-visible {
    outline: 2px solid var(--apple-blue);
    outline-offset: 2px;
}
.ia-copy-btn.ia-copied {
    border-color: var(--success, #34C759);
    color: var(--success, #34C759);
}


/* ═══ Phase 6a: Inline Field Edit ═══ */

.ia-field-edit-btn {
    opacity: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    flex-shrink: 0;
    transition: opacity 0.15s, color 0.15s;
}
.ia-section-field:hover .ia-field-edit-btn {
    opacity: 1;
}
.ia-field-edit-btn:hover {
    color: var(--apple-blue);
}
.ia-field-edit-btn:focus-visible {
    opacity: 1;
    outline: 2px solid var(--apple-blue);
    outline-offset: 2px;
}

.ia-field-edit-input {
    width: 100%;
    padding: 2px 6px;
    border: 1.5px solid var(--apple-blue);
    border-radius: 6px;
    background: var(--bg-input);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    text-align: right;
    outline: none;
}


/* ═══ Phase 2: Hazard Badges ═══ */

.ia-hazard-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 6px 14px 8px;
}

.ia-hazard-badge {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.ia-hazard-badge-orange {
    background: rgba(255, 159, 10, 0.12);
    color: #FF9500;
}
body.dark-mode .ia-hazard-badge-orange {
    background: rgba(255, 159, 10, 0.18);
    color: #FFB340;
}

.ia-hazard-badge-red {
    background: rgba(255, 59, 48, 0.10);
    color: var(--danger, #FF3B30);
}
body.dark-mode .ia-hazard-badge-red {
    background: rgba(255, 69, 58, 0.18);
    color: var(--danger, #FF453A);
}

.ia-hazard-badge-green {
    background: rgba(52, 199, 89, 0.10);
    color: var(--success, #34C759);
}
body.dark-mode .ia-hazard-badge-green {
    background: rgba(50, 215, 75, 0.15);
    color: var(--success, #32D74B);
}


/* ═══ Phase 1: Market Intelligence Card ═══ */

.ia-market-intel-body {
    padding: 12px 14px;
}

.ia-appreciation-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 8px;
}
.ia-appreciation-green {
    background: rgba(52, 199, 89, 0.12);
    color: var(--success, #34C759);
}
body.dark-mode .ia-appreciation-green {
    background: rgba(50, 215, 75, 0.15);
    color: var(--success, #32D74B);
}
.ia-appreciation-yellow {
    background: rgba(255, 159, 10, 0.12);
    color: #FF9500;
}
body.dark-mode .ia-appreciation-yellow {
    background: rgba(255, 159, 10, 0.18);
    color: #FFB340;
}
.ia-appreciation-red {
    background: rgba(255, 59, 48, 0.10);
    color: var(--danger, #FF3B30);
}
body.dark-mode .ia-appreciation-red {
    background: rgba(255, 69, 58, 0.18);
    color: var(--danger, #FF453A);
}

.ia-sparkline-wrap {
    margin: 6px 0;
}

.ia-sparkline {
    display: block;
    max-width: 100%;
}

.ia-market-trend-note {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 0;
    line-height: 1.5;
}

.ia-market-disclaimer {
    font-size: 10px;
    color: var(--text-tertiary);
    font-style: italic;
    margin-top: 6px;
    opacity: 0.8;
}


/* ═══ Phase 4: Insurance Trends Card ═══ */

.ia-insurance-body {
    padding: 12px 14px;
}

.ia-insurance-rate {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.ia-insurance-trend {
    font-size: 13px;
    font-weight: 700;
    color: var(--apple-blue);
    margin-bottom: 6px;
}

.ia-insurance-carrier-note {
    font-size: 12px;
    color: var(--danger, #FF3B30);
    padding: 4px 0;
    line-height: 1.4;
}

.ia-insurance-tip {
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 0;
    line-height: 1.4;
}


/* ═══ Focus Visible States (all new interactive elements) ═══ */

.ia-chip:focus-visible,
.ia-send-btn:focus-visible,
.ia-clear-btn:focus-visible,
.ia-export-btn:focus-visible,
.ia-populate-btn-sm:focus-visible,
.ia-map-expand-btn:focus-visible,
.ia-section-header:focus-visible,
.ia-tab:focus-visible {
    outline: 2px solid var(--apple-blue);
    outline-offset: 2px;
}


/* ═══ Reduced Motion ═══ */

@media (prefers-reduced-motion: reduce) {
    .ia-msg,
    .ia-section,
    .ia-chip-row,
    .ia-hazard-badge,
    .ia-appreciation-badge {
        animation: none !important;
        transition: none !important;
    }
    .ia-dot { animation: none !important; }
    .ia-section-chevron { transition: none !important; }
}

/* ═══ Drag-and-Drop Overlay ═══ */

.ia-chat-card {
    position: relative;
}

.ia-drop-overlay {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 50;
    background: rgba(0, 122, 255, 0.04);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 2px dashed var(--apple-blue);
    border-radius: 16px;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    animation: iaDropFadeIn 0.2s ease;
}

.ia-chat-card.ia-drag-over .ia-drop-overlay {
    display: flex;
}

@keyframes iaDropFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.ia-drop-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    text-align: center;
    padding: 32px;
}

.ia-drop-icon {
    color: var(--apple-blue);
    opacity: 0.7;
    animation: iaDropBounce 1.5s ease infinite;
}

@keyframes iaDropBounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

.ia-drop-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--apple-blue);
}

.ia-drop-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 220px;
}

body.dark-mode .ia-drop-overlay {
    background: rgba(10, 132, 255, 0.10);
    border-color: #0A84FF;
}

/* Processing state message in chat */
.ia-msg-doc-processing {
    border-left: 3px solid var(--apple-blue);
    background: rgba(0, 122, 255, 0.04);
}
body.dark-mode .ia-msg-doc-processing {
    background: rgba(10, 132, 255, 0.08);
}

.ia-doc-field-count {
    display: inline-block;
    background: var(--apple-blue);
    color: #fff;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 700;
    margin-right: 4px;
}

/* ═══ Desktop Wide-Screen Enhancements ═══ */

@media (min-width: 1280px) {
    .ia-layout {
        grid-template-columns: 1fr 460px;
    }
    .ia-chat-pane {
        padding: 16px 20px;
    }
    .ia-sidebar-pane {
        padding: 16px;
    }
    .ia-messages {
        padding: 18px 22px;
    }
    .ia-input-row {
        padding: 14px 22px 16px;
    }
    .ia-chip-row {
        padding: 10px 22px 14px;
    }
}

@media (min-width: 1440px) {
    .ia-layout {
        grid-template-columns: 1fr 500px;
    }
}

/* ═══ Enhanced Scrollbar (WebKit) ═══ */

.ia-messages::-webkit-scrollbar,
.ia-sidebar-pane::-webkit-scrollbar {
    width: 6px;
}

.ia-messages::-webkit-scrollbar-track,
.ia-sidebar-pane::-webkit-scrollbar-track {
    background: transparent;
}

.ia-messages::-webkit-scrollbar-thumb,
.ia-sidebar-pane::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}
.ia-messages::-webkit-scrollbar-thumb:hover,
.ia-sidebar-pane::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

body.dark-mode .ia-messages::-webkit-scrollbar-thumb,
body.dark-mode .ia-sidebar-pane::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.08);
}
body.dark-mode .ia-messages::-webkit-scrollbar-thumb:hover,
body.dark-mode .ia-sidebar-pane::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* ═══ Dark Mode Polish — Surface Elevation Hierarchy ═══ */

body.dark-mode .ia-tab-bar {
    background: #111111;
    border-bottom-color: #2C2C2E;
}

body.dark-mode .ia-chat-pane {
    border-right-color: #2C2C2E;
}

body.dark-mode .ia-card.ia-chat-card {
    background: #111111;
}

body.dark-mode .ia-input-row {
    border-top-color: #2C2C2E;
}

body.dark-mode .ia-section-body {
    border-top-color: #2C2C2E;
}

body.dark-mode .ia-sidebar-card-header {
    border-bottom-color: #2C2C2E;
}

body.dark-mode .ia-map-grid {
    background: #2C2C2E;
}

body.dark-mode .ia-export-btn {
    border-color: #38383A;
    background: #1C1C1E;
}
body.dark-mode .ia-export-btn:hover {
    border-color: #0A84FF;
    color: #0A84FF;
}

body.dark-mode .ia-copy-btn {
    border-color: #38383A;
    background: #1C1C1E;
}

body.dark-mode .ia-populate-btn-sm {
    background: #32D74B;
}

body.dark-mode .ia-input {
    border-color: #38383A;
    background: #1C1C1E;
}

body.dark-mode .ia-input-icon-btn {
    border-color: #38383A;
    background: #1C1C1E;
}

body.dark-mode .ia-drop-overlay {
    background: rgba(10, 132, 255, 0.08);
    border-color: rgba(10, 132, 255, 0.4);
}

/* Section badge dark mode polish */
body.dark-mode .ia-section-badge {
    background: #2C2C2E;
}
body.dark-mode .ia-section-done .ia-section-badge {
    background: rgba(50, 215, 75, 0.12);
    color: #32D74B;
}
body.dark-mode .ia-section-partial .ia-section-badge {
    background: rgba(10, 132, 255, 0.12);
    color: #0A84FF;
}

/* Mobile dark mode full-bleed chat */
@media (max-width: 767px) {
    body.dark-mode .ia-card.ia-chat-card {
        background: #000000;
    }
    body.dark-mode .ia-sidebar-pane {
        background: #000000;
    }
}
