/* ========================================
   AI Voice Chat - Styles
   모던 다크 테마 디자인
======================================== */

:root {
    /* 색상 팔레트 - 다크 테마 */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a26;
    --bg-card: #1e1e2d;
    
    --text-primary: #ffffff;
    --text-secondary: #a0a0b2;
    --text-muted: #6b6b7d;
    
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #a855f7 100%);
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --border-color: rgba(255, 255, 255, 0.08);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
    --shadow-glow: 0 0 40px rgba(99, 102, 241, 0.3);
    
    /* 간격 */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    
    /* 폰트 */
    --font-display: 'Outfit', sans-serif;
    --font-body: 'Noto Sans KR', sans-serif;
    
    /* 반경 */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;
    
    /* 트랜지션 */
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms ease;
}

/* 라이트 테마 */
[data-theme="light"] {
    --bg-primary: #f8f9fc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f0f1f5;
    --bg-card: #ffffff;
    
    --text-primary: #1a1a2e;
    --text-secondary: #4a4a5c;
    --text-muted: #8a8a9c;
    
    --border-color: rgba(0, 0, 0, 0.08);
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.16);
}

/* ========================================
   기본 스타일
======================================== */

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

/* 배경 그라데이션 효과 */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(ellipse at 20% 20%, rgba(99, 102, 241, 0.15) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 80%, rgba(139, 92, 246, 0.1) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 50%, rgba(168, 85, 247, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ========================================
   앱 컨테이너
======================================== */

.app-container {
    position: relative;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

/* ========================================
   헤더
======================================== */

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) var(--space-lg);
    background: rgba(10, 10, 15, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo-icon {
    font-size: 1.5rem;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

.logo-text {
    font-family: var(--font-display);
    font-size: 1.25rem;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-actions {
    display: flex;
    gap: var(--space-sm);
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-base);
}

.icon-btn:hover {
    background: var(--bg-card);
    border-color: var(--accent-primary);
    transform: scale(1.05);
}

.icon-btn .icon {
    font-size: 1.1rem;
}

/* ========================================
   메인 콘텐츠
======================================== */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--space-lg);
    max-width: 600px;
    margin: 0 auto;
    width: 100%;
}

/* ========================================
   아바타 섹션
======================================== */

.avatar-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-2xl) 0;
}

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

.avatar-ring {
    position: relative;
    width: 160px;
    height: 160px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    padding: 4px;
    box-shadow: var(--shadow-glow);
}

.avatar-pulse {
    position: absolute;
    inset: -8px;
    border-radius: var(--radius-full);
    border: 2px solid var(--accent-primary);
    opacity: 0;
    animation: pulse-ring 2s ease-out infinite;
}

@keyframes pulse-ring {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(1.2);
        opacity: 0;
    }
}

.avatar-inner {
    width: 100%;
    height: 100%;
    border-radius: var(--radius-full);
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar-face {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.avatar-eyes {
    display: flex;
    gap: 24px;
}

.eye {
    width: 16px;
    height: 16px;
    background: var(--accent-primary);
    border-radius: var(--radius-full);
    position: relative;
    animation: blink 3s ease-in-out infinite;
}

.eye::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: var(--radius-full);
    top: 3px;
    left: 3px;
}

@keyframes blink {
    0%, 45%, 55%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(0.1); }
}

.avatar-mouth {
    width: 24px;
    height: 8px;
    background: var(--accent-secondary);
    border-radius: 0 0 var(--radius-full) var(--radius-full);
    transition: var(--transition-base);
}

/* 말하는 상태 */
.avatar-container.speaking .avatar-mouth {
    animation: speak 200ms ease-in-out infinite alternate;
}

@keyframes speak {
    0% { height: 8px; }
    100% { height: 16px; }
}

/* 듣는 상태 */
.avatar-container.listening .avatar-ring {
    animation: listening-glow 1s ease-in-out infinite alternate;
}

@keyframes listening-glow {
    0% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.3); }
    100% { box-shadow: 0 0 40px rgba(99, 102, 241, 0.6); }
}

.avatar-status {
    margin-top: var(--space-md);
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* 비주얼라이저 */
.visualizer {
    display: flex;
    gap: 4px;
    height: 40px;
    align-items: center;
    margin-top: var(--space-lg);
    opacity: 0;
    transition: var(--transition-base);
}

.visualizer.active {
    opacity: 1;
}

.visualizer .bar {
    width: 4px;
    height: 8px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    transition: height 100ms ease;
}

.visualizer.active .bar {
    animation: visualize 400ms ease-in-out infinite;
}

.visualizer .bar:nth-child(1) { animation-delay: 0ms; }
.visualizer .bar:nth-child(2) { animation-delay: 50ms; }
.visualizer .bar:nth-child(3) { animation-delay: 100ms; }
.visualizer .bar:nth-child(4) { animation-delay: 150ms; }
.visualizer .bar:nth-child(5) { animation-delay: 200ms; }
.visualizer .bar:nth-child(6) { animation-delay: 250ms; }
.visualizer .bar:nth-child(7) { animation-delay: 300ms; }

@keyframes visualize {
    0%, 100% { height: 8px; }
    50% { height: 32px; }
}

/* ========================================
   채팅 섹션
======================================== */

.chat-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 200px;
    max-height: 300px;
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
}

.chat-welcome {
    text-align: center;
    padding: var(--space-xl);
    color: var(--text-secondary);
}

