/**
 * Document Magic Chat (floating bar + expanding chat window)
 * Styled to match the Sports Registration magic chat.
 */

.doc-detail-container {
    /* Room for floating bar; scales with --dm-scale on .doc-magic-bar-container */
    padding-bottom: calc(120px * 0.75);
}

.doc-magic-bar-container {
    /* ~1/4 smaller UI (75% scale) */
    --dm-scale: 0.75;
    position: fixed;
    bottom: calc(40px * var(--dm-scale));
    left: var(--sidebar-width, 240px);
    width: calc(100% - var(--sidebar-width, 240px));
    z-index: 1000;
    padding: 0 calc(40px * var(--dm-scale));
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
    transition: all 0.3s ease;
}

@media (max-width: 768px) {
    .doc-magic-bar-container {
        left: 0;
        width: 100%;
        padding: 0 calc(20px * var(--dm-scale));
        bottom: calc(24px * var(--dm-scale));
    }
}

.magic-bar {
    width: 100%;
    max-width: calc(900px * var(--dm-scale));
    background: rgba(255, 255, 255, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: calc(50px * var(--dm-scale));
    padding: calc(8px * var(--dm-scale)) calc(12px * var(--dm-scale));
    display: flex;
    align-items: center;
    box-shadow:
        0 10px 40px rgba(0, 0, 0, 0.08),
        0 4px 12px rgba(0, 0, 0, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.4);
    pointer-events: auto;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.magic-bar:focus-within {
    background: rgba(255, 255, 255, 0.9);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.12),
        0 8px 20px rgba(0, 0, 0, 0.06);
    transform: translateY(calc(-2px * var(--dm-scale)));
    border-color: rgba(255, 255, 255, 0.8);
}

.bar-left {
    display: flex;
    align-items: center;
    padding-left: calc(8px * var(--dm-scale));
}

.bar-center {
    flex: 1;
    margin: 0 calc(15px * var(--dm-scale));
}

.bar-center input {
    width: 100%;
    border: none !important;
    padding: calc(14px * var(--dm-scale)) 0;
    font-size: calc(1.1rem * var(--dm-scale));
    background: transparent;
    color: #0f172a;
    outline: none !important;
    font-weight: 400;
}

.bar-center input::placeholder {
    color: #94a3b8;
    font-weight: 400;
}

.bar-icon-btn.plus-btn {
    background: transparent;
    border: none;
    color: #64748b;
    width: calc(44px * var(--dm-scale));
    height: calc(44px * var(--dm-scale));
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.bar-icon-btn.plus-btn:hover {
    color: #1e293b;
    background: rgba(0, 0, 0, 0.04);
    transform: rotate(90deg);
}

.doc-magic-bar-container .bar-icon-btn.plus-btn svg {
    width: calc(22px * var(--dm-scale));
    height: calc(22px * var(--dm-scale));
}

.doc-magic-bar-container .bar-icon-btn-small svg,
.doc-magic-bar-container .bar-send-btn-compact svg {
    width: calc(18px * var(--dm-scale));
    height: calc(18px * var(--dm-scale));
}

.bar-right-stacked {
    display: flex;
    align-items: center;
    gap: calc(8px * var(--dm-scale));
    padding-right: calc(4px * var(--dm-scale));
}

.bar-icon-btn-small {
    background: transparent;
    border: none;
    color: #94a3b8;
    width: calc(36px * var(--dm-scale));
    height: calc(36px * var(--dm-scale));
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
}

.bar-icon-btn-small:hover {
    color: #1e293b;
    background: rgba(0, 0, 0, 0.04);
}

.bar-send-btn-compact {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    color: #fff;
    border: none;
    width: calc(44px * var(--dm-scale));
    height: calc(44px * var(--dm-scale));
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 4px 12px rgba(30, 41, 59, 0.25);
}

.bar-send-btn-compact:hover {
    transform: scale(1.1) translateY(-1px);
    box-shadow: 0 8px 20px rgba(30, 41, 59, 0.35);
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
}

.magic-bar-chat-window {
    width: 100%;
    max-width: calc(900px * var(--dm-scale));
    max-height: 0;
    overflow-y: auto;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: calc(24px * var(--dm-scale));
    margin-bottom: calc(20px * var(--dm-scale));
    /* Keep separation on light page backgrounds */
    box-shadow:
        0 22px 55px rgba(0, 0, 0, 0.16),
        0 0 0 1px rgba(15, 23, 42, 0.12);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    padding: 0;
    opacity: 0;
    pointer-events: none;
    border: 1px solid rgba(15, 23, 42, 0.12);
}

.magic-bar-chat-window.active {
    max-height: calc(500px * var(--dm-scale));
    padding: calc(24px * var(--dm-scale));
    opacity: 1;
    pointer-events: auto;
    box-shadow:
        0 26px 70px rgba(0, 0, 0, 0.18),
        0 0 0 1px rgba(15, 23, 42, 0.16);
    border-color: rgba(15, 23, 42, 0.16);
}

.chat-message {
    max-width: 80%;
    padding: calc(12px * var(--dm-scale)) calc(18px * var(--dm-scale));
    border-radius: calc(16px * var(--dm-scale));
    margin-bottom: calc(12px * var(--dm-scale));
    font-size: calc(0.95rem * var(--dm-scale));
    line-height: 1.6;
}

.chat-message.ai {
    align-self: flex-start;
    background: #f1f5f9;
    color: #1e293b;
    border-bottom-left-radius: 4px;
}

.chat-message.user {
    align-self: flex-end;
    background: #1e293b;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-message b {
    font-weight: 700;
}

.chat-message.ai b {
    color: #0f172a;
}

.chat-status-indicator {
    padding: calc(12px * var(--dm-scale)) calc(15px * var(--dm-scale));
    margin-bottom: calc(12px * var(--dm-scale));
    background: rgba(0, 0, 0, 0.03);
    border-radius: calc(12px * var(--dm-scale));
    color: rgba(15, 23, 42, 0.7);
    font-size: calc(0.9rem * var(--dm-scale));
    font-style: italic;
    display: flex;
    align-items: center;
    gap: calc(10px * var(--dm-scale));
    animation: docFadeIn 0.3s ease;
}

.chat-status-indicator .spinner {
    width: calc(16px * var(--dm-scale));
    height: calc(16px * var(--dm-scale));
    border: 2px solid rgba(15, 23, 42, 0.1);
    border-top: 2px solid var(--doc-primary, #4a90d9);
    border-radius: 50%;
    animation: docSpin 1s linear infinite;
}

@keyframes docSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

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

