/* JB-Voice 채팅 스타일시트 */
/* 리팩토링: chat_web.py에서 분리 */

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', 'Malgun Gothic', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    min-height: 100vh;
    color: #fff;
}

/* 로그인 화면 */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
}
.login-box {
    background: rgba(255,255,255,0.1);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.login-box h1 {
    color: #00d4ff;
    margin-bottom: 10px;
    font-size: 28px;
}
.login-box p {
    color: #aaa;
    margin-bottom: 30px;
    font-size: 14px;
}
.phone-input {
    width: 100%;
    padding: 15px 20px;
    font-size: 18px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 10px;
    background: rgba(0,0,0,0.3);
    color: #fff;
    text-align: center;
    letter-spacing: 2px;
    margin-bottom: 20px;
}
.phone-input:focus {
    outline: none;
    border-color: #00d4ff;
}
.phone-input::placeholder {
    color: #666;
    letter-spacing: normal;
}
.login-btn {
    width: 100%;
    padding: 15px;
    font-size: 16px;
    font-weight: bold;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    color: #fff;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}
.login-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0,212,255,0.4);
}
.login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.error-msg {
    color: #ff4757;
    margin-top: 15px;
    font-size: 14px;
    display: none;
}

/* 채팅 화면 */
.chat-container {
    display: none;
    flex-direction: column;
    height: 100vh;
    max-width: 800px;
    margin: 0 auto;
}

.chat-header {
    background: rgba(0,0,0,0.3);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.dealer-info {
    display: flex;
    align-items: center;
    gap: 10px;
}
.dealer-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 18px;
}
.dealer-name {
    font-weight: bold;
    color: #00d4ff;
}
.dealer-id {
    font-size: 12px;
    color: #888;
}
.logout-btn {
    padding: 8px 16px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
}
.logout-btn:hover {
    background: rgba(255,255,255,0.1);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.message {
    margin-bottom: 15px;
    max-width: 80%;
    animation: fadeIn 0.3s;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    margin-left: auto;
}
.message.ai {
    margin-right: auto;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 15px;
    line-height: 1.5;
}
.message.user .message-bubble {
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    border-bottom-right-radius: 5px;
}
.message.ai .message-bubble {
    background: rgba(255,255,255,0.15);
    border-bottom-left-radius: 5px;
}

.message-time {
    font-size: 11px;
    color: #666;
    margin-top: 5px;
    text-align: right;
}
.message.ai .message-time {
    text-align: left;
}

/* 테이블 스타일 */
.data-table {
    width: 100%;
    margin-top: 10px;
    border-collapse: collapse;
    font-size: 13px;
}
.data-table th, .data-table td {
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.2);
    text-align: left;
}
.data-table th {
    background: rgba(0,212,255,0.2);
    color: #00d4ff;
    width: 100px;
}
.data-table td {
    background: rgba(0,0,0,0.2);
}

.chat-input-area {
    background: rgba(0,0,0,0.3);
    padding: 15px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.input-wrapper {
    display: flex;
    gap: 10px;
}
.chat-input {
    flex: 1;
    padding: 12px 16px;
    font-size: 15px;
    border: 2px solid rgba(255,255,255,0.2);
    border-radius: 25px;
    background: rgba(0,0,0,0.3);
    color: #fff;
}
.chat-input:focus {
    outline: none;
    border-color: #00d4ff;
}
.chat-input::placeholder {
    color: #666;
}
.send-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: transform 0.2s;
}
.send-btn:hover {
    transform: scale(1.05);
}
.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 로딩 인디케이터 */
.typing-indicator {
    display: none;
    padding: 15px;
}
.typing-indicator span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #00d4ff;
    margin: 0 2px;
    animation: bounce 1.4s infinite ease-in-out both;
}
.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }
@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* 빠른 질문 버튼 */
.quick-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}
.quick-btn {
    padding: 8px 14px;
    border: 1px solid rgba(0,212,255,0.3);
    border-radius: 20px;
    background: rgba(0,212,255,0.1);
    color: #00d4ff;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}
.quick-btn:hover {
    background: rgba(0,212,255,0.2);
    border-color: #00d4ff;
}

/* 음성 토글 버튼 */
.voice-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    margin-right: 10px;
}
.voice-toggle.active {
    background: rgba(0,212,255,0.2);
    border-color: #00d4ff;
    color: #00d4ff;
}
.voice-toggle:hover {
    background: rgba(255,255,255,0.1);
}