.chat-welcome h2 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    margin-bottom: var(--space-sm);
    color: var(--text-primary);
}

.chat-welcome p {
    font-size: 0.95rem;
    line-height: 1.7;
}

/* 메시지 스타일 */
.message {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    animation: messageIn 300ms ease-out;
}

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

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--bg-tertiary);
}

.message-content {
    max-width: 80%;
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    font-size: 0.95rem;
}

.message.user .message-content {
    background: var(--accent-primary);
    color: white;
}

.message.ai .message-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

/* ========================================
   컨트롤 섹션
======================================== */

.control-section {
    padding: var(--space-lg) 0;
}

.call-button-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

.call-button {
    width: 100%;
    max-width: 280px;
    padding: var(--space-lg) var(--space-xl);
    border: none;
    border-radius: var(--radius-xl);
    background: var(--accent-gradient);
    color: white;
    font-family: var(--font-body);
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    box-shadow: var(--shadow-md), var(--shadow-glow);
    transition: var(--transition-base);
    position: relative;
    overflow: hidden;
    /* 모바일 터치 최적화 */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

.call-button::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.2) 0%, transparent 50%);
    opacity: 0;
    transition: var(--transition-base);
}

.call-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 60px rgba(99, 102, 241, 0.4);
}

.call-button:hover::before {
    opacity: 1;
}

.call-button:active,
.call-button.recording {
    transform: scale(0.98);
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
}

.call-button.recording {
    animation: recording-pulse 1s ease-in-out infinite;
}

@keyframes recording-pulse {
    0%, 100% { box-shadow: var(--shadow-md), 0 0 20px rgba(239, 68, 68, 0.4); }
    50% { box-shadow: var(--shadow-lg), 0 0 40px rgba(239, 68, 68, 0.6); }
}

/* 통화 활성화 상태 */
.call-button.active {
    background: linear-gradient(135deg, #22c55e 0%, #16a34a 100%);
}

/* 응답 중 상태 */
.call-button.speaking {
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    animation: speaking-pulse 0.8s ease-in-out infinite;
}

@keyframes speaking-pulse {
    0%, 100% { box-shadow: var(--shadow-md), 0 0 20px rgba(59, 130, 246, 0.4); }
    50% { box-shadow: var(--shadow-lg), 0 0 40px rgba(59, 130, 246, 0.6); }
}

/* 처리 중 상태 */
.call-button.processing {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    animation: processing-pulse 1.5s ease-in-out infinite;
}

@keyframes processing-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.call-icon {
    font-size: 1.5rem;
}

.call-hint {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* 텍스트 입력 */
.text-input-wrapper {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-color);
}

.text-input {
    flex: 1;
    padding: var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 0.95rem;
    transition: var(--transition-base);
}

.text-input:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.text-input::placeholder {
    color: var(--text-muted);
}

.send-button {
    padding: var(--space-md) var(--space-lg);
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent-primary);
    color: white;
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-base);
}

.send-button:hover {
    background: var(--accent-secondary);
}

.send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ========================================
   설정 패널
======================================== */

.settings-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 100%;
    max-width: 360px;
    height: 100vh;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-color);
    z-index: 200;
    transition: right var(--transition-slow);
}

.settings-panel.open {
    right: 0;
}

.settings-content {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border-color);
}

.settings-header h3 {
    font-family: var(--font-display);
    font-size: 1.25rem;
}

.close-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: var(--radius-full);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition-base);
}

.close-btn:hover {
    background: var(--danger);
    color: white;
}

.settings-body {
    flex: 1;
    padding: var(--space-lg);
    overflow-y: auto;
}

.setting-item {
    margin-bottom: var(--space-lg);
}

.setting-item label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-sm);
}

.setting-item select,
.setting-item input[type="range"] {
    width: 100%;
    padding: var(--space-sm) var(--space-md);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: var(--font-body);
}

.setting-item select:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.danger-btn {
    width: 100%;
    padding: var(--space-md);
    border: 1px solid var(--danger);
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--danger);
    font-family: var(--font-body);
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition-base);
}

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

/* ========================================
   로딩 오버레이
======================================== */

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 10, 15, 0.9);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition-base);
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-lg);
}

.spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loadingText {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

/* ========================================
   반응형 디자인
======================================== */

@media (max-width: 640px) {
    .main-content {
        padding: var(--space-md);
    }
    
    .avatar-ring {
        width: 120px;
        height: 120px;
    }
    
    .call-button {
        max-width: 100%;
    }
    
    .settings-panel {
        max-width: 100%;
    }
}

/* ========================================
   스크롤바 스타일
======================================== */

::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--accent-primary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-secondary);
}

/* ========================================
   HTTP 경고 배너
======================================== */

.http-warning {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: white;
    padding: 12px 16px;
    font-size: 14px;
    position: relative;
    z-index: 1000;
}

.http-warning .warning-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    max-width: 800px;
    margin: 0 auto;
}

.http-warning .warning-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.http-warning .warning-text {
    flex: 1;
}

.http-warning .warning-text strong {
    display: block;
    margin-bottom: 4px;
}

.http-warning .warning-text p {
    margin: 4px 0;
    font-size: 12px;
    opacity: 0.9;
}

.http-warning .warning-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    flex-shrink: 0;
}

.http-warning .warning-close:hover {
    background: rgba(255, 255, 255, 0.3);
}
