﻿/* RoomCoachWidget.razor.css */

/* Container - Make it flex-aware */
.room-coach {
    position: relative; /* Changed from sticky for mobile */
    margin: 14px auto 0 auto;
    border: 1px solid rgba(0,0,0,.10);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 8px 30px rgba(0,0,0,.08);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    /* Let parent control the height on mobile */
}

/* Header */
.room-coach-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    font-weight: 700;
    cursor: pointer;
    user-select: none;
    background: linear-gradient(to bottom, rgba(0,0,0,.02), rgba(0,0,0,.00));
    border-bottom: 1px solid rgba(0,0,0,.06);
}

    .room-coach-header .chev {
        font-size: 14px;
        opacity: .7;
    }

.hdr-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hdr-avatar {
    width: 22px;
    height: 22px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.12);
    font-weight: 700;
}

.hdr-title {
    font-weight: 700;
}

.hdr-sub {
    font-size: 12px;
    opacity: .7;
    font-weight: 600;
}

.hdr-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hdr-btn {
    padding: 3px 6px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 6px;
    background: rgba(0,0,0,.04);
    border: 1px solid rgba(0,0,0,.15);
}

    .hdr-btn:hover:not(:disabled) {
        background: rgba(0,0,0,.08);
    }

    .hdr-btn:disabled {
        opacity: .5;
        cursor: default;
    }

/* Body - grows with content, scrolls after max-height */
.room-coach-body {
    padding: 12px 14px 14px 14px;
    scroll-behavior: smooth;
    overflow-anchor: none;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    max-height: 400px; /* Fixed pixel value - more reliable in WebView */
}

/* Desktop: use viewport-based heights */
@media (min-width: 769px) {
    .room-coach-body {
        max-height: 55vh;
    }
}

/* Mobile-specific adjustments */
@media (max-width: 768px) {
    .room-coach {
        position: relative;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    .room-coach-body {
        max-height: 350px; /* Fixed pixel value for mobile */
        overflow-y: auto !important; /* Force overflow */
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
    }
}

/* Extra small screens */
@media (max-width: 480px) {
    .room-coach-body {
        max-height: 300px;
    }
}

/* Short phones / landscape */
@media (max-height: 600px) {
    .room-coach-body {
        max-height: 200px;
    }
}

/* Chat Transcript */
.chat-transcript,
.bot-msg,
.user-bubble {
    contain: layout style paint;
}

/* Bot Messages */
.bot-msg {
    margin: 10px 0;
}

.bot-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 6px 2px;
    opacity: .85;
    font-size: 12px;
    font-weight: 600;
}

.bot-avatar {
    width: 18px;
    height: 18px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,.10);
}

.bot-name {
    letter-spacing: .2px;
}

/* Chat Bubbles */
.bot-bubble,
.user-bubble {
    display: inline-block;
    max-width: 92%;
    padding: 10px 12px;
    border-radius: 14px;
    line-height: 1.25;
    font-size: 14px;
    margin: 6px 0;
    white-space: pre-wrap;
    word-wrap: break-word;
    will-change: contents;
}

.bot-bubble {
    background: rgba(0,0,0,.05);
    color: rgba(0,0,0,.88);
    border-top-left-radius: 6px;
}

.user-bubble {
    background: rgba(0,0,0,.88);
    color: #fff;
    margin-left: auto;
    border-top-right-radius: 6px;
}

/* Text Input Area */
.coach-text {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 12px 0;
}

.coach-textarea {
    width: 100%;
    min-height: 100px;
    padding: 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.5;
    resize: vertical;
    transition: border-color 0.2s;
    outline: none;
}

    .coach-textarea:focus {
        border-color: #3b82f6;
        box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
    }

    .coach-textarea:disabled {
        background-color: #f3f4f6;
        cursor: not-allowed;
        opacity: 0.6;
    }

/* Action Buttons Container */
.coach-text-actions {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
}

.coach-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 10px;
}

/* Buttons */
.coach-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 16px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.5;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background: white;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

    .coach-btn:hover:not(:disabled) {
        background: #f9fafb;
        border-color: #9ca3af;
        transform: translateY(-1px);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    }

    .coach-btn:active:not(:disabled) {
        transform: translateY(0);
    }

    .coach-btn:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

