/**
 * 採用チャットボット UI
 * 税理士法人松本 採用サイトのデザインに準拠
 *
 * カラー:
 *   オレンジ    #E85810
 *   テキスト    #231D15
 *   ゴールド    #C0943E
 *   グレー背景  #F9F9F9
 *   グレーボーダー #EEEBE7
 *   ホワイト    #FFFFFF
 *   グラデーション linear-gradient(to right, #85231D, #BA321B, #E95810, #EF7009, #D5650C)
 *
 * フォント: "Noto Sans JP", sans-serif
 */

/* ========================================
   Reset / Base
   ======================================== */
.rcb-chatbot,
.rcb-chatbot *,
.rcb-chatbot *::before,
.rcb-chatbot *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

.rcb-chatbot {
    font-family: "Noto Sans JP", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: #231D15;
    z-index: 40; /* above .o-fixed (z-index:20) */
    -webkit-font-smoothing: antialiased;
}

body.rcb-chatbot-open {
    overflow: hidden;
    touch-action: none;
}

.rcb-overlay {
    position: fixed;
    inset: 0;
    display: none;
    background: rgba(35, 29, 21, 0.32);
    backdrop-filter: blur(2px);
    z-index: 41;
}

/* ========================================
   Floating Toggle Button
   ======================================== */
.rcb-toggle {
    position: fixed;
    bottom: 88px; /* clear .o-fixed on mobile */
    right: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 40px;
    background: linear-gradient(to right, #85231D, #BA321B, #E95810, #EF7009, #D5650C);
    color: #fff;
    font-family: "Noto Sans JP", sans-serif;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    z-index: 43;
}

@media (min-width: 768px) {
    .rcb-toggle {
        bottom: 24px;
        right: 24px;
        padding: 14px 24px;
        font-size: 15px;
    }
}

.rcb-toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
    opacity: 1;
}

.rcb-toggle:focus-visible {
    outline: 3px solid #E85810;
    outline-offset: 2px;
}

.rcb-toggle__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
}

.rcb-toggle__label {
    white-space: nowrap;
}

/* ========================================
   Chat Window
   ======================================== */
.rcb-window {
    position: fixed;
    bottom: 88px;
    right: 16px;
    width: calc(100vw - 32px);
    max-width: 400px;
    height: 520px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 42;
    animation: rcb-slide-up 0.3s ease;
}

@media (min-width: 768px) {
    .rcb-window {
        bottom: 90px;
        right: 24px;
        width: 400px;
        height: 560px;
        max-height: calc(100vh - 120px);
    }
}

@media (max-width: 767px) {
    .rcb-window {
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        max-width: none;
        height: min(78dvh, 680px);
        max-height: calc(100dvh - 8px);
        border-radius: 20px 20px 0 0;
        animation: rcb-sheet-up 0.3s ease;
    }

    .rcb-window__messages {
        padding: 16px 16px 20px;
    }

    .rcb-window__input-area {
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    }

    .rcb-chatbot.is-open .rcb-toggle {
        opacity: 0;
        pointer-events: none;
        transform: translateY(12px);
    }
}

/* Inline variant */
.rcb-window--inline {
    position: static;
    width: 100%;
    max-width: 100%;
    height: 480px;
    max-height: none;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    animation: none;
}

