/* === ALEX AI 메인 스타일시트 === */

/* --- 테마 시스템 (Theme System) --- */
:root, body[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f3f4f6;
    --bg-tertiary: #e5e7eb;
    --bg-hover: #d1d5db;
    --bg-accent: #dbeafe;
    --border-color: #d1d5db;
    --text-primary: #111827;
    --text-secondary: #4b5563;
    --accent: #059669;
    --new-tag-text: #1e40af;
    --new-tag-bg: #dbeafe;
}

body[data-theme="dark"] {
    --bg-primary: #000000;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --bg-hover: #4b5563;
    --bg-accent: #374151;
    --border-color: #4b5563;
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --accent: #2dd4bf;
    --new-tag-text: #60a5fa;
    --new-tag-bg: rgba(30, 64, 175, 0.5);
}

body[data-theme="blue"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --bg-hover: #475569;
    --bg-accent: #334155;
    --border-color: #475569;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --new-tag-text: #60a5fa;
    --new-tag-bg: rgba(30, 64, 175, 0.5);
}

/* --- 스크롤바 숨김 (Scrollbar Hide) --- */
.scrollbar-hide {
    -ms-overflow-style: none;  /* IE 및 Edge */
    scrollbar-width: none;     /* Firefox */
}
.scrollbar-hide::-webkit-scrollbar {
    display: none;             /* Chrome, Safari, Opera */
}

/* --- 기본 스타일 (Base Styles) --- */
body {
    /* 로컬 Pretendard 폰트 + 시스템 폰트 fallback */
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', '맑은 고딕', 'Noto Sans KR', 'Segoe UI', Roboto, system-ui, sans-serif;
    font-size: 14px; /* 기본 폰트 크기를 작게 설정 */
    overflow: hidden;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

.bg-primary { background-color: var(--bg-primary) !important; }
.bg-secondary { background-color: var(--bg-secondary); }
.bg-tertiary { background-color: var(--bg-tertiary); }
.bg-accent { background-color: var(--bg-accent); }
.text-primary { color: var(--text-primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.border-theme { border-color: var(--border-color); }
.border-accent { border-color: var(--accent); }
.text-accent { color: var(--accent); }
.hover\:bg-hover:hover { background-color: var(--bg-hover); }

/* --- 애니메이션 (Animations) --- */
.chat-bubble, .view-content { 
    opacity: 0; 
    transform: translateY(20px); 
    animation: pop-in 0.5s ease-out forwards; 
}

@keyframes pop-in { 
    to { 
        opacity: 1; 
        transform: translateY(0); 
    } 
}

/* --- 컴포넌트 스타일 (Component Styles) --- */
.model-dropdown, .settings-modal {
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    transform: translateY(-10px);
}

.settings-modal:not(.hidden), .model-dropdown:not(.hidden) {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

.model-dropdown:not(.hidden){
     display: block;
}

/* --- 사이드바 스타일 (Sidebar Styles) --- */
#sidebar.collapsed { 
    width: 80px; 
}

#sidebar.collapsed .sidebar-text { 
    opacity: 0; 
    visibility: hidden; 
    width: 0; 
}

.sidebar-text { 
    transition: opacity 0.2s ease, visibility 0.2s ease, width 0.2s ease; 
}

.sidebar-link.active { 
    background-color: var(--bg-accent); 
}

/* --- 테마 옵션 스타일 (Theme Options) --- */
.theme-option {
    border: 2px solid transparent;
    transition: all 0.3s ease;
}

.theme-option.border-accent {
    border-color: var(--accent);
}

/* --- 신규 태그 스타일 (New Tag) --- */
.new-tag {
    color: var(--new-tag-text);
    background-color: var(--new-tag-bg);
}

/* --- Alex 로고 원본 색상 유지 --- */
.alex-logo {
    /* 모든 필터 제거 */
    filter: none !important;
    -webkit-filter: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    
    /* 투명도 고정 */
    opacity: 1 !important;
    
    /* 브라우저의 자동 색상 반전 방지 */
    color-scheme: normal !important;
    
    /* 다크 모드에서도 색상 변경 방지 */
    color-adjust: exact !important;
    print-color-adjust: exact !important;
    -webkit-color-adjust: exact !important;
    
    /* 브라우저 기본 이미지 처리 방지 */
    image-rendering: auto !important;
    -webkit-image-rendering: auto !important;
    
    /* 크기 및 위치 유지 */
    height: 1.25rem !important;
    width: auto !important;
    display: inline-block !important;
    vertical-align: middle !important;
    
    /* 브라우저 강제 색상 변경 방지 */
    forced-color-adjust: none !important;
}

/* === 커스텀 모달 스타일 === */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* 라이트 테마 오버레이 */
body[data-theme="light"] .modal-overlay {
    background: rgba(0, 0, 0, 0.4);
}

.modal-overlay.show {
    opacity: 1;
}

.modal-content {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    min-width: 360px;
    max-width: 450px;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    position: relative;
}

/* 테마별 모달 그림자 */
body[data-theme="dark"] .modal-content,
body[data-theme="blue"] .modal-content {
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.8),
        0 0 0 1px rgba(255, 255, 255, 0.05);
}

body[data-theme="light"] .modal-content {
    box-shadow: 
        0 25px 50px -12px rgba(0, 0, 0, 0.15),
        0 10px 20px -5px rgba(0, 0, 0, 0.1),
        0 0 0 1px rgba(0, 0, 0, 0.05);
}

.modal-overlay.show .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    margin-bottom: 16px;
}

.modal-icon {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    color: var(--accent);
    flex-shrink: 0;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.modal-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    margin-bottom: 16px;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.modal-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.modal-input:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-primary);
}

/* 테마별 input focus 효과 */
body[data-theme="dark"] .modal-input:focus,
body[data-theme="blue"] .modal-input:focus {
    box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.15);
}

body[data-theme="light"] .modal-input:focus {
    box-shadow: 0 0 0 4px rgba(5, 150, 105, 0.15);
}

.modal-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 13px;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    letter-spacing: -0.01em;
    position: relative;
    overflow: hidden;
    min-width: 60px;
}

.modal-btn-cancel {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-color: var(--border-color);
}

.modal-btn-cancel:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent);
    transform: translateY(-1px);
}

.modal-btn-confirm {
    background: var(--accent);
    border-color: var(--accent);
    position: relative;
}

/* 테마별 확인 버튼 텍스트 색상 */
body[data-theme="dark"] .modal-btn-confirm,
body[data-theme="blue"] .modal-btn-confirm {
    color: #000000;
    font-weight: 700;
}

body[data-theme="light"] .modal-btn-confirm {
    color: #ffffff;
    font-weight: 600;
}

.modal-btn-confirm:hover:not(:disabled) {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

/* 테마별 확인 버튼 hover 그림자 */
body[data-theme="dark"] .modal-btn-confirm:hover:not(:disabled),
body[data-theme="blue"] .modal-btn-confirm:hover:not(:disabled) {
    box-shadow: 0 8px 25px rgba(45, 212, 191, 0.4);
}

body[data-theme="light"] .modal-btn-confirm:hover:not(:disabled) {
    box-shadow: 0 8px 25px rgba(5, 150, 105, 0.3);
}

.modal-btn-confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    filter: none;
    box-shadow: none;
}

/* 애니메이션 개선 */
@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}