/* ======================
   CSS 변수 - 다크 모드 (기본)
   모던 다크 테마 - 녹색/에메랄드 톤
   ====================== */

:root {
    /* 배경 - 순수 검정 대신 부드러운 다크 블루 */
    --bg-primary: #0d1117;
    --bg-secondary: #161b22;
    --bg-tertiary: #21262d;
    --bg-hover: #30363d;
    --bg-elevated: #1c2128;
    
    /* 텍스트 - 순백 대신 부드러운 화이트 */
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-tertiary: #6e7681;
    --text-inverse: #0d1117;
    --text-link: #58a6ff;
    
    /* 강조색 - 녹색/에메랄드 */
    --accent-primary: #10b981;
    --accent-secondary: #34d399;
    --accent-tertiary: #059669;
    --accent-hover: #059669;
    
    /* 보조 강조색 */
    --accent-blue: #58a6ff;
    --accent-cyan: #39d0d8;
    --accent-green: #3fb950;
    --accent-orange: #f0883e;
    --accent-pink: #f472b6;
    
    /* 경계선 */
    --border: #30363d;
    --border-hover: #484f58;
    --border-accent: #10b981;
    --border-subtle: #21262d;
    
    /* 상태 색상 */
    --success: #3fb950;
    --success-bg: rgba(63, 185, 80, 0.15);
    --warning: #d29922;
    --warning-bg: rgba(210, 153, 34, 0.15);
    --error: #f85149;
    --error-bg: rgba(248, 81, 73, 0.15);
    --info: #58a6ff;
    --info-bg: rgba(88, 166, 255, 0.15);
    
    /* 그라데이션 - 녹색 계열 */
    --gradient-accent: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
    --gradient-accent-reverse: linear-gradient(135deg, #047857 0%, #059669 50%, #10b981 100%);
    --gradient-warm: linear-gradient(135deg, #f472b6 0%, #f0883e 100%);
    --gradient-cool: linear-gradient(135deg, #39d0d8 0%, #58a6ff 100%);
    --gradient-surface: linear-gradient(180deg, #161b22 0%, #0d1117 100%);
    
    /* 그림자 */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
    --shadow-xl: 0 12px 48px rgba(0, 0, 0, 0.6);
    --shadow-glow: 0 0 20px rgba(16, 185, 129, 0.4);
    --shadow-glow-lg: 0 0 40px rgba(16, 185, 129, 0.3);
    --shadow-inner: inset 0 1px 2px rgba(0, 0, 0, 0.2);
    
    /* 오버레이 */
    --overlay-light: rgba(255, 255, 255, 0.05);
    --overlay-dark: rgba(0, 0, 0, 0.5);
    --overlay-accent: rgba(16, 185, 129, 0.1);
    
    /* 애니메이션 */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;
    --transition-bounce: 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    
    /* 반경 */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-full: 9999px;
    
    /* 블러 */
    --blur-sm: 4px;
    --blur-md: 8px;
    --blur-lg: 16px;
}

/* ======================
   라이트 모드 - 따뜻한 크림/베이지 톤 + 녹색 강조
   ====================== */

.light-mode {
    /* 배경 - 따뜻한 크림 톤 */
    --bg-primary: #fafaf9;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f5f5f4;
    --bg-hover: #e7e5e4;
    --bg-elevated: #ffffff;
    
    /* 텍스트 - 순수 검정 대신 부드러운 다크 */
    --text-primary: #1c1917;
    --text-secondary: #57534e;
    --text-tertiary: #a8a29e;
    --text-inverse: #fafaf9;
    --text-link: #059669;
    
    /* 강조색 - 녹색/에메랄드 */
    --accent-primary: #059669;
    --accent-secondary: #10b981;
    --accent-tertiary: #047857;
    --accent-hover: #047857;
    
    /* 보조 강조색 */
    --accent-blue: #2563eb;
    --accent-cyan: #0891b2;
    --accent-green: #16a34a;
    --accent-orange: #ea580c;
    --accent-pink: #db2777;
    
    /* 경계선 */
    --border: #e7e5e4;
    --border-hover: #d6d3d1;
    --border-accent: #059669;
    --border-subtle: #f5f5f4;
    
    /* 상태 색상 */
    --success: #16a34a;
    --success-bg: rgba(22, 163, 74, 0.1);
    --warning: #ca8a04;
    --warning-bg: rgba(202, 138, 4, 0.1);
    --error: #dc2626;
    --error-bg: rgba(220, 38, 38, 0.1);
    --info: #2563eb;
    --info-bg: rgba(37, 99, 235, 0.1);
    
    /* 그라데이션 - 녹색 계열 */
    --gradient-accent: linear-gradient(135deg, #059669 0%, #047857 50%, #065f46 100%);
    --gradient-accent-reverse: linear-gradient(135deg, #065f46 0%, #047857 50%, #059669 100%);
    --gradient-warm: linear-gradient(135deg, #db2777 0%, #ea580c 100%);
    --gradient-cool: linear-gradient(135deg, #0891b2 0%, #2563eb 100%);
    --gradient-surface: linear-gradient(180deg, #ffffff 0%, #fafaf9 100%);
    
    /* 그림자 - 더 부드러운 그림자 */
    --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.05);
    --shadow-md: 0 4px 6px rgba(28, 25, 23, 0.07);
    --shadow-lg: 0 10px 15px rgba(28, 25, 23, 0.1);
    --shadow-xl: 0 20px 25px rgba(28, 25, 23, 0.1);
    --shadow-glow: 0 0 20px rgba(5, 150, 105, 0.15);
    --shadow-glow-lg: 0 0 40px rgba(5, 150, 105, 0.1);
    --shadow-inner: inset 0 1px 2px rgba(28, 25, 23, 0.06);
    
    /* 오버레이 */
    --overlay-light: rgba(255, 255, 255, 0.8);
    --overlay-dark: rgba(28, 25, 23, 0.5);
    --overlay-accent: rgba(5, 150, 105, 0.08);
}

/* ======================
   테마 전환 애니메이션
   ====================== */

body,
.sidebar,
.main-content,
.modal-content,
.message,
.card,
header,
aside,
main,
.chat-input-container,
.welcome-message {
    transition: 
        background-color var(--transition-normal),
        border-color var(--transition-normal),
        color var(--transition-normal),
        box-shadow var(--transition-normal);
}

/* ======================
   스크롤바 테마
   ====================== */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb {
    background: var(--border-hover);
    border-radius: var(--radius-full);
    border: 2px solid var(--bg-secondary);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* 라이트 모드 스크롤바 */
.light-mode ::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

.light-mode ::-webkit-scrollbar-thumb {
    background: var(--border);
    border-color: var(--bg-tertiary);
}

.light-mode ::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* ======================
   선택 영역 스타일
   ====================== */

::selection {
    background: var(--accent-primary);
    color: var(--text-inverse);
}

.light-mode ::selection {
    background: var(--accent-primary);
    color: white;
}

/* ======================
   포커스 스타일
   ====================== */

:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}

/* ======================
   유틸리티 클래스
   ====================== */

.gradient-text {
    background: var(--gradient-accent);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.gradient-border {
    border: 2px solid transparent;
    background: linear-gradient(var(--bg-secondary), var(--bg-secondary)) padding-box,
                var(--gradient-accent) border-box;
}

.glow {
    box-shadow: var(--shadow-glow);
}

.glow-lg {
    box-shadow: var(--shadow-glow-lg);
}

.surface-elevated {
    background: var(--bg-elevated);
    box-shadow: var(--shadow-md);
}

.surface-glass {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(var(--blur-md));
    -webkit-backdrop-filter: blur(var(--blur-md));
}

.light-mode .surface-glass {
    background: rgba(255, 255, 255, 0.7);
}

/* ======================
   AI 모델별 테마 변형
   기본 녹색 유지하면서 미묘한 변화
   ====================== */

/* OpenAI (GPT) - 청록/민트 톤 */
body.provider-openai {
    --accent-glow: rgba(16, 163, 127, 0.4);
    --provider-color: #10a37f;
    --provider-gradient: linear-gradient(135deg, #10a37f 0%, #1a7f64 50%, #0d6b56 100%);
}

body.provider-openai .gradient-text {
    background: linear-gradient(135deg, #10a37f 0%, #1a7f64 50%, #0d6b56 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

body.provider-openai .welcome-icon {
    filter: drop-shadow(0 0 20px #10a37f);
}

body.provider-openai .provider-selector select {
    border-color: #10a37f;
}

/* Claude - 주황/앰버 톤 */
body.provider-claude {
    --accent-glow: rgba(217, 119, 6, 0.4);
    --provider-color: #d97706;
    --provider-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
}

body.provider-claude .gradient-text {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 50%, #b45309 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

body.provider-claude .welcome-icon {
    filter: drop-shadow(0 0 20px #d97706);
}

body.provider-claude .provider-selector select {
    border-color: #d97706;
}

/* Gemini - 파란/보라 톤 */
body.provider-gemini {
    --accent-glow: rgba(66, 133, 244, 0.4);
    --provider-color: #4285f4;
    --provider-gradient: linear-gradient(135deg, #4285f4 0%, #7c4dff 50%, #536dfe 100%);
}

body.provider-gemini .gradient-text {
    background: linear-gradient(135deg, #4285f4 0%, #7c4dff 50%, #536dfe 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

body.provider-gemini .welcome-icon {
    filter: drop-shadow(0 0 20px #4285f4);
}

body.provider-gemini .provider-selector select {
    border-color: #4285f4;
}

/* Perplexity - 청색/시안 톤 */
body.provider-perplexity {
    --accent-glow: rgba(32, 180, 170, 0.4);
    --provider-color: #20b4aa;
    --provider-gradient: linear-gradient(135deg, #20b4aa 0%, #1a8f87 50%, #156d67 100%);
}

body.provider-perplexity .gradient-text {
    background: linear-gradient(135deg, #20b4aa 0%, #1a8f87 50%, #156d67 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

body.provider-perplexity .welcome-icon {
    filter: drop-shadow(0 0 20px #20b4aa);
}

body.provider-perplexity .provider-selector select {
    border-color: #20b4aa;
}

/* ======================
   모델 전환 애니메이션
   ====================== */

/* 텍스트 전환 애니메이션 */
.model-text-transition {
    animation: modelTextFade 0.5s ease-out;
}

@keyframes modelTextFade {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 아이콘 전환 애니메이션 */
.model-icon-transition {
    animation: modelIconPop 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes modelIconPop {
    0% {
        transform: scale(0.8) rotate(-10deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.1) rotate(5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* 테마 색상 전환 */
body {
    transition: 
        --accent-glow 0.5s ease,
        --provider-color 0.5s ease;
}

.gradient-text,
.welcome-icon {
    transition: all 0.4s ease;
}

/* 프로바이더 선택 드롭다운 강조 */
.provider-selector select {
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.provider-selector select:focus {
    box-shadow: 0 0 0 3px var(--accent-glow, rgba(16, 185, 129, 0.3));
}

/* 프로바이더 상태 아이콘 */
.provider-status {
    transition: all 0.3s ease;
}

.provider-status.success {
    color: var(--success);
}

.provider-status.warning {
    color: var(--warning);
}

.provider-status.error {
    color: var(--error);
}

/* ======================
   페르소나별 테마 변형
   ====================== */

/* 논문 도우미 - 녹색 (기본) */
body.persona-thesis {
    --persona-color: #10b981;
    --persona-glow: rgba(16, 185, 129, 0.4);
}

body.persona-thesis .sidebar-header .gradient-text {
    background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

body.persona-thesis .welcome-icon {
    filter: drop-shadow(0 0 20px #10b981);
}

/* 연구 상담가 - 핑크 */
body.persona-counselor {
    --persona-color: #ec4899;
    --persona-glow: rgba(236, 72, 153, 0.4);
}

body.persona-counselor .sidebar-header .gradient-text {
    background: linear-gradient(135deg, #f472b6 0%, #ec4899 50%, #db2777 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

body.persona-counselor .welcome-icon {
    filter: drop-shadow(0 0 20px #ec4899);
}

body.persona-counselor .app-title-container:hover {
    border-color: #ec4899;
}

/* AI 비서 - 인디고/보라 */
body.persona-general {
    --persona-color: #6366f1;
    --persona-glow: rgba(99, 102, 241, 0.4);
}

body.persona-general .sidebar-header .gradient-text {
    background: linear-gradient(135deg, #818cf8 0%, #6366f1 50%, #4f46e5 100%);
    -webkit-background-clip: text;
    background-clip: text;
}

body.persona-general .welcome-icon {
    filter: drop-shadow(0 0 20px #6366f1);
}

body.persona-general .app-title-container:hover {
    border-color: #6366f1;
}

/* 페르소나 + 프로바이더 조합 효과 */
/* 페르소나가 우선, 프로바이더는 아이콘 glow에만 적용 */
body.persona-counselor .provider-selector select {
    border-color: #ec4899;
}

body.persona-general .provider-selector select {
    border-color: #6366f1;
}