@keyframes rcb-slide-up {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes rcb-sheet-up {
    from {
        opacity: 0;
        transform: translateY(28px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ========================================
   Header
   ======================================== */
.rcb-window__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: linear-gradient(to right, #85231D, #BA321B, #E95810, #EF7009, #D5650C);
    color: #fff;
    flex-shrink: 0;
}

.rcb-window__header-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.rcb-window__header-icon {
    display: flex;
    align-items: center;
    opacity: 0.9;
}

.rcb-window__header-title {
    font-size: 14px;
    font-weight: bold;
    letter-spacing: 0.02em;
}

.rcb-window__header-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

.rcb-window__btn-reset,
.rcb-window__btn-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    cursor: pointer;
    transition: background 0.2s;
}

.rcb-window__btn-reset:hover,
.rcb-window__btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
    opacity: 1;
}

/* ========================================
   AI Notice
   ======================================== */
.rcb-window__notice {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    padding: 8px 16px;
    background: #FFF8F0;
    border-bottom: 1px solid #EEEBE7;
    font-size: 11px;
    color: #8B7355;
    flex-shrink: 0;
    line-height: 1.5;
}

.rcb-window__notice svg {
    flex-shrink: 0;
    margin-top: 1px;
    color: #C0943E;
}

/* ========================================
   Messages Area
   ======================================== */
.rcb-window__messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
    background: #F9F9F9;
}

.rcb-window__messages::-webkit-scrollbar {
    width: 4px;
}

.rcb-window__messages::-webkit-scrollbar-track {
    background: transparent;
}

.rcb-window__messages::-webkit-scrollbar-thumb {
    background: #EEEBE7;
    border-radius: 2px;
}

/* Message bubble — bot */
.rcb-msg {
    display: flex;
    flex-direction: column;
    max-width: 88%;
    animation: rcb-fade-in 0.3s ease;
}

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

.rcb-msg--bot {
    align-self: flex-start;
}

.rcb-msg--user {
    align-self: flex-end;
}

.rcb-msg__bubble {
    padding: 12px 16px;
    border-radius: 16px;
    word-break: break-word;
}

.rcb-msg--bot .rcb-msg__bubble {
    background: #fff;
    border: 1px solid #EEEBE7;
    border-radius: 4px 16px 16px 16px;
}

.rcb-msg--user .rcb-msg__bubble {
    background: #E85810;
    color: #fff;
    border-radius: 16px 4px 16px 16px;
}

.rcb-msg--user .rcb-msg__bubble a {
    color: #fff;
    text-decoration: underline;
}

.rcb-msg__bubble p {
    margin: 0 0 4px;
}

.rcb-msg__bubble p:last-child {
    margin-bottom: 0;
}

.rcb-msg__bubble strong {
    font-weight: bold;
    color: #E85810;
}

.rcb-msg--user .rcb-msg__bubble strong {
    color: #fff;
}

/* Related links */
.rcb-msg__links {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.rcb-msg__link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    background: #F9F9F9;
    border: 1px solid #EEEBE7;
    border-radius: 8px;
    font-size: 12px;
    color: #E85810;
    text-decoration: none;
    transition: background 0.2s, border-color 0.2s;
}

.rcb-msg__link:hover {
    background: #FFF3ED;
    border-color: #E85810;
    opacity: 1;
    text-decoration: none;
}

.rcb-msg__link::before {
    content: "→";
    font-size: 10px;
}

/* CTA button */
.rcb-msg__cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-top: 10px;
    padding: 10px 20px;
    border: none;
    border-radius: 40px;
    background: linear-gradient(to right, #85231D, #BA321B, #E95810, #EF7009, #D5650C);
    color: #fff;
    font-family: "Noto Sans JP", sans-serif;
    font-size: 13px;
    font-weight: bold;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.rcb-msg__cta:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(232, 88, 16, 0.3);
    opacity: 1;
    color: #fff;
    text-decoration: none;
}

.rcb-msg__cta::after {
    content: "→";
    font-size: 12px;
}

/* Feedback buttons */
.rcb-msg__feedback {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #EEEBE7;
}

.rcb-msg__feedback-label {
    font-size: 11px;
    color: #8B7355;
}

.rcb-msg__feedback-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid #EEEBE7;
    border-radius: 50%;
    background: #fff;
    color: #8B7355;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.rcb-msg__feedback-btn:hover {
    border-color: #E85810;
    color: #E85810;
    opacity: 1;
}

.rcb-msg__feedback-btn.is-selected {
    background: #E85810;
    border-color: #E85810;
    color: #fff;
}

.rcb-msg__feedback-btn[disabled] {
    cursor: default;
    opacity: 0.5;
}

/* Loading dots */
.rcb-msg__loading {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.rcb-msg__loading-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #EEEBE7;
    animation: rcb-dot-pulse 1.4s infinite ease-in-out;
}

.rcb-msg__loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.rcb-msg__loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes rcb-dot-pulse {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
        background: #E85810;
    }
}

/* ========================================
   Quick Replies
   ======================================== */
.rcb-window__quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px;
    background: #F9F9F9;
    border-top: 1px solid #EEEBE7;
    flex-shrink: 0;
}

.rcb-window__quick-replies:empty {
    display: none;
}

.rcb-quick-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border: 1px solid #E85810;
    border-radius: 20px;
    background: #fff;
    color: #E85810;
    font-family: "Noto Sans JP", sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.rcb-quick-chip:hover {
    background: #E85810;
    color: #fff;
    opacity: 1;
}

/* ========================================
   Input Area
   ======================================== */
.rcb-window__input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #EEEBE7;
    flex-shrink: 0;
}

.rcb-window__input {
    flex: 1;
    min-height: 40px;
    max-height: 96px;
    padding: 10px 14px;
    border: 1px solid #EEEBE7;
    border-radius: 12px;
    background: #F9F9F9;
    font-family: "Noto Sans JP", sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: #231D15;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.rcb-window__input:focus {
    border-color: #E85810;
    background: #fff;
}

.rcb-window__input::placeholder {
    color: #a5a5a5;
}

.rcb-window__send {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: #E85810;
    color: #fff;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    flex-shrink: 0;
}

.rcb-window__send:hover:not([disabled]) {
    background: #BA321B;
    transform: scale(1.05);
    opacity: 1;
}

.rcb-window__send[disabled] {
    background: #EEEBE7;
    color: #a5a5a5;
    cursor: default;
}

/* ========================================
   Inline variant overrides
   ======================================== */
.rcb-chatbot--inline {
    position: static;
    z-index: auto;
    margin: 24px 0;
}

.rcb-chatbot--inline .rcb-toggle {
    display: none;
}

.rcb-chatbot--inline .rcb-window--inline {
    display: flex !important;
}

/* ========================================
   Accessibility
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .rcb-chatbot,
    .rcb-chatbot * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast */
@media (forced-colors: active) {
    .rcb-msg__bubble {
        border: 1px solid;
    }
    .rcb-toggle,
    .rcb-msg__cta,
    .rcb-window__send {
        border: 1px solid;
    }
}
