/* ── Milo Widget ─────────────────────────────────────── */

:root {
    --milo-primary: #00A7E1;
    --milo-primary-dark: #0088b8;
    --milo-bg: #ffffff;
    --milo-chat-bg: #f5f7fa;
    --milo-text: #1a1a2e;
    --milo-text-light: #6b7280;
    --milo-radius: 16px;
    --milo-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* ── Container ── */

.epai-milo {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
}

.epai-milo--visible {
    opacity: 1;
    transform: translateY(0);
}

/* ── FAB (floating action button) ── */

.epai-milo__fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--milo-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--milo-shadow);
    transition: transform 0.2s, background 0.2s;
    margin-left: auto;
}

.epai-milo__fab:hover {
    transform: scale(1.08);
    background: var(--milo-primary-dark);
}

.epai-milo--open .epai-milo__fab {
    display: none;
}

/* ── Panel ── */

.epai-milo__panel {
    display: none;
    width: 380px;
    max-height: 520px;
    background: var(--milo-bg);
    border-radius: var(--milo-radius);
    box-shadow: var(--milo-shadow);
    overflow: hidden;
    flex-direction: column;
}

.epai-milo--open .epai-milo__panel {
    display: flex;
}

/* ── Header ── */

.epai-milo__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: var(--milo-primary);
    color: white;
}

.epai-milo__header-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
}

.epai-milo__avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 16px;
}

.epai-milo__close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
    opacity: 0.8;
}

.epai-milo__close:hover {
    opacity: 1;
}

/* ── Chat area ── */

.epai-milo__chat {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--milo-chat-bg);
    min-height: 200px;
    max-height: 340px;
}

/* ── Messages ── */

.epai-milo__msg {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 14px;
    margin-bottom: 10px;
    word-wrap: break-word;
    animation: epai-fadeIn 0.3s ease;
}

.epai-milo__msg--milo {
    background: white;
    color: var(--milo-text);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.epai-milo__msg--user {
    background: var(--milo-primary);
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

@keyframes epai-fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Input area ── */

.epai-milo__input-area {
    padding: 12px 16px;
    border-top: 1px solid #e5e7eb;
    background: white;
}

.epai-milo__input-wrap {
    display: flex;
    gap: 8px;
}

.epai-milo__text-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d1d5db;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.epai-milo__text-input:focus {
    border-color: var(--milo-primary);
}

.epai-milo__send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: var(--milo-primary);
    color: white;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.epai-milo__send:hover {
    background: var(--milo-primary-dark);
}

/* ── Buttons ── */

.epai-milo__buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.epai-milo__btn {
    padding: 8px 18px;
    border: 2px solid var(--milo-primary);
    border-radius: 24px;
    background: white;
    color: var(--milo-primary);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.epai-milo__btn:hover {
    background: var(--milo-primary);
    color: white;
}

/* ── Upload ── */

.epai-milo__upload-wrap {
    margin-top: 8px;
}

.epai-milo__upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    background: white;
    color: var(--milo-text-light);
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.epai-milo__upload-btn:hover {
    border-color: var(--milo-primary);
    color: var(--milo-primary);
}

/* ── Logo preview ── */

.epai-milo__logo-preview {
    text-align: center;
    padding: 12px;
    animation: epai-fadeIn 0.4s ease;
}

.epai-milo__logo-preview img {
    max-width: 160px;
    max-height: 120px;
    object-fit: contain;
    border-radius: 8px;
    background: #f0f0f0;
    padding: 8px;
}

/* ── Candidates ── */

.epai-milo__candidates {
    margin-top: 8px;
}

.epai-milo__candidates-label {
    font-size: 12px;
    color: var(--milo-text-light);
    margin-bottom: 6px;
}

.epai-milo__candidate-thumb {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 6px;
    border: 2px solid transparent;
    cursor: pointer;
    margin-right: 6px;
    background: #f0f0f0;
    padding: 4px;
    transition: border-color 0.2s;
}

.epai-milo__candidate-thumb:hover {
    border-color: var(--milo-primary);
}

/* ── Brand summary ── */

.epai-milo__brand-summary {
    text-align: center;
    padding: 16px;
    background: white;
    border-radius: 12px;
    margin-bottom: 10px;
    animation: epai-fadeIn 0.4s ease;
}

.epai-milo__brand-logo img {
    max-width: 140px;
    max-height: 80px;
    object-fit: contain;
}

.epai-milo__brand-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--milo-text);
    margin: 8px 0;
}

.epai-milo__palette {
    display: flex;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.epai-milo__swatch {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    cursor: help;
}

/* ── Spinner ── */

.epai-milo__spinner {
    display: flex;
    padding: 10px 14px;
    animation: epai-fadeIn 0.3s ease;
}

.epai-milo__spinner-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--milo-primary);
    animation: epai-pulse 1.2s infinite ease-in-out;
}

@keyframes epai-pulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.2); }
}

/* ── Brand match badge on catalog ── */

.epai-brand-badge {
    display: inline-block;
    padding: 3px 10px;
    background: var(--milo-primary);
    color: white;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    position: absolute;
    top: 8px;
    left: 8px;
    z-index: 5;
}

.epai-brand-match {
    outline: 2px solid var(--milo-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ── Mobile responsive ── */

@media (max-width: 480px) {
    .epai-milo {
        bottom: 12px;
        right: 12px;
        left: 12px;
    }

    .epai-milo__panel {
        width: 100%;
        max-height: 70vh;
    }

    .epai-milo__fab {
        width: 48px;
        height: 48px;
    }
}
