/**
 * style.css
 * AI Language Tutor - スタイルシート
 * カラースキーム: 暖色系（コーラルレッド & オレンジ）
 */

/* ==========================================================================
   カラー定義
   ========================================================================== */
:root {
    --color-main: #FF6B6B;          /* メインカラー: コーラルレッド */
    --color-accent: #FFA500;        /* アクセント: オレンジ */
    --color-background: #FFF5E6;    /* 背景: クリーム */
    --color-text: #333333;          /* テキスト: ダークグレー */
    --color-ai-bubble: #FFE4B5;     /* AI吹き出し: モカシン */
    --color-learner-bubble: #FFDAB9; /* 学習者吹き出し: ピーチ */
    --color-white: #FFFFFF;
    --color-shadow: rgba(0, 0, 0, 0.1);
    --color-border: #FFCCAA;
}

/* ==========================================================================
   基本スタイル
   ========================================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #FFF5E6 0%, #FFEEDD 100%);
    color: var(--color-text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* ==========================================================================
   メインコンテナ
   ========================================================================== */
#app-container {
    width: 100%;
    max-width: 900px;
    margin: 20px;
}

/* 画面の表示/非表示 */
.screen {
    display: none;
}

.screen.active {
    display: block;
    animation: fadeIn 0.3s ease-in;
}

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

/* ==========================================================================
   設定画面
   ========================================================================== */
.content-box {
    background: var(--color-white);
    border-radius: 20px;
    box-shadow: 0 10px 30px var(--color-shadow);
    padding: 40px;
    max-width: 600px;
    margin: 0 auto;
}

.app-header {
    text-align: center;
    margin-bottom: 40px;
}

.app-header i {
    font-size: 60px;
    color: var(--color-main);
    margin-bottom: 10px;
}

.app-header h1 {
    font-size: 32px;
    color: var(--color-text);
    font-weight: 700;
}

/* フォームスタイル */
.setup-form {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-group label {
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
}

.form-group label i {
    color: var(--color-accent);
    margin-right: 8px;
}

.form-group input[type="text"] {
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-white);
    transition: border-color 0.3s;
}

.form-group input[type="text"]:focus {
    outline: none;
    border-color: var(--color-main);
}

.form-group input[type="text"][readonly] {
    background: #f5f5f5;
    cursor: not-allowed;
    color: #666;
}

/* セレクトボックス */
.select-input {
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--color-border);
    border-radius: 10px;
    background: var(--color-white);
    cursor: pointer;
    transition: border-color 0.3s;
}

.select-input:focus {
    outline: none;
    border-color: var(--color-main);
}

/* ラジオボタン */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ラジオボタン（グリッド表示） */
.radio-group-grid {
    display: grid;
    gap: 12px;
}

/* 2列グリッド */
.radio-group-2col {
    grid-template-columns: 1fr 1fr;
}

/* 3列グリッド */
.radio-group-3col {
    grid-template-columns: 1fr 1fr 1fr;
}

.radio-label {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border: 2px solid var(--color-border);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s;
    background: var(--color-white);
}

.radio-label:hover {
    border-color: var(--color-main);
    background: #FFF9F5;
}

.radio-label input[type="radio"] {
    display: none;
}

.radio-custom {
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-radius: 50%;
    margin-right: 12px;
    position: relative;
    transition: all 0.3s;
}

.radio-label input[type="radio"]:checked + .radio-custom {
    border-color: var(--color-main);
    background: var(--color-main);
}

.radio-label input[type="radio"]:checked + .radio-custom::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--color-white);
}

.radio-label input[type="radio"]:checked ~ span:not(.radio-custom) {
    font-weight: 600;
}

/* ボタン */
.btn {
    padding: 14px 28px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-main) 0%, var(--color-accent) 100%);
    color: var(--color-white);
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-danger {
    background: #FF4444;
    color: var(--color-white);
}

.btn-danger:hover {
    background: #CC0000;
}

/* ==========================================================================
   会話画面
   ========================================================================== */
.conversation-container {
    background: var(--color-white);
    border-radius: 20px;
    box-shadow: 0 10px 30px var(--color-shadow);
    overflow: hidden;
    height: 80vh;
    display: flex;
    flex-direction: column;
}

/* ヘッダー */
.conversation-header {
    background: linear-gradient(135deg, var(--color-main) 0%, var(--color-accent) 100%);
    color: var(--color-white);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left i {
    font-size: 28px;
}

.header-left h2 {
    font-size: 24px;
    font-weight: 600;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.timer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 18px;
    font-weight: 600;
}

/* フェーズインジケータ */
.phase-indicator {
    background: linear-gradient(135deg, #FFE4B5 0%, #FFDAB9 100%);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--color-border);
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.phase-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.phase-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--color-text);
}

.phase-title i {
    color: var(--color-main);
}

.phase-details {
    display: flex;
    align-items: center;
    gap: 20px;
    font-size: 14px;
    color: var(--color-text);
}

.phase-current {
    font-weight: 500;
}

.phase-timer {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 600;
    color: var(--color-accent);
}

.phase-timer i {
    font-size: 14px;
}

/* チャットエリア */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    background: var(--color-background);
}

