/**
 * ChatGPT Realtime Voice - スタイルシート
 */

.chatgpt-realtime-container {
    border: 1px solid #ddd;
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    overflow: hidden;
    height: 600px;
    width: 500px;
    margin: 0 auto;
}

.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    text-align: center;
}

.chat-header h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    background: none!important;
}

.chat-header h2:before {
    display: none;
}

.chat-description {
    margin: 8px 0 0 0;
    font-size: 14px;
    opacity: 0.9;
    font-weight: 400;
}

/* エラーメッセージ */
.chatgpt-realtime-error {
    padding: 15px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 10px 0;
    font-size: 14px;
}

.chat-messages {
    height: 300px;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 15px;
    transition: opacity 0.3s ease, height 0.3s ease;
}

.chat-messages.hidden {
    opacity: 0;
    pointer-events: none;
}

.chat-messages.collapsed {
    height: 0;
    padding: 0 20px;
    overflow: hidden;
}

.message {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    line-height: 1.4;
    animation: fadeIn 0.3s ease-in;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.message p {
    margin: 0;
    word-wrap: break-word;
}

.user-message {
    background: #007cff;
    color: white;
    align-self: flex-end;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.bot-message {
    background: white;
    color: #333;
    align-self: flex-start;
    border: 1px solid #e1e8ed;
    border-bottom-left-radius: 4px;
}

.bot-message.streaming {
    border-color: #667eea;
    background: #f0f4ff;
}

.bot-message.streaming::after {
    content: "▋";
    animation: blink 1s infinite;
    color: #667eea;
}

.chat-controls {
    padding: 10px 20px;
    background: white;
    border-top: 1px solid #e1e8ed;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding-top: 20px;
}

.voice-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px;
    margin-top: 20px;
    border: none;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 200px;
    justify-content: center;
}

.voice-btn.ready {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.voice-btn.ready:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.voice-btn.connecting {
    background: #ffc107;
    color: #333;
}

.voice-btn.listening {
    background: #dc3545;
    color: white;
    animation: pulse 2s infinite;
}

.voice-btn.error {
    background: #6c757d;
    color: white;
    cursor: not-allowed;
}

.voice-btn:disabled {
    cursor: not-allowed;
    opacity: 0.7;
}


.btn-icon {
    font-size: 20px;
}


/* チャット表示トグル */
.chat-toggle-control {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    width: 100%;
    max-width: 300px;
    cursor: pointer;
}

.chat-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    user-select: none;
    flex: 1;
}

.chat-toggle-icon {
    font-size: 16px;
}

.chat-toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
    cursor: pointer;
    flex-shrink: 0;
}

.chat-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.chat-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.chat-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .chat-toggle-slider {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

input:checked + .chat-toggle-slider:before {
    transform: translateX(26px);
}

.chat-toggle-slider:hover {
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

/* 音量コントロール */
.volume-control {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    width: 100%;
    max-width: 300px;
}

.volume-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    cursor: pointer;
}

.volume-icon {
    font-size: 16px;
}

.volume-slider {
    flex: 1;
    height: 6px;
    background: #e1e8ed;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.volume-slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.volume-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

.volume-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.volume-slider::-moz-range-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(102, 126, 234, 0.4);
}

/* 残り時間表示 */
.remaining-time-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    font-size: 14px;
    color: #333;
}

.remaining-time-icon {
    font-size: 16px;
}

.remaining-time-label {
    font-weight: 500;
    color: #555;
}

.remaining-time-value {
    font-weight: bold;
    color: #46b450;
    font-size: 15px;
}

.volume-slider::-moz-range-track {
    height: 6px;
    background: #e1e8ed;
    border-radius: 3px;
    border: none;
}

.volume-value {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    min-width: 35px;
    text-align: center;
}

/* アニメーション */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(220, 53, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0);
    }
}

/* レスポンシブデザイン */
@media (max-width: 768px) {
    .chatgpt-realtime-container {
        margin: 10px;
    }
    
    .message {
        max-width: 90%;
    }
    
    .voice-btn {
        min-width: 180px;
        padding: 12px 25px;
        font-size: 14px;
    }
    
    .chat-messages {
        height: 250px;
        padding: 15px;
    }
    
    .volume-control {
        max-width: 250px;
        gap: 8px;
    }
    
    .volume-label {
        font-size: 13px;
    }
    
    .volume-value {
        font-size: 11px;
        min-width: 30px;
    }
}

/* スクロールバーのスタイリング */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* セッション制限・終了ポップアップ */
.session-limit-popup,
.session-timeout-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.3s ease;
}

.session-limit-popup.show,
.session-timeout-popup.show {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 10000;
}

.popup-content {
    position: relative;
    background: white;
    padding: 40px 30px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    z-index: 10001;
}

.session-timeout-popup.show .popup-content {
    transform: scale(1);
}

.popup-icon {
    font-size: 60px;
    margin-bottom: 20px;
    animation: bounce 1s infinite;
}

.popup-content h3 {
    margin: 0 0 15px 0;
    font-size: 24px;
    font-weight: 600;
    color: #333;
    background: none!important;
}

.popup-content h3:before {
    display: none;
}

.popup-content p {
    margin: 0 0 30px 0;
    font-size: 16px;
    color: #666;
    line-height: 1.5;
}

.popup-close-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px;
}

.popup-close-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

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

/* ポップアップ用のバウンスアニメーション */
@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
    60% {
        transform: translateY(-5px);
    }
}

/* モバイル対応 */
@media (max-width: 768px) {
    .popup-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .popup-icon {
        font-size: 50px;
    }
    
    .popup-content h3 {
        font-size: 20px;
    }
    
    .popup-content p {
        font-size: 14px;
    }
    
    .popup-close-btn {
        padding: 12px 25px;
        font-size: 14px;
    }
}
