/* 
 * D-dan フロントエンドスタイル
 * チャットUIのスタイル定義
 */

:root {
    --ddan-primary: #2c3e50;
    --ddan-primary-light: #4b6cb7;
    --ddan-accent: #d4a017;
    --ddan-dan-kun: #6b5b95;
    --ddan-dan-san: #e8a0bf;
    --ddan-text: #333333;
    --ddan-text-sub: #666666;
    --ddan-bg: rgba(255, 255, 255, 0.85);
    --ddan-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.15);
}

/* チャットコンテナ */
.ddan-chat-container {
    font-family: 'Noto Sans JP', sans-serif;
    background: var(--ddan-bg);
    backdrop-filter: blur(16px);
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    box-shadow: var(--ddan-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: 700px;
    max-width: 900px;
    margin: 0 auto;
}

/* ヘッダー */
.ddan-header {
    padding: 1rem 1.5rem;
    background: rgba(255, 255, 255, 0.9);
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.ddan-char-selector {
    display: flex;
    gap: 0.5rem;
    background: #f0f0f0;
    padding: 5px;
    border-radius: 50px;
}

.ddan-char-btn {
    padding: 8px 16px;
    border-radius: 50px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-family: 'Zen Maru Gothic', sans-serif;
    font-weight: bold;
    color: #888;
    transition: all 0.3s;
    font-size: 0.9rem;
}

.ddan-char-btn.active {
    background: white;
    color: var(--ddan-primary);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* アバターエリア */
.ddan-avatar-area {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    padding: 1.5rem;
    background: linear-gradient(180deg, rgba(240,245,255,0.9) 0%, rgba(255,255,255,0.7) 100%);
    border-bottom: 1px solid rgba(0,0,0,0.05);
    min-height: 180px;
    position: relative;
}

.ddan-character-container {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.ddan-avatar-svg {
    width: 120px;
    height: 140px;
    transition: all 0.3s ease;
}

.ddan-avatar-svg.hidden { display: none; }

.ddan-avatar-name {
    font-family: 'Zen Maru Gothic', sans-serif;
    font-weight: bold;
    font-size: 1.1rem;
    margin-top: 0.5rem;
    text-align: center;
}

.ddan-avatar-name.dan-kun { color: var(--ddan-dan-kun); }
.ddan-avatar-name.dan-san { color: var(--ddan-dan-san); }

.ddan-speech-bubble {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    padding: 10px 18px;
    border-radius: 20px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    font-size: 0.85rem;
    max-width: 280px;
    text-align: center;
    opacity: 0;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 10;
}

.ddan-speech-bubble.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(-5px);
}

.ddan-speech-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 10px solid white;
}

/* アニメーション */
@keyframes ddan-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes ddan-talking {
    0%, 100% { transform: scale(1) translateY(0); }
    25% { transform: scale(1.02) translateY(-3px); }
    50% { transform: scale(1) translateY(0); }
    75% { transform: scale(1.02) translateY(-3px); }
}

@keyframes ddan-wing-flap {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-5deg); }
}

.ddan-avatar-svg.idle { animation: ddan-float 3s ease-in-out infinite; }
.ddan-avatar-svg.talking { animation: ddan-talking 0.6s ease-in-out infinite; }
.ddan-wing-left { transform-origin: right center; animation: ddan-wing-flap 0.8s ease-in-out infinite; }
.ddan-wing-right { transform-origin: left center; animation: ddan-wing-flap 0.8s ease-in-out infinite reverse; }

/* メッセージエリア */
.ddan-messages {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.3);
}

.ddan-message {
    max-width: 85%;
    padding: 1rem 1.5rem;
    border-radius: 15px;
    position: relative;
    animation: ddan-pop-in 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes ddan-pop-in {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}

.ddan-message.ai {
    align-self: flex-start;
    background: white;
    border-bottom-left-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
}

.ddan-message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, var(--ddan-primary), var(--ddan-primary-light));
    color: white;
    border-bottom-right-radius: 5px;
    box-shadow: 0 2px 8px rgba(44, 62, 80, 0.2);
}

.ddan-message-content { font-size: 0.95rem; white-space: pre-wrap; }
.ddan-message-time { font-size: 0.7rem; margin-top: 5px; opacity: 0.7; text-align: right; }
.ddan-message.user .ddan-message-time { color: rgba(255, 255, 255, 0.8); }

/* 入力エリア */
.ddan-input-area {
    padding: 1.5rem;
    background: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-top: 1px solid rgba(0, 0, 0, 0.05);
}

.ddan-input-area textarea {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid #ddd;
    resize: none;
    height: 50px;
    font-family: 'Noto Sans JP', sans-serif;
    transition: border 0.3s;
    font-size: 1rem;
}

.ddan-input-area textarea:focus {
    outline: none;
    border-color: var(--ddan-primary-light);
}

.ddan-voice-btn,
.ddan-send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.ddan-voice-btn {
    background: #f0f0f0;
    color: #666;
}

.ddan-voice-btn:hover { background: #e0e0e0; }
.ddan-voice-btn.recording { background: #ff4444; color: white; animation: ddan-pulse 1s infinite; }

@keyframes ddan-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.ddan-send-btn { background: var(--ddan-primary); color: white; }
.ddan-send-btn:hover { background: var(--ddan-primary-light); transform: scale(1.1); }
.ddan-send-btn:disabled { background: #ccc; cursor: not-allowed; transform: none; }

/* エラーバナー */
.ddan-error-banner {
    background: #fff3cd;
    border: 1px solid #ffc107;
    color: #856404;
    padding: 10px 15px;
    margin: 0 1.5rem 1rem;
    border-radius: 8px;
    font-size: 0.9rem;
    display: none;
}

.ddan-error-banner.visible { display: block; }

/* レスポンシブ */
@media (max-width: 768px) {
    .ddan-chat-container { height: 85vh; }
    .ddan-avatar-area { min-height: 140px; padding: 1rem; }
    .ddan-avatar-svg { width: 90px; height: 105px; }
    .ddan-header { flex-direction: column; gap: 0.75rem; }
}
