/**
 * Machine chatbot — BEM: .machine-chatbot
 * 正本（本番デプロイ対象）: inc/machine-chatbot.php が wp_enqueue_style で読込
 * トークンはメイン app.css :root の変数を優先（未定義時はフォールバック）
 */

.machine-chatbot {
    --mb-accent: var(--color-accent-700, #0f3a79);
    --mb-accent-bright: var(--color-accent-500, #2f5d96);
    --mb-cta-hover: #a07d1e;
    --mb-panel-bg: #1a1a2e;
    --mb-panel-text: rgba(255, 255, 255, 0.85);
    --mb-z-overlay: 200;
    --mb-z-panel: 201;
}

/* FAB */
.machine-chatbot__fab {
    position: fixed;
    bottom: 60px;
    right: 16px;
    z-index: var(--mb-z-overlay);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 50px;
    background: var(--mb-accent);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition:
        transform 0.3s ease,
        opacity 0.3s ease,
        box-shadow 0.3s ease,
        bottom 0.15s ease;
}

.machine-chatbot__fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 28px rgba(0, 0, 0, 0.4);
}

.machine-chatbot__fab.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: scale(0.8);
}

.machine-chatbot__fab.is-fab-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
}

.machine-chatbot__fab.is-fab-entering {
    transition-duration: 0.6s;
}

.machine-chatbot__fab-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

@media (max-width: 479px) {
    .machine-chatbot__fab-label {
        display: none;
    }
}

@media (min-width: 1024px) {
    .machine-chatbot__fab {
        bottom: 32px;
        right: 32px;
    }
}

.machine-chatbot__overlay {
    position: fixed;
    inset: 0;
    z-index: var(--mb-z-overlay);
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.machine-chatbot__overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

@media (min-width: 1024px) {
    .machine-chatbot__overlay {
        background: transparent;
    }
}

.machine-chatbot__panel {
    position: fixed;
    bottom: 0;
    right: 0;
    z-index: var(--mb-z-panel);
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--mb-panel-bg);
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.35s ease, opacity 0.3s ease;
    pointer-events: none;
}

.machine-chatbot__panel.is-open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
}

@media (min-width: 1024px) {
    .machine-chatbot__panel {
        bottom: 24px;
        right: 24px;
        width: 380px;
        height: 540px;
        border-radius: 16px;
        box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
        transform: translateY(20px);
    }

    .machine-chatbot__panel.is-open {
        transform: translateY(0);
    }
}

.machine-chatbot__panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
}

.machine-chatbot__panel-title {
    font-size: 0.875rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.05em;
}

.machine-chatbot__close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s ease;
}

.machine-chatbot__close:hover {
    color: #fff;
}

.machine-chatbot__body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

.machine-chatbot__body::-webkit-scrollbar {
    width: 4px;
}

.machine-chatbot__body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.machine-chatbot__input-row {
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    flex-shrink: 0;
    display: flex;
    gap: 8px;
}

.machine-chatbot__search {
    flex: 1;
    min-width: 0;
    padding: 10px 14px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 0.875rem;
    outline: none;
    transition: border-color 0.2s ease;
    box-sizing: border-box;
    -webkit-appearance: none;
}

.machine-chatbot__search::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

.machine-chatbot__search:focus {
    border-color: var(--mb-accent);
}

.machine-chatbot__submit {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: var(--mb-accent);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.machine-chatbot__submit svg {
    width: 16px;
    height: 16px;
}

.machine-chatbot__submit:hover {
    background: var(--mb-cta-hover);
}

/* メッセージ */
.machine-chatbot__msg {
    margin-bottom: 12px;
    display: flex;
}

.machine-chatbot__msg--bot {
    justify-content: flex-start;
}

.machine-chatbot__msg--user {
    justify-content: flex-end;
}

.machine-chatbot__bubble {
    max-width: 90%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.8125rem;
    line-height: 1.6;
}

.machine-chatbot__msg--bot .machine-chatbot__bubble {
    background: rgba(255, 255, 255, 0.06);
    color: var(--mb-panel-text);
    border-bottom-left-radius: 4px;
}

.machine-chatbot__msg--user .machine-chatbot__bubble {
    background: var(--mb-accent);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.machine-chatbot__makers {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.machine-chatbot__maker-btn {
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    background: transparent;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem;
    cursor: pointer;
    transition:
        background 0.2s ease,
        color 0.2s ease,
        border-color 0.2s ease;
}

.machine-chatbot__maker-btn:hover {
    background: var(--mb-accent);
    color: #fff;
    border-color: var(--mb-accent);
}

.machine-chatbot__models {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
    max-height: 280px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.machine-chatbot__models::-webkit-scrollbar {
    width: 3px;
}

.machine-chatbot__models::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.machine-chatbot__model-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.75rem;
    text-align: left;
    cursor: pointer;
    transition:
        background 0.2s ease,
        border-color 0.2s ease;
}

.machine-chatbot__model-btn:hover {
    background: rgba(15, 58, 121, 0.25);
    border-color: rgba(15, 58, 121, 0.45);
}

.machine-chatbot__model-name {
    font-weight: 700;
}

.machine-chatbot__model-maker {
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.4);
    flex-shrink: 0;
}

.machine-chatbot__hint {
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.35);
    margin-top: 6px;
}

.machine-chatbot__card-maker {
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.4);
    margin-bottom: 2px;
}

.machine-chatbot__card-model {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 10px;
}

.machine-chatbot__card-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 6px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    gap: 8px;
}

.machine-chatbot__card-name {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.7);
}

.machine-chatbot__card-spec {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
    font-family: "Montserrat", sans-serif;
}

.machine-chatbot__card-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 14px;
}

.machine-chatbot__card-cta {
    display: block;
    padding: 10px;
    border-radius: 8px;
    background: var(--mb-accent);
    color: #fff;
    font-size: 0.8125rem;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
    transition: background 0.2s ease;
}

.machine-chatbot__card-cta:hover {
    background: var(--mb-cta-hover);
}

.machine-chatbot__back {
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    background: transparent;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.75rem;
    cursor: pointer;
    text-align: center;
    transition:
        color 0.2s ease,
        border-color 0.2s ease;
}

.machine-chatbot__back:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.machine-chatbot__back--inline {
    display: block;
    width: 100%;
    margin-top: 10px;
}