/* メッセージ */
.message {
    display: flex;
    margin-bottom: 20px;
    animation: slideIn 0.3s ease-out;
}

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

.message.ai {
    justify-content: flex-start;
}

.message.learner {
    justify-content: flex-end;
}

.message-bubble {
    max-width: 70%;
    padding: 15px 20px;
    border-radius: 18px;
    position: relative;
}

.message.ai .message-bubble {
    background: var(--color-ai-bubble);
    border-bottom-left-radius: 4px;
}

.message.learner .message-bubble {
    background: var(--color-learner-bubble);
    border-bottom-right-radius: 4px;
}

.message-header {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
    opacity: 0.7;
    margin-bottom: 5px;
}

.message-content {
    font-size: 16px;
    color: var(--color-text);
    line-height: 1.5;
}

/* マークダウン整形スタイル */
.message-content strong {
    font-weight: 700;
    color: var(--color-main);
}

.message-content em {
    font-style: italic;
}

.message-content ul,
.message-content ol {
    margin: 10px 0;
    padding-left: 25px;
}

.message-content ul li,
.message-content ol li {
    margin: 5px 0;
    line-height: 1.6;
}

.message-content ol {
    list-style-type: decimal;
}

.message-content ul {
    list-style-type: disc;
}

.message-content p {
    margin: 8px 0;
}

.message-content p:first-child {
    margin-top: 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.message-content pre {
    background: rgba(0, 0, 0, 0.05);
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 10px 0;
}

.message-content pre code {
    background: none;
    padding: 0;
}

.message-time {
    font-size: 11px;
    color: var(--color-text);
    opacity: 0.5;
    margin-top: 5px;
    text-align: right;
}

/* 訂正メッセージ */
.correction {
    background: #FFFACD;
    border-left: 4px solid var(--color-accent);
    padding: 12px 16px;
    margin-top: 10px;
    border-radius: 8px;
    font-size: 14px;
}

.correction i {
    color: var(--color-accent);
    margin-right: 6px;
}

/* ステータスバー */
.status-bar {
    padding: 20px 30px;
    background: var(--color-white);
    border-top: 2px solid var(--color-border);
}

.status-item {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
    color: var(--color-text);
}

.status-item.active {
    display: flex;
}

.status-main {
    display: flex;
    align-items: center;
    gap: 12px;
}

.status-item i {
    font-size: 24px;
    color: var(--color-main);
}

/* 途中結果表示 */
.interim-result {
    min-height: 24px;
    padding: 8px 16px;
    font-size: 16px;
    font-weight: 400;
    color: #999;
    font-style: italic;
    text-align: center;
    border-radius: 8px;
    background: #F5F5F5;
    max-width: 600px;
    word-wrap: break-word;
    transition: opacity 0.2s;
}

.interim-result:empty {
    opacity: 0;
    padding: 0;
    min-height: 0;
}

.interim-result:not(:empty) {
    opacity: 1;
    margin-top: 8px;
}

/* ヒントボタン */
.hint-button {
    margin-top: 12px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    color: var(--color-white);
    background: linear-gradient(135deg, #FFA500 0%, #FF8C00 100%);
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(255, 165, 0, 0.3);
    transition: all 0.3s;
    animation: fadeInBounce 0.5s ease-out;
}

.hint-button i {
    font-size: 20px;
    color: #FFD700;
}

.hint-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(255, 165, 0, 0.4);
    background: linear-gradient(135deg, #FFB520 0%, #FF9C10 100%);
}

.hint-button:active {
    transform: translateY(0);
}

@keyframes fadeInBounce {
    0% {
        opacity: 0;
        transform: scale(0.8) translateY(-10px);
    }
    60% {
        opacity: 1;
        transform: scale(1.05) translateY(0);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* パルスアニメーション（録音中・AI応答中） */
@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.8; }
}

.pulse-icon {
    animation: pulse 1.5s ease-in-out infinite;
}

/* スクロールバーのカスタマイズ */
.chat-area::-webkit-scrollbar {
    width: 8px;
}

.chat-area::-webkit-scrollbar-track {
    background: var(--color-background);
}

.chat-area::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: 4px;
}

.chat-area::-webkit-scrollbar-thumb:hover {
    background: var(--color-main);
}

/* ==========================================================================
   レスポンシブ対応（参考：設計書ではスマホ対応不要だが追加）
   ========================================================================== */
@media (max-width: 768px) {
    .content-box {
        padding: 30px 20px;
    }

    .conversation-header {
        padding: 15px 20px;
        flex-direction: column;
        gap: 15px;
    }

    .header-left h2 {
        font-size: 20px;
    }

    .chat-area {
        padding: 20px;
    }

    .message-bubble {
        max-width: 85%;
    }
}