/* 녹취 버튼 */
.record-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 20px;
    background: transparent;
    color: #fff;
    cursor: pointer;
    font-size: 13px;
    margin-right: 10px;
}
.record-btn.active {
    background: rgba(255, 82, 82, 0.2);
    border-color: #ff5252;
    color: #ff5252;
}
.record-btn:hover {
    background: rgba(255,255,255,0.1);
}

audio { display: none; }

/* 마이크 버튼 */
.mic-btn {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #ff6b6b, #ee5a5a);
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s;
    display: flex;
    justify-content: center;
    align-items: center;
}
.mic-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 20px rgba(255,107,107,0.4);
}
.mic-btn.recording {
    background: linear-gradient(135deg, #ff4757, #ff3838);
    animation: pulse 1s infinite;
}
.mic-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    animation: none;
}
@keyframes pulse {
    0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255,71,87,0.7); }
    50% { transform: scale(1.05); box-shadow: 0 0 0 15px rgba(255,71,87,0); }
}

/* 녹음 상태 표시 */
.recording-status {
    display: none;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(255,71,87,0.2);
    border-radius: 20px;
    color: #ff6b6b;
    font-size: 13px;
    margin-bottom: 10px;
}
.recording-status.active {
    display: flex;
}
.recording-dot {
    width: 8px;
    height: 8px;
    background: #ff4757;
    border-radius: 50%;
    animation: blink 1s infinite;
}
@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* 대기 메시지 애니메이션 */
.message.waiting .waiting-dots {
    animation: dotPulse 1.5s infinite;
}
@keyframes dotPulse {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}

/* 음성 대화 모드 */
.voice-mode-indicator {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 12px 20px;
    background: linear-gradient(135deg, rgba(0,212,255,0.15), rgba(0,153,204,0.15));
    border: 2px solid rgba(0,212,255,0.4);
    border-radius: 15px;
    color: #00d4ff;
    font-size: 14px;
    margin-bottom: 10px;
}
.voice-mode-indicator.active {
    display: flex;
}
.voice-mode-indicator.listening {
    background: linear-gradient(135deg, rgba(76,175,80,0.15), rgba(56,142,60,0.15));
    border-color: rgba(76,175,80,0.6);
    color: #4CAF50;
}
.voice-mode-indicator.processing {
    background: linear-gradient(135deg, rgba(255,152,0,0.15), rgba(245,124,0,0.15));
    border-color: rgba(255,152,0,0.6);
    color: #FF9800;
}
.voice-mode-indicator.speaking {
    background: linear-gradient(135deg, rgba(156,39,176,0.15), rgba(123,31,162,0.15));
    border-color: rgba(156,39,176,0.6);
    color: #9C27B0;
}
.voice-wave {
    display: flex;
    align-items: center;
    gap: 3px;
    height: 20px;
}
.voice-wave span {
    display: block;
    width: 4px;
    background: currentColor;
    border-radius: 2px;
    animation: wave 1.2s infinite ease-in-out;
}
.voice-wave span:nth-child(1) { animation-delay: -0.4s; }
.voice-wave span:nth-child(2) { animation-delay: -0.3s; }
.voice-wave span:nth-child(3) { animation-delay: -0.2s; }
.voice-wave span:nth-child(4) { animation-delay: -0.1s; }
.voice-wave span:nth-child(5) { animation-delay: 0s; }
@keyframes wave {
    0%, 40%, 100% { height: 8px; }
    20% { height: 20px; }
}

/* 마이크 버튼 - 음성 대화 모드 */
.mic-btn.voice-mode {
    background: linear-gradient(135deg, #00d4ff, #0099cc);
    animation: pulse-blue 2s infinite;
}
@keyframes pulse-blue {
    0%, 100% { box-shadow: 0 0 0 0 rgba(0,212,255,0.7); }
    50% { box-shadow: 0 0 0 15px rgba(0,212,255,0); }
}

/* 볼륨 미터 */
.volume-meter {
    width: 100%;
    height: 4px;
    background: rgba(255,255,255,0.1);
    border-radius: 2px;
    overflow: hidden;
    margin-top: 8px;
}
.volume-meter-fill {
    height: 100%;
    background: linear-gradient(90deg, #4CAF50, #8BC34A);
    width: 0%;
    transition: width 0.1s;
}

/* 녹취 표시 애니메이션 */
@keyframes pulse-red {
    0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,68,68,0.7); }
    50% { opacity: 0.8; box-shadow: 0 0 0 10px rgba(255,68,68,0); }
}
#recordingIndicator {
    animation: pulse-red 1.5s infinite;
}
