/* assets/mils-chat.css */
/* Mils Chat — FAB + Drawer + Chat UI */

/* FAB Button */
.mils-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--accent-soft);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-glow);
    cursor: pointer;
    z-index: 1050;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.mils-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 0 60px rgba(31, 255, 185, 0.25);
    border-color: var(--accent);
}

.mils-fab img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}

/* Drawer */
.mils-drawer {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    height: 100vh;
    background: var(--card-bg);
    border-left: 1px solid var(--card-border);
    box-shadow: var(--shadow-premium);
    z-index: 1060;
    display: flex;
    flex-direction: column;
    transition: var(--transition-elegant);
    backdrop-filter: blur(20px);
}

.mils-drawer.open {
    right: 0;
}

.mils-drawer-header {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--card-border);
    gap: 12px;
}

.mils-drawer-header img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
}

.mils-drawer-header h6 {
    color: var(--text-primary);
    margin: 0;
    font-size: 0.95rem;
}

.mils-drawer-close {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
}

/* Explicit chat body wrappers — avoid fragile nth-child coupling with Dash DOM */
.mils-chat-body {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.mils-chat-loading,
.mils-chat-loading > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.mils-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* Block page scroll when drawer is open */
body:has(.mils-drawer.open) {
    overflow: hidden;
}

.mils-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.mils-message.assistant {
    align-self: stretch;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    background: var(--accent-soft);
    border: 1px solid var(--card-border);
}

.mils-message.user {
    align-self: flex-end;
    background: rgba(31, 255, 185, 0.08);
    border: 1px solid rgba(31, 255, 185, 0.15);
}

/* Input area */
.mils-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--card-border);
    display: flex;
    gap: 8px;
}

/* Dash wraps dcc.Input in .dash-input-container — force transparent bg */
.mils-input-area .dash-input-container {
    background: transparent !important;
}

.mils-input-area textarea,
.mils-input-area input[type="text"],
.mils-input-area .dash-input-element {
    flex: 1;
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--card-border) !important;
    border-radius: 10px;
    color: var(--text-primary) !important;
    padding: 8px 12px;
    resize: none;
    font-size: 0.85rem;
    min-height: 38px;
    max-height: 120px;
}

.mils-input-area textarea::placeholder,
.mils-input-area input[type="text"]::placeholder,
.mils-input-area .dash-input-element::placeholder {
    color: var(--text-secondary) !important;
}

.mils-input-area textarea:focus,
.mils-input-area input[type="text"]:focus,
.mils-input-area .dash-input-element:focus {
    border-color: var(--accent) !important;
    outline: none;
    box-shadow: 0 0 8px rgba(31, 255, 185, 0.18);
}

.mils-send-btn {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 10px;
    color: var(--accent);
    padding: 8px 16px;
    cursor: pointer;
    font-size: 0.85rem;
    transition: var(--transition-fast);
}

.mils-send-btn:hover {
    background: rgba(31, 255, 185, 0.25);
}

/* Page /assistente — scoped to mils-page-chat only (NOT .goal-card which is global) */
.mils-page-chat .dash-input-container {
    background: transparent !important;
}

.mils-page-chat .dash-input-element {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid var(--card-border) !important;
    border-radius: 10px;
    color: var(--text-primary) !important;
    font-size: 0.85rem;
}

.mils-page-chat .dash-input-element::placeholder {
    color: var(--text-secondary) !important;
}

.mils-page-chat .dash-input-element:focus {
    border-color: var(--accent) !important;
    outline: none;
    box-shadow: 0 0 8px rgba(31, 255, 185, 0.18);
}

/* Overlay */
.mils-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1055;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-smooth);
}

.mils-overlay.visible {
    opacity: 1;
    pointer-events: auto;
}