/* Microphone Button */
.coach-btn--mic {
    flex: 0 0 auto;
    border-color: #9ca3af;
}

    .coach-btn--mic:hover:not(:disabled) {
        background: #f3f4f6;
        border-color: #6b7280;
    }

    .coach-btn--mic .fa-microphone {
        font-size: 16px;
    }

    .coach-btn--mic .mic-blinking {
        color: #ef4444;
        animation: pulse 1.5s ease-in-out infinite;
    }

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* Primary Button */
.coach-btn.primary,
.coach-btn--primary {
    flex: 1 1 auto;
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
    font-weight: 600;
    min-width: 160px;
}

    .coach-btn.primary:hover:not(:disabled),
    .coach-btn--primary:hover:not(:disabled) {
        background: #2563eb;
        border-color: #2563eb;
        box-shadow: 0 4px 6px rgba(59, 130, 246, 0.25);
        transform: translateY(-1px);
    }

/* Secondary Button */
.coach-btn.secondary {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

    .coach-btn.secondary:hover:not(:disabled) {
        background: #e5e7eb;
    }

/* Button Label */
.btn-label {
    display: inline;
}

/* Speech Container */
.speechtext-containerWwu {
    display: contents;
}

/* Jump to Latest */
.jump-latest-top {
    position: sticky;
    top: 8px;
    display: flex;
    justify-content: flex-end;
    z-index: 30;
    pointer-events: none;
}

.jump-latest {
    pointer-events: auto;
    margin-right: 10px;
    padding: 6px 10px;
    border-radius: 999px;
    font-weight: 800;
    font-size: 12px;
    border: 1px solid rgba(0,0,0,.18);
    background: rgba(255,255,255,.92);
    box-shadow: 0 6px 18px rgba(0,0,0,.10);
    white-space: nowrap;
}

.scroll-spacer {
    height: 28px;
}

/* Progress Indicator */
.coach-progress {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #f3f4f6;
    border-radius: 8px;
    margin: 12px 0;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.progress-text {
    color: #6b7280;
    font-size: 14px;
}

/* Alerts and Errors */
.coach-alert {
    display: flex;
    gap: 12px;
    padding: 14px;
    border-radius: 8px;
    margin: 12px 0;
}

    .coach-alert.error {
        background: #fef2f2;
        border: 1px solid #fecaca;
    }

.alert-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.alert-content {
    flex: 1;
}

.alert-title {
    font-weight: 600;
    color: #991b1b;
    margin-bottom: 4px;
}

.alert-message {
    color: #dc2626;
    font-size: 14px;
}

.alert-close {
    background: transparent;
    border: none;
    color: #dc2626;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    line-height: 1;
    flex-shrink: 0;
}

/* Task Groups */
.coach-group {
    margin-top: 12px;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px;
    overflow: hidden;
}

.coach-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: #f9fafb;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

    .coach-group-header:hover {
        background: #f3f4f6;
    }

.expand-icon {
    font-size: 12px;
    color: #6b7280;
    transition: transform 0.2s;
}

.coach-group-title {
    font-weight: 800;
    font-size: 13px;
}

.coach-group-count {
    margin-left: auto;
    font-size: 12px;
    color: #6b7280;
    background: white;
    padding: 4px 8px;
    border-radius: 12px;
}

.coach-group-content {
    padding-top: 8px;
}

/* Tasks */
.coach-task {
    display: flex;
    gap: 10px;
    padding: 10px 12px;
    align-items: flex-start;
    border-bottom: 1px solid rgba(0,0,0,.06);
}

    .coach-task:last-child {
        border-bottom: none;
    }

    .coach-task input[type="checkbox"] {
        margin-top: 3px;
        transform: scale(1.05);
    }

.coach-task-body {
    flex: 1;
    display: grid;
    gap: 6px;
}

.coach-task-cat {
    font-weight: 800;
    font-size: 13px;
}

.coach-task-add {
    margin-top: 0px;
    padding: 6px 10px;
    border-radius: 10px;
    font-weight: 800;
    font-size: 12px;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid rgba(0,0,0,.15);
    background: rgba(0,0,0,.04);
}

    .coach-task-add:hover {
        background: rgba(0,0,0,.07);
    }

    .coach-task-add.is-added {
        opacity: 0.7;
        cursor: not-allowed;
    }

/* Upload Panel */
.upload-panel {
    margin-top: 12px;
}

.upload-card {
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 14px;
    padding: 12px;
}

.upload-head {
    margin-bottom: 10px;
}

.upload-title {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
}

.upload-sub {
    margin-top: 2px;
    font-size: 12px;
    opacity: .7;
}

.upload-picker {
    position: relative;
}

.upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    clip-path: inset(50%);
}

.upload-drop {
    display: block;
    border: 1px dashed rgba(0,0,0,.18);
    border-radius: 14px;
    padding: 18px 14px;
    background: rgba(0,0,0,.02);
    cursor: pointer;
    user-select: none;
    transition: background 120ms ease, border-color 120ms ease, transform 120ms ease;
}

    .upload-drop:hover {
        background: rgba(0,0,0,.03);
        border-color: rgba(0,0,0,.28);
    }

    .upload-drop:active {
        transform: scale(.995);
    }

.upload-drop-inner {
    text-align: center;
}

.upload-cta {
    font-weight: 700;
    font-size: 14px;
}

.upload-hint {
    margin-top: 3px;
    font-size: 12px;
    opacity: .7;
}

.upload-btnrow {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

    .upload-btnrow .upload-btn {
        flex: 1;
    }

.upload-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.upload-btn {
    border: 1px solid rgba(0,0,0,.12);
    background: #fff;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 13px;
    cursor: pointer;
}

    .upload-btn.primary {
        border-color: rgba(0,0,0,.12);
        background: rgba(0,0,0,.90);
        color: #fff;
    }

    .upload-btn:disabled {
        opacity: .6;
        cursor: not-allowed;
    }

/* Thumbnails */
.thumbs {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
    max-height: 220px;
    overflow: auto;
    padding-right: 4px;
}

.thumb {
    position: relative;
    width: 120px;
}

    .thumb img {
        width: 120px;
        height: 90px;
        display: block;
        object-fit: cover;
        border-radius: 12px;
        border: 1px solid rgba(0,0,0,.08);
    }

.thumb-name {
    font-size: 12px;
    opacity: .75;
    margin-top: 4px;
    word-break: break-word;
}

.thumb-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

    .thumb-remove:hover {
        background: rgba(0, 0, 0, 0.8);
    }

/* Image Analysis */
.img-analysis-card {
    margin-top: 12px;
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 14px;
    padding: 12px;
}

    .img-analysis-card.error {
        border-color: rgba(255,0,0,.18);
        background: rgba(255,0,0,.03);
    }

.img-analysis-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.img-analysis-title {
    font-weight: 800;
    font-size: 14px;
}

.img-analysis-sub {
    font-size: 12px;
    opacity: .75;
}

.img-preview-wrap {
    margin-top: 10px;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 1;
}

.img-preview {
    width: 100%;
    max-height: 220px;
    object-fit: cover;
    display: block;
}

.img-items-scroll {
    margin-top: 10px;
    max-height: 240px;
    overflow: auto;
    padding-right: 4px;
    border-top: 1px solid rgba(0,0,0,.06);
    padding-top: 10px;
}

.img-items {
    display: grid;
    gap: 10px;
}

.img-item {
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 12px;
    padding: 10px;
    background: rgba(0,0,0,.01);
}

.img-item-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.img-item-desc {
    font-weight: 700;
    font-size: 13px;
    line-height: 1.25;
}

.img-item-conf {
    font-size: 12px;
    opacity: .75;
    white-space: nowrap;
}

.img-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.pill {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(0,0,0,.10);
    border-radius: 999px;
    padding: 3px 8px;
    font-size: 12px;
    background: #fff;
}

    .pill.subtle {
        opacity: .8;
    }

    .pill.warn {
        border-color: rgba(255,165,0,.25);
        background: rgba(255,165,0,.10);
    }

.img-item-evidence,
.img-item-notes {
    margin-top: 8px;
    font-size: 12px;
    opacity: .85;
    line-height: 1.35;
}

.img-item-refs {
    margin-top: 8px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.ref {
    font-size: 11px;
    opacity: .7;
    border: 1px dashed rgba(0,0,0,.14);
    border-radius: 10px;
    padding: 2px 6px;
}

/* Confirmation Dialog */
.coach-confirm-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1200 !important;
}

.coach-confirm-dialog {
    background: white;
    border-radius: 8px;
    padding: 20px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 1210; 
    position: relative;
}

.coach-confirm-header h3 {
    margin: 0 0 12px 0;
    font-size: 18px;
    font-weight: 600;
}

.coach-confirm-body p {
    margin: 0 0 20px 0;
    color: #666;
}

.coach-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* Toast Notifications */
.coach-toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 16px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

    .coach-toast.success {
        background: #10b981;
        color: white;
    }

    .coach-toast.error {
        background: #ef4444;
        color: white;
    }

    .coach-toast.info {
        background: #3b82f6;
        color: white;
    }

.toast-message {
    flex: 1;
}

.toast-close {
    background: transparent;
    border: none;
    color: inherit;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    line-height: 1;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Miscellaneous */
.coach-pill {
    display: inline-block;
    padding: 6px 9px;
    border-radius: 999px;
    font-size: 12px;
    border: 1px solid rgba(0,0,0,.14);
    background: #fff;
}

.coach-suggest {
    margin-top: 6px;
    font-size: 12px;
    opacity: .8;
}

/* Responsive Design */
@media (max-width: 640px) {
    .coach-text-actions {
        flex-direction: column;
        width: 100%;
    }

    .coach-btn--mic,
    .coach-btn--primary {
        width: 100%;
        flex: 1 1 auto;
    }
}

@media (max-width: 520px) {
    .room-coach {
        border-radius: 12px;
        bottom: 10px;
    }

    .coach-actions {
        gap: 8px;
    }

    .coach-btn {
        width: 100%;
        text-align: center;
    }

    .bot-bubble,
    .user-bubble {
        max-width: 100%;
    }
}


/* Scope Actions */
.room-info-data__scope-actions {
    display: flex;
    justify-content: flex-end;
    padding: 0 0 16px 0;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

/* Danger Outline Button */
.room-info-data__btn--danger-outline {
    background: transparent;
    color: #dc2626;
    border: 1px solid #dc2626;
}

    .room-info-data__btn--danger-outline:hover:not(:disabled) {
        background: #fef2f2;
        border-color: #b91c1c;
        color: #b91c1c;
    }

    .room-info-data__btn--danger-outline:disabled {
        opacity: 0.5;
        cursor: not-allowed;
    }

/* Confirm Warning Text */
.room-info-data__confirm-warning {
    color: #dc2626;
    font-size: 13px;
    margin-top: 8px;
}


/* Proposal Card - Separate from chat widget */
.proposal-card {
    margin: 14px auto 0 auto;
    border: 1px solid rgba(0, 0, 0, 0.10);
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.proposal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: linear-gradient(to bottom, rgba(59, 130, 246, 0.05), rgba(59, 130, 246, 0.02));
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.proposal-card-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
    color: #1f2937;
}

.proposal-icon {
    font-size: 18px;
}

.proposal-card-meta {
    font-size: 13px;
    color: #6b7280;
    font-weight: 600;
    background: white;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.proposal-card-body {
    padding: 12px;
    max-height: 400px;
    overflow-y: auto;
}

.proposal-card-footer {
    padding: 14px 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    background: #f9fafb;
}

/* Proposal Groups */
.proposal-group {
    margin-bottom: 10px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    overflow: hidden;
    background: white;
}

    .proposal-group:last-child {
        margin-bottom: 0;
    }

.proposal-group-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 12px;
    background: #f9fafb;
    border: none;
    cursor: pointer;
    transition: background 0.2s;
}

    .proposal-group-header:hover {
        background: #f3f4f6;
    }

.proposal-group-title {
    font-weight: 700;
    font-size: 14px;
    flex: 1;
}

.proposal-group-count {
    font-size: 12px;
    color: #6b7280;
    background: white;
    padding: 3px 8px;
    border-radius: 10px;
    border: 1px solid rgba(0, 0, 0, 0.06);
}

.proposal-group-content {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

/* Proposal Tasks */
.proposal-task {
    display: flex;
    gap: 10px;
    padding: 12px;
    align-items: flex-start;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    transition: background-color 0.2s;
}

    .proposal-task:last-child {
        border-bottom: none;
    }

    .proposal-task:hover {
        background-color: rgba(59, 130, 246, 0.02);
    }

.proposal-task-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.proposal-task-cat {
    font-weight: 700;
    font-size: 12px;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.proposal-task-desc {
    font-size: 14px;
    color: #1f2937;
    line-height: 1.4;
}

.proposal-task-add {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    line-height: 1;
    white-space: nowrap;
    border: 1px solid #3b82f6;
    background: white;
    color: #3b82f6;
    cursor: pointer;
    transition: all 0.2s;
}

    .proposal-task-add:hover:not(:disabled) {
        background: #3b82f6;
        color: white;
        transform: scale(1.05);
    }

    .proposal-task-add.is-added {
        background: #10b981;
        border-color: #10b981;
        color: white;
        opacity: 0.8;
        cursor: not-allowed;
    }

    .proposal-task-add:disabled {
        opacity: 0.6;
        cursor: not-allowed;
    }

/* Proposal Actions */
.proposal-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Responsive */
@media (max-width: 640px) {
    .proposal-card-body {
        max-height: 300px;
    }

    .proposal-task {
        flex-direction: column;
        align-items: stretch;
    }

    .proposal-task-add {
        width: 100%;
    }
}

/* Option 1: Overlay Legend */

.coach-legend-overlay {
    position: fixed; /* was absolute */
    inset: 0; /* replaces top/left/right/bottom */
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000; /* higher than .room-info-data (1010) */
}

.coach-legend-panel {
    background: white;
    border-radius: 8px;
    max-width: 500px;
    width: 90%;
    max-height: 80vh; /* use vh since it’s viewport-based now */
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}


.coach-legend-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.coach-legend-body {
    padding: 16px;
}

.legend-section {
    margin-bottom: 20px;
}

    .legend-section h4 {
        font-size: 14px;
        font-weight: 600;
        margin-bottom: 8px;
        color: #333;
    }

.legend-list {
    list-style: none;
    padding-left: 0;
}

    .legend-list li {
        padding: 4px 0;
        font-size: 13px;
        color: #555;
    }

    .legend-list code {
        background: #f5f5f5;
        padding: 2px 6px;
        border-radius: 3px;
        font-size: 12px;
        color: #e83e8c;
    }

.hdr-btn--help {
    font-size: 18px;
    padding: 4px 8px;
}


.coach-btn.is-processing {
    opacity: 0.8;
    cursor: not-allowed;
}

.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-right: 8px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* Measurement Options */
.coach-measurement-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 16px 0;
    padding: 0 12px;
}

.measurement-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

    .measurement-btn i {
        font-size: 16px;
    }

    .measurement-btn:hover:not(:disabled) {
        transform: translateY(-1px);
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    .measurement-btn:active:not(:disabled) {
        transform: translateY(0);
    }

/* Mobile: Stack vertically with full width */
@media (max-width: 640px) {
    .coach-measurement-options {
        gap: 8px;
    }

    .measurement-btn {
        width: 100%;
    }
}

/* Desktop: Can optionally display in a row if preferred */
@media (min-width: 641px) {
    .coach-measurement-options {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .measurement-btn {
        flex: 1;
        min-width: 140px;
    }
}







/* =========================================================
   Phase 3: RoomCoach “screenshot” skin (bubbles + surfaces)
   ========================================================= */

/* Inside panel wrapper, RoomCoach should be flat (panel provides the card) */
.z-panel .room-coach {
    background: transparent;
}

/* Bubbles use tokens */
.bot-bubble {
    background: var(--bg-surface-2) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    border-top-left-radius: var(--r-8) !important;
  
    display: inline-block; 
    max-width: 92%; 
    padding: 10px 12px; 
    line-height: 1.35;
    white-space: pre-wrap; 
    overflow-wrap: anywhere; 
    word-break: break-word; 
}

.user-bubble {
    background: var(--brand-primary) !important;
    color: #fff !important;
    border: 1px solid transparent !important;
    border-top-right-radius: var(--r-8) !important;
}

/* Chat header should be lighter + modern */
.room-coach-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border) !important;
}

/* Buttons align to your design system */
.coach-btn--primary,
.coach-btn.primary {
    background: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
}

    .coach-btn--primary:hover:not(:disabled),
    .coach-btn.primary:hover:not(:disabled) {
        background: var(--brand-primary-hover) !important;
        border-color: var(--brand-primary-hover) !important;
    }


/* =========================================================
   Phase 3: RoomCoach skin (match screenshot)
   - panel wrapper (z-panel) provides the card
   - flatter header + crisp divider
   - modern bubbles (AI gray, user blue)
   - cleaner transcript spacing
   ========================================================= */

.z-panel .room-coach {
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    margin: 0 !important;
}

/* Header: flat, subtle divider */
.z-panel .room-coach-header {
    background: transparent !important;
    border-bottom: 1px solid var(--border) !important;
    padding: 10px 0 !important;
    cursor: pointer;
}

/* Avatar: simple neutral */
.z-panel .hdr-avatar {
    background: var(--bg-surface-2) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    font-weight: var(--fw-bold);
}

/* Header type */
.z-panel .hdr-title {
    font-weight: var(--fw-bold) !important;
    color: var(--text-primary) !important;
    letter-spacing: -0.01em;
}

.z-panel .hdr-sub {
    color: var(--text-secondary) !important;
}

/* Header buttons */
.z-panel .hdr-btn {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--r-8) !important;
    color: var(--text-primary) !important;
    box-shadow: none !important;
}

    .z-panel .hdr-btn:hover:not(:disabled) {
        background: var(--bg-surface-2) !important;
    }

.z-panel .hdr-btn--help {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
}

/* Body spacing */
.z-panel .room-coach-body {
    padding: 14px 0 0 0 !important;
}

/* Transcript spacing */
.z-panel .chat-transcript {
    padding: 6px 0 0 0 !important;
}

.z-panel .bot-msg {
    margin: 10px 0 14px 0 !important;
}

.z-panel .bot-meta {
    margin-bottom: 6px !important;
    color: var(--text-secondary) !important;
}

/* Bot bubble: light gray surface with border */
.z-panel .bot-bubble {
    background: var(--bg-surface-2) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--r-16) !important;
    border-top-left-radius: var(--r-8) !important;
    color: var(--text-primary) !important;
    padding: 10px 12px !important;
    box-shadow: none !important;
    /* streaming stability */
    display: block; /* NEW: avoids inline-block baseline/width quirks */
    max-width: 100%; /* NEW: wrapper controls width */
    min-width: 0; /* NEW: allow proper wrapping in flex contexts */
    line-height: 1.35;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
    /* NEW: prevent scroll anchoring inside bubble */
    overflow-anchor: none;
    /* keep transitions from affecting size */
    transition: background-color 120ms ease, border-color 120ms ease;
}



/* User bubble: primary blue pill */
.z-panel .user-bubble {
    background: var(--brand-primary) !important;
    color: #fff !important;
    border-radius: var(--r-16) !important;
    border-top-right-radius: var(--r-8) !important;
    padding: 10px 12px !important;
    box-shadow: none !important;
}

/* Progress row: subtle */
.z-panel .coach-progress {
    border: 1px solid var(--border) !important;
    background: var(--bg-surface) !important;
    border-radius: var(--r-12) !important;
}

/* Primary buttons in coach: align with tokens */
.z-panel .coach-btn.primary,
.z-panel .coach-btn--primary {
    background: var(--brand-primary) !important;
    border-color: var(--brand-primary) !important;
    color: #fff !important;
    border-radius: var(--r-8) !important;
    box-shadow: none !important;
}

    .z-panel .coach-btn.primary:hover:not(:disabled),
    .z-panel .coach-btn--primary:hover:not(:disabled) {
        background: var(--brand-primary-hover) !important;
        border-color: var(--brand-primary-hover) !important;
    }

/* Secondary buttons: light surface */
.z-panel .coach-btn.secondary {
    background: var(--bg-surface-2) !important;
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    border-radius: var(--r-8) !important;
    box-shadow: none !important;
}

/* Textareas: modern input surface */
.z-panel .coach-textarea {
    background: var(--bg-surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--r-12) !important;
    color: var(--text-primary) !important;
    box-shadow: none !important;
}

    .z-panel .coach-textarea:focus {
        outline: none !important;
        box-shadow: var(--focus) !important;
        border-color: rgba(0, 102, 204, 0.35) !important;
    }

/* Upload card: flatten (panel already provides card) */
.z-panel .upload-card,
.z-panel .img-analysis-card {
    border: 1px solid var(--border) !important;
    box-shadow: none !important;
    border-radius: var(--r-16) !important;
    background: var(--bg-surface) !important;
}

/* =========================================================
   Chat alignment: user on right, bot on left
   ========================================================= */

/* Make transcript a vertical flex stack */
.z-panel .chat-transcript {
    display: flex;
    flex-direction: column;
    gap: 12px;
    /* NEW: prevents “jumping” while text streams */
    overflow-anchor: none;
}

/* Bot messages already have a wrapper (.bot-msg). Keep them left. */
.z-panel .bot-msg {
    align-self: flex-start;
    /* Keep the wrapper width stable */
    max-width: 92%;
    min-width: 0;
    /* NEW: also disable anchoring on this subtree */
    overflow-anchor: none;
}

/* User bubbles have NO wrapper. Target them directly and push right. */
.z-panel .chat-transcript > .user-bubble {
    align-self: flex-end;
    max-width: 78%; /* feels like iMessage */
    text-align: left; /* keep text readable */
}

/* Optional: add a little right “breathing room” so it doesn’t touch edge */
.z-panel .chat-transcript > .user-bubble {
    margin-right: 2px;
}

/* If your user bubble currently spans full width because it's display:block somewhere */
.z-panel .user-bubble {
    display: inline-block;
}


/* =========================================================
   Chat bubble tails (subtle)
   ========================================================= */

/* Ensure tails can position correctly */
.z-panel .bot-bubble,
.z-panel .user-bubble {
    position: relative;
}

    /* BOT tail (left) */
    .z-panel .bot-bubble::after {
        content: "";
        position: absolute;
        left: -6px;
        bottom: 10px;
        width: 10px;
        height: 10px;
        background: var(--bg-surface-2);
        border-left: 1px solid var(--border);
        border-bottom: 1px solid var(--border);
        transform: rotate(45deg);
        border-bottom-left-radius: 2px;
        opacity: 0.95;
    }

    /* USER tail (right) */
    .z-panel .user-bubble::after {
        content: "";
        position: absolute;
        right: -6px;
        bottom: 10px;
        width: 10px;
        height: 10px;
        background: var(--brand-primary);
        transform: rotate(45deg);
        border-bottom-right-radius: 2px;
        opacity: 0.95;
    }

/* Keep tails from looking weird on very short bubbles */
.z-panel .bot-bubble,
.z-panel .user-bubble {
    padding-bottom: 10px;
}


/* =========================================================
   Chat spacing: keep user bubbles off the right edge
   ========================================================= */

/* Give the transcript some side breathing room */
.z-panel .chat-transcript {
    padding-left: 6px;
    padding-right: 10px; /* slightly more on the right */
}

    /* Pull user bubbles inward */
    .z-panel .chat-transcript > .user-bubble {
        margin-right: 10px; /* key change */
    }

/* Also pull bot bubbles inward a touch for symmetry */
.z-panel .bot-msg {
    margin-left: 2px;
}

/* Project Photos Picker Styles */
.project-photos-picker {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary, #f8f9fa);
    border-radius: 8px;
    border: 1px solid var(--border-color, #dee2e6);
}

.project-photos-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.project-photos-title {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary, #333);
}

.project-photos-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-secondary, #666);
    padding: 0;
    line-height: 1;
}

    .project-photos-close:hover {
        color: var(--text-primary, #333);
    }

.project-photos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
}

.project-photo-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: border-color 0.15s, transform 0.15s;
}

    .project-photo-item:hover {
        transform: scale(1.02);
    }

    .project-photo-item.selected {
        border-color: var(--primary-color, #0d6efd);
    }

    .project-photo-item img {
        width: 100%;
        height: 100%;
        object-fit: cover;
    }

.project-photo-check {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    background: var(--primary-color, #0d6efd);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.7rem;
}

.project-photos-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color, #dee2e6);
}