/* ================================================================
   home-assistant.css — Bot Assistente Homepage Melacompro
   Prefisso: .mc-bot-
   z-index: bubble 9990, panel 9991
   Caricato solo in homepage (tramite display_header.tpl)
   ================================================================ */

/* ── Root container ──────────────────────────────────────────── */
.mc-bot-root {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9990;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.4;
}

.mc-bot-root * { box-sizing: border-box; margin: 0; padding: 0; }

/* Start hidden, JS shows after delay */
.mc-bot-root[hidden] { display: none; }

/* ── Bubble ──────────────────────────────────────────────────── */
.mc-bot-bubble {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a1a2e, #0f3460);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    position: relative;
    transition: transform 0.15s, box-shadow 0.15s;
}

.mc-bot-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.4);
}

.mc-bot-bubble:active { transform: scale(0.95); }

.mc-bot-bubble__icon {
    font-size: 24px;
    line-height: 1;
    transition: transform 0.2s;
}

/* Pulse ring on first appear */
.mc-bot-bubble__pulse {
    position: absolute;
    top: -4px; left: -4px; right: -4px; bottom: -4px;
    border-radius: 50%;
    border: 2px solid rgba(15, 52, 96, 0.4);
    animation: mc-bot-pulse 2s ease-out 3;
    pointer-events: none;
}

@keyframes mc-bot-pulse {
    0%   { transform: scale(1);   opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* When open: bubble becomes close button */
.mc-bot--open .mc-bot-bubble__icon { transform: rotate(90deg); }
.mc-bot--open .mc-bot-bubble__pulse { display: none; }

/* ── Panel ───────────────────────────────────────────────────── */
.mc-bot-panel {
    position: absolute;
    bottom: calc(100% + 12px);
    right: 0;
    width: 340px;
    max-height: 480px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: mc-bot-slide-up 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    z-index: 9991;
}

.mc-bot-panel[hidden] { display: none !important; }

@keyframes mc-bot-slide-up {
    from { transform: translateY(16px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* Panel header */
.mc-bot-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #1a1a2e, #0f3460);
    color: #fff;
    flex-shrink: 0;
}

.mc-bot-panel__title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.mc-bot-panel__close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}
.mc-bot-panel__close:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }

/* ── Messages area ───────────────────────────────────────────── */
.mc-bot-panel__messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px 14px 8px;
    min-height: 0;
}

/* Message bubble */
.mc-bot-msg {
    margin-bottom: 10px;
    max-width: 90%;
    animation: mc-bot-msg-in 0.2s ease;
}

@keyframes mc-bot-msg-in {
    from { transform: translateY(8px); opacity: 0; }
    to   { transform: translateY(0);   opacity: 1; }
}

/* Bot message: left-aligned, light bg */
.mc-bot-msg--bot { margin-right: auto; }

.mc-bot-msg__text {
    background: #f2f2f2;
    color: #222;
    border-radius: 14px 14px 14px 4px;
    padding: 10px 14px;
    font-size: 13px;
    line-height: 1.5;
}

/* User message: right-aligned, dark bg */
.mc-bot-msg--user { margin-left: auto; }

.mc-bot-msg--user .mc-bot-msg__text {
    background: #1a1a2e;
    color: #fff;
    border-radius: 14px 14px 4px 14px;
}

/* Typing indicator */
.mc-bot-typing .mc-bot-msg__text {
    display: flex;
    gap: 5px;
    padding: 12px 18px;
}

.mc-bot-typing__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #aaa;
    animation: mc-bot-dot 1.2s ease infinite;
}
.mc-bot-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.mc-bot-typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes mc-bot-dot {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-4px); }
}

/* ── Actions area ────────────────────────────────────────────── */
.mc-bot-panel__actions {
    padding: 10px 14px 14px;
    flex-shrink: 0;
}

.mc-bot-panel__actions:empty { display: none; }

/* Quick reply buttons */
.mc-bot-action-btn {
    display: block;
    width: 100%;
    padding: 10px 16px;
    margin-bottom: 6px;
    background: #fff;
    border: 1.5px solid #e0e0e0;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: #1a1a2e;
    text-align: left;
    transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.mc-bot-action-btn:last-child { margin-bottom: 0; }

.mc-bot-action-btn:hover {
    background: #f0f4ff;
    border-color: #0f3460;
}

.mc-bot-action-btn:active { transform: scale(0.98); }

.mc-bot-action-btn--primary {
    background: #1a1a2e;
    color: #fff;
    border-color: #1a1a2e;
}
.mc-bot-action-btn--primary:hover {
    background: #0f3460;
    border-color: #0f3460;
}

/* ── Search input inside actions ─────────────────────────────── */
.mc-bot-search-wrap { margin-bottom: 6px; }

.mc-bot-search-input {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1.5px solid #ddd;
    border-radius: 12px;
    outline: none;
    background: #f9f9f9;
    transition: border-color 0.15s, background 0.15s;
    -webkit-appearance: none;
    font-family: inherit;
}

.mc-bot-search-input:focus {
    border-color: #0f3460;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(15, 52, 96, 0.1);
}

/* Suggestions dropdown */
.mc-bot-suggestions {
    list-style: none;
    margin: 4px 0 0;
    padding: 4px 0;
    background: #fff;
    border: 1.5px solid #e0e0e0;
    border-radius: 10px;
    max-height: 160px;
    overflow-y: auto;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.mc-bot-suggestions[hidden] { display: none; }

.mc-bot-sug-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 9px 14px;
    cursor: pointer;
    font-size: 13px;
    color: #222;
    transition: background 0.1s;
    border-bottom: 1px solid #f5f5f5;
}

.mc-bot-sug-item:last-child { border-bottom: none; }
.mc-bot-sug-item:hover { background: #f0f4ff; }
.mc-bot-sug-item mark { background: transparent; color: #0f3460; font-weight: 700; }

.mc-bot-sug-year {
    font-size: 11px;
    color: #aaa;
    flex-shrink: 0;
    margin-left: 8px;
}

/* ── Help text ───────────────────────────────────────────────── */
.mc-bot-help-block {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 8px;
}

.mc-bot-help-block h4 {
    font-size: 12px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.mc-bot-help-steps {
    font-size: 12px;
    color: #555;
    line-height: 1.7;
    padding-left: 16px;
    margin: 0;
}

.mc-bot-help-steps strong { color: #1a1a2e; }

/* ── Mobile responsive ───────────────────────────────────────── */
@media (max-width: 480px) {
    .mc-bot-root { bottom: 16px; right: 16px; }
    .mc-bot-bubble { width: 50px; height: 50px; }
    .mc-bot-bubble__icon { font-size: 20px; }

    .mc-bot-panel {
        width: calc(100vw - 32px);
        max-height: 60vh;
        right: -8px;
    }
}

/* ── Reduce motion ───────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .mc-bot-panel,
    .mc-bot-msg,
    .mc-bot-bubble__pulse,
    .mc-bot-typing__dot {
        animation: none !important;
    }
}
