/* ===========================
   AIこうた先生 - iframe埋め込み専用CSS
   =========================== */

:root {
    --primary-color: #EF8223;
    --primary-hover: #D6721C;
    --accent-color: #9B7B6C;
    --bg-color: #FAFAFA;
    --text-color: #333;
    --ai-msg-bg: #FFF3E8;
    --user-msg-bg: #6B6B6B;
    --border-color: #E8E8E8;
    --shadow-soft: 0 2px 12px rgba(0, 0, 0, 0.06);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
    background: transparent;
    color: var(--text-color);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* チャットウィンドウ全体 */
.chat-window-embedded {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: var(--shadow-soft);
    border: 1px solid var(--border-color);
}

/* ヘッダーバー */
.chat-header-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: linear-gradient(135deg, #FFF8F2 0%, #FFF 100%);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.chat-header-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    border: 1px solid rgba(0,0,0,0.05);
}

.chat-header-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.chat-header-info {
    display: flex;
    flex-direction: column;
}

.chat-header-name {
    font-weight: 700;
    font-size: 16px;
    color: var(--text-color);
}

.chat-header-status {
    font-size: 12px;
    color: #888;
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4CAF50;
    display: inline-block;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* メッセージエリア */
.chat-body {
    flex-grow: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background-color: var(--bg-color);
    scroll-behavior: smooth;
}

/* スクロールバーカスタマイズ */
.chat-body::-webkit-scrollbar {
    width: 5px;
}
.chat-body::-webkit-scrollbar-track {
    background: transparent;
}
.chat-body::-webkit-scrollbar-thumb {
    background: #D0D0D0;
    border-radius: 10px;
}

/* メッセージ共通 */
.message {
    padding: 14px 18px;
    border-radius: 18px;
    max-width: 80%;
    font-size: 14.5px;
    line-height: 1.85;
    animation: fadeInUp 0.3s ease-out;
    word-break: break-word;
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* AI メッセージ */
.ai-message {
    align-self: flex-start;
    background-color: #fff;
    color: #444;
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

/* ユーザーメッセージ */
.user-message {
    align-self: flex-end;
    background-color: var(--user-msg-bg);
    color: white;
    border-bottom-right-radius: 4px;
}

/* タイピングインジケーター */
.typing {
    color: #999;
    font-style: italic;
}

.typing::after {
    content: '';
    animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

/* 出典エリア */
.source-box {
    margin-top: 12px;
    padding: 10px 14px;
    background: #FFF8F2;
    border-radius: 10px;
    font-size: 12.5px;
    border-left: 3px solid var(--primary-color);
}

.source-box a {
    color: var(--primary-color);
    text-decoration: none;
    display: block;
    margin-top: 4px;
    transition: opacity 0.2s;
}

.source-box a:hover {
    opacity: 0.7;
    text-decoration: underline;
}

/* フォールバックバブル */
.fallback-bubble {
    background: #FFF8F2 !important;
    border: 1px solid #FFD9B3 !important;
}

.fallback-title {
    font-weight: 600;
    margin-bottom: 8px;
    font-size: 14px;
}

.fallback-description {
    font-size: 13px;
    margin-bottom: 14px;
    opacity: 0.85;
    line-height: 1.7;
}

.fallback-buttons {
    display: flex;
    gap: 8px;
}

.deny-btn, .grant-btn {
    flex: 1;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 13.5px;
    font-family: inherit;
    transition: all 0.2s;
}

.deny-btn {
    border: 1px solid #ddd;
    background: white;
    color: #666;
}

.deny-btn:hover {
    background: #f5f5f5;
}

.grant-btn {
    border: none;
    background: var(--primary-color);
    color: white;
    font-weight: 600;
}

.grant-btn:hover {
    background: var(--primary-hover);
    transform: scale(1.02);
}

/* フッター（入力エリア） */
.chat-footer {
    padding: 16px 20px;
    background: #fff;
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

.encryption-notice {
    font-size: 11px;
    color: #aaa;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 5px;
}

.input-wrapper {
    display: flex;
    gap: 10px;
    align-items: flex-end;
}

textarea {
    flex-grow: 1;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 11px 16px;
    resize: none;
    font-family: inherit;
    font-size: 14.5px;
    outline: none;
    background: var(--bg-color);
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 1.5;
    max-height: 120px;
}

textarea:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(239, 130, 35, 0.1);
}

textarea::placeholder {
    color: #bbb;
}

#send-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

#send-btn:hover {
    transform: scale(1.06);
    background-color: var(--primary-hover);
}

#send-btn:active {
    transform: scale(0.96);
}

#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* レスポンシブ */
@media (max-width: 768px) {
    .chat-window-embedded {
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    .chat-header-bar {
        padding: 12px 16px;
    }

    .chat-header-avatar {
        font-size: 28px;
        width: 38px;
        height: 38px;
    }

    .chat-body {
        padding: 16px;
        gap: 12px;
    }

    .message {
        max-width: 88%;
        padding: 12px 15px;
        font-size: 14px;
    }

    .chat-footer {
        padding: 12px 14px;
    }

    textarea {
        font-size: 14px;
        padding: 10px 14px;
    }

    #send-btn {
        width: 42px;
        height: 42px;
    }
}
