/* ==========================================================================
   Casual Interview Chatbot Styles
   プレフィックス "cic-" でテーマのCSSと衝突しないよう設計
   ========================================================================== */

#cic-chatbot-root {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue",
        "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo,
        sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #1e293b;
}

#cic-chatbot-root,
#cic-chatbot-root *,
#cic-chatbot-root *::before,
#cic-chatbot-root *::after {
    box-sizing: border-box;
}

/* hidden ユーティリティ — テーマのCSSリセットに負けないよう !important 付き */
#cic-chatbot-root .cic-hidden {
    display: none !important;
}

/* Launcher button */
.cic-launcher {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    position: relative;
    /* 右寄せのために flex-direction を row のまま使用 */
}

.cic-launcher:focus-visible {
    outline: none;
}
.cic-launcher:focus-visible .cic-launcher-circle {
    outline: 3px solid #D4919F;
    outline-offset: 2px;
}

.cic-launcher svg {
    pointer-events: none;
}

/* ラベル（ホバー時に左にスライドアウト） */
.cic-launcher-label {
    background: #A82B43;
    color: #fff;
    overflow: hidden;
    max-width: 0;
    opacity: 0;
    padding: 0;
    height: 64px;
    border-radius: 32px 0 0 32px;
    margin-right: -50px;
    transition: max-width 0.35s ease, padding 0.35s ease, opacity 0.25s ease;
    font-family: inherit;
    display: flex;
    align-items: center;
    white-space: nowrap;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.4;
    text-align: center;
}

/* 円の中のテキスト「求職者はこちら」— 常時表示 */
.cic-launcher-circle-text {
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    letter-spacing: 0.02em;
}

/* 丸ボタン */
.cic-launcher-circle {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: #A82B43;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
    border: 3px solid #A82B43;
    box-shadow: 0 4px 16px rgba(168, 43, 67, 0.35);
    transition: background 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* デスクトップのみホバー */
@media (hover: hover) and (pointer: fine) {
    .cic-launcher:hover .cic-launcher-label {
        max-width: 260px;
        padding: 0 60px 0 28px;
        opacity: 1;
    }
    .cic-launcher:hover .cic-launcher-circle {
        background: #fff;
        color: #A82B43;
        border-color: #A82B43;
    }
}

/* Window */
.cic-window {
    position: fixed;
    bottom: 120px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.22);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    animation: cic-window-in 0.25s ease-out;
}

@keyframes cic-window-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Header */
.cic-header {
    background: #A82B43;
    color: #fff;
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    flex-shrink: 0;
}

.cic-title {
    font-size: 16px;
    font-weight: 700;
    margin: 0 0 2px;
    color: #fff;
    line-height: 1.3;
}

.cic-subtitle {
    font-size: 12px;
    opacity: 0.9;
    margin: 0;
    color: #fff;
    line-height: 1.3;
}

.cic-close {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    padding: 0;
    width: 28px;
    height: 28px;
    border-radius: 4px;
    flex-shrink: 0;
    opacity: 0.85;
}

.cic-close:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.15);
}

.cic-close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* Messages area */
.cic-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

.cic-messages::-webkit-scrollbar {
    width: 6px;
}
.cic-messages::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}
.cic-messages::-webkit-scrollbar-track {
    background: transparent;
}

.cic-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
    animation: cic-fade-in 0.3s ease-out;
    line-height: 1.5;
}

@keyframes cic-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.cic-message-bot {
    align-self: flex-start;
    background: #fff;
    color: #1e293b;
    border-top-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

.cic-message-user {
    align-self: flex-end;
    background: #A82B43;
    color: #fff;
    border-top-right-radius: 4px;
}

.cic-typing {
    align-self: flex-start;
    background: #fff;
    color: #94a3b8;
    padding: 8px 14px;
    border-radius: 16px;
    font-size: 12px;
    font-style: italic;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    animation: cic-fade-in 0.2s ease-out;
}

/* Input area */
.cic-input-area {
    padding: 12px;
    border-top: 1px solid #e2e8f0;
    background: #fff;
    flex-shrink: 0;
}

.cic-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cic-option-btn {
    background: #fff;
    border: 2px solid #A82B43;
    color: #A82B43;
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.cic-option-btn:hover {
    background: #A82B43;
    color: #fff;
}

.cic-option-btn:focus-visible {
    outline: 2px solid #D4919F;
    outline-offset: 2px;
}

.cic-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.cic-input {
    flex: 1;
    background: #f1f5f9;
    border: none;
    border-radius: 999px;
    padding: 10px 16px;
    font-size: 14px;
    outline: none;
    color: #1e293b;
    font-family: inherit;
    min-width: 0;
    height: 40px;
}

.cic-input:focus {
    box-shadow: 0 0 0 2px #A82B43;
    background: #fff;
}

.cic-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.cic-send {
    background: #A82B43;
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: background 0.2s ease;
}

.cic-send:hover {
    background: #8A2337;
}

.cic-send:focus-visible {
    outline: 2px solid #D4919F;
    outline-offset: 2px;
}

.cic-send:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

.cic-send svg {
    pointer-events: none;
}

/* Mobile */
@media (max-width: 480px) {
    #cic-chatbot-root {
        right: 12px;
        bottom: 12px;
    }
    .cic-window {
        right: 12px;
        bottom: 100px;
        width: calc(100vw - 24px);
        height: calc(100vh - 120px);
        max-height: calc(100vh - 120px);
    }
    .cic-launcher-circle {
        width: 80px;
        height: 80px;
    }
    .cic-launcher-circle svg {
        width: 30px;
        height: 30px;
    }
    /* モバイルではラベルのみ非表示（円内テキストは表示） */
    .cic-launcher-label {
        display: none !important;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .cic-window,
    .cic-message,
    .cic-typing {
        animation: none;
    }
    .cic-launcher-label,
    .cic-launcher-circle {
        transition: none;
    }
}
