/* Floating Schedule AI chat widget */

.ai-chat-fab {
    position: fixed;
    right: 1rem;
    bottom: 4.5rem; /* above help walkthrough controls */
    z-index: 1070;
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 50%;
    border: none;
    box-shadow: 0 0.35rem 1rem rgba(0, 0, 0, 0.22);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.35rem;
    background: var(--bs-primary, #0d6efd);
    color: #fff;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.ai-chat-fab:hover,
.ai-chat-fab:focus {
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.28);
}

.ai-chat-fab.is-hidden {
    display: none;
}

.ai-chat-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1068;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.ai-chat-backdrop.show {
    opacity: 1;
    visibility: visible;
}

.ai-chat-panel {
    position: fixed;
    z-index: 1069;
    display: flex;
    flex-direction: column;
    background: var(--card-bg, #fff);
    color: var(--text-color, inherit);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.125));
    box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.2);
    overflow: hidden;
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease, right 0.25s ease;
}

.ai-chat-panel.is-open {
    visibility: visible;
    opacity: 1;
    pointer-events: auto;
}

/* Docked to the right edge */
.ai-chat-panel.mode-dock {
    top: 0;
    right: -28rem;
    width: min(26rem, 100vw);
    height: 100vh;
    border-radius: 0;
    border-right: none;
    transform: none;
}

.ai-chat-panel.mode-dock.is-open {
    right: 0;
}

/* Overlay floating card */
.ai-chat-panel.mode-overlay {
    top: 50%;
    left: 50%;
    width: min(42rem, calc(100vw - 2rem));
    height: min(36rem, calc(100vh - 2rem));
    border-radius: 0.75rem;
    transform: translate(-50%, -46%) scale(0.96);
}

.ai-chat-panel.mode-overlay.is-open {
    transform: translate(-50%, -50%) scale(1);
}

.ai-chat-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
    background: var(--bs-primary, #0d6efd);
    color: #fff;
}

.ai-chat-header .btn-link,
.ai-chat-header .btn-outline-light {
    color: #fff;
}

.ai-chat-header-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    justify-content: flex-end;
}

.ai-chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    padding: 0.75rem;
    gap: 0.75rem;
}

.ai-chat-context {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.ai-chat-log {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
    border-radius: 0.5rem;
    padding: 0.75rem;
    background: var(--bs-gray-100, #f8f9fa);
}

.ai-chat-bubble {
    margin-bottom: 0.75rem;
}

.ai-chat-bubble:last-child {
    margin-bottom: 0;
}

.ai-chat-bubble-role {
    font-size: 0.75rem;
    color: var(--bs-secondary-color, #6c757d);
    margin-bottom: 0.2rem;
}

.ai-chat-bubble-body {
    padding: 0.55rem 0.7rem;
    border-radius: 0.45rem;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-chat-bubble.is-user .ai-chat-bubble-body {
    background: #fff;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.1));
}

.ai-chat-bubble.is-assistant .ai-chat-bubble-body {
    background: rgba(13, 110, 253, 0.12);
}

/* Composer + proposals stay pinned; chat log scrolls above */
.ai-chat-footer {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-height: 0;
}

.ai-chat-proposals {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    max-height: min(38vh, 16rem);
    overflow-y: auto;
    padding-top: 0.15rem;
}

.ai-chat-proposals.has-proposals {
    display: flex;
}

.ai-chat-body.has-pending-proposals .ai-chat-log {
    min-height: 5rem;
}

.ai-chat-proposal-card {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    border: 1px solid rgba(25, 135, 84, 0.45);
    border-radius: 0.45rem;
    padding: 0.65rem 0.75rem;
    background: rgba(25, 135, 84, 0.08);
    flex: 0 0 auto;
}

.ai-chat-proposal-card .ai-chat-proposal-title {
    font-weight: 600;
    font-size: 0.85rem;
}

.ai-chat-proposal-card .ai-chat-proposal-summary {
    font-size: 0.8rem;
    line-height: 1.35;
    max-height: 4.2em;
    overflow-y: auto;
}

.ai-chat-proposal-card .ai-chat-proposal-actions {
    flex: 0 0 auto;
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding-top: 0.15rem;
}

.ai-chat-proposal-card.is-done {
    opacity: 0.75;
    border-color: var(--border-color, rgba(0, 0, 0, 0.15));
    background: var(--bs-gray-100, #f8f9fa);
}

.ai-chat-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    flex: 0 0 auto;
}

.ai-chat-form textarea {
    resize: none;
}

.ai-chat-disabled-note {
    font-size: 0.8rem;
}

@media (max-width: 576px) {
    .ai-chat-fab {
        bottom: 5.25rem;
        right: 0.75rem;
    }

    .ai-chat-panel.mode-overlay,
    .ai-chat-panel.mode-dock {
        top: 0;
        left: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        border-radius: 0;
        transform: none;
    }

    .ai-chat-panel.mode-overlay.is-open,
    .ai-chat-panel.mode-dock.is-open {
        transform: none;
    }

    .ai-chat-context {
        grid-template-columns: 1fr;
    }
}
