/* ============================================
   Koharu AI Chat - UI Styles
   ============================================ */

.koharu-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #d4a5a5 0%, #c98b8b 100%);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
    cursor: pointer;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 26px;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    line-height: 1;
}
.koharu-chat-bubble:hover {
    transform: scale(1.06);
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.25);
}

.koharu-chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 360px;
    max-width: calc(100vw - 32px);
    height: 520px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.22);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}
.koharu-chat-window.koharu-open {
    display: flex;
    animation: koharuFadeIn 0.25s ease;
}
@keyframes koharuFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.koharu-chat-header {
    padding: 14px 18px;
    background: linear-gradient(135deg, #d4a5a5 0%, #c98b8b 100%);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.koharu-chat-header-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}
.koharu-chat-header-sub {
    font-size: 11px;
    opacity: 0.85;
    margin-top: 2px;
}
.koharu-chat-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.koharu-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #faf7f5;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.koharu-msg {
    max-width: 80%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: pre-wrap;
}
.koharu-msg-user {
    align-self: flex-end;
    background: #d4a5a5;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.koharu-msg-assistant {
    align-self: flex-start;
    background: #fff;
    color: #333;
    border: 1px solid #ebe0db;
    border-bottom-left-radius: 4px;
}
.koharu-msg-error {
    align-self: center;
    background: #fff5f5;
    color: #c62828;
    border: 1px solid #f8c4c4;
    font-size: 13px;
}

.koharu-typing {
    align-self: flex-start;
    display: flex;
    gap: 4px;
    padding: 12px 14px;
    background: #fff;
    border: 1px solid #ebe0db;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.koharu-typing span {
    width: 6px;
    height: 6px;
    background: #c98b8b;
    border-radius: 50%;
    animation: koharuBounce 1.2s infinite;
}
.koharu-typing span:nth-child(2) { animation-delay: 0.15s; }
.koharu-typing span:nth-child(3) { animation-delay: 0.30s; }
@keyframes koharuBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30%           { transform: translateY(-5px); opacity: 1; }
}

.koharu-chat-footer {
    padding: 10px 12px;
    border-top: 1px solid #ebe0db;
    background: #fff;
}
.koharu-chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.koharu-chat-input {
    flex: 1;
    border: 1px solid #d4c5bf;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 14px;
    resize: none;
    max-height: 100px;
    min-height: 38px;
    font-family: inherit;
    line-height: 1.4;
    outline: none;
    color: #333;
    background: #fff;
}
.koharu-chat-input:focus {
    border-color: #c98b8b;
}
.koharu-chat-send {
    background: #c98b8b;
    color: #fff;
    border: none;
    border-radius: 10px;
    width: 40px;
    height: 38px;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
}
.koharu-chat-send:hover { background: #b87575; }
.koharu-chat-send:disabled { background: #ddd; cursor: not-allowed; }

.koharu-chat-meta {
    margin-top: 6px;
    font-size: 11px;
    color: #999;
    display: flex;
    justify-content: space-between;
}
.koharu-char-count.koharu-near-limit { color: #c98b8b; }
.koharu-char-count.koharu-over-limit { color: #c62828; }

/* インライン版 (ショートコード) */
.koharu-ai-chat-inline .koharu-chat-window {
    position: relative;
    bottom: auto;
    right: auto;
    width: 100%;
    max-width: 600px;
    height: 500px;
    margin: 20px auto;
    display: flex;
}
.koharu-ai-chat-inline .koharu-chat-bubble,
.koharu-ai-chat-inline .koharu-chat-close { display: none; }

/* スマホ対応 */
@media (max-width: 480px) {
    .koharu-chat-window {
        width: calc(100vw - 24px);
        right: 12px;
        bottom: 88px;
        height: 70vh;
    }
    .koharu-chat-bubble {
        bottom: 16px;
        right: 16px;
    }
}
