/* prevent horizontal layout shift due to scrollbar */
html, body {
  overflow-y: scroll;
}

body {
    margin: 0;
    padding: 0;
    font-family: 'Noto Sans KR', sans-serif;
    background: #FFF3E0;
    color: #222;
}
.container {
    display: flex;
    height: 100vh;
}
.sidebar {
    width: 80px;
    background: linear-gradient(180deg, #FFE0B2 0%, #FFCC80 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
    box-shadow: 1px 0 8px #FFD180;
}
.logo {
    font-size: 2rem;
    font-weight: bold;
    color: #FF9800;
    margin-bottom: 40px;
    letter-spacing: 2px;
}
.menu {
    width: 100%;
}
.menu ul {
    list-style: none;
    padding: 0;
    margin: 0;
}
.menu-item {
    padding: 18px 0;
    text-align: center;
    cursor: pointer;
    color: #333;
    font-size: 1.1rem;
    transition: background 0.2s, color 0.2s;
}
.menu-item.active, .menu-item:hover {
    background: #FFF3E0;
    color: #FF9800;
    font-weight: bold;
}
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #FFF3E0;
    min-width: 0;
}
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 24px 0 24px;
    background: transparent;
    height: 60px;
}
.page-title {
    font-size: 1.3rem;
    font-weight: bold;
}
.login-btn {
    background: none;
    border: 1px solid #b2b2b2;
    border-radius: 16px;
    padding: 6px 18px;
    color: #00b6f0;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}
.login-btn:hover {
    background: #e6f7ff;
}
.page {
    display: none;
    flex: 1;
    flex-direction: column;
    height: 100%;
}
.page.active {
    display: flex;
}
/* 채팅 화면 */
.page-chat {
    justify-content: center;
    align-items: center;
    position: relative;
}
.chat-center {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-y: auto;
    max-height: calc(100vh - 200px);
    padding: 20px;
    width: 100%;
    max-width: min(800px, calc(95vw - 80px)); /* 메인 사이드바(80px) 고려 */
}
.chat-logo-wrapper {
    position: relative;
    width: 100px;
    height: 100px;
    margin-bottom: 10px;
}
.chat-logo {
    width: 100px;
    height: 100px;
    background: radial-gradient(circle, #FF9800 70%, #FFE0B2 100%);
    border-radius: 50%;
    box-shadow: 0 0 16px #FFD180;
    position: relative;
    z-index: 1;
}
.chat-title {
    font-size: 2rem;
    font-weight: 700;
    color: #222;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    z-index: 2;
    pointer-events: none;
    writing-mode: initial;
    text-align: center;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-subtitle {
    font-size: 0.9rem;
    color: #888;
    text-align: center;
    margin-top: 8px;
}
.chat-input-wrapper {
    width: 700px;
    max-width: calc(95vw - 80px); /* 메인 사이드바(80px) 고려 */
    display: flex;
    flex-direction: column;
    align-items: center;
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}
.chat-input-area {
    display: flex;
    align-items: center;
    background: #fff;
    border-radius: 24px;
    box-shadow: 0 2px 8px #FFD180;
    padding: 8px 16px;
    width: 100%;
    max-width: 100%;
}
.chat-input {
    flex: 1;
    border: none;
    outline: none;
    font-size: 1rem;
    padding: 8px 10px;
    background: #fff;
    color: #222;
    resize: none;
    min-height: 32px;
    max-height: 160px;
    line-height: 1.5;
    box-sizing: border-box;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.chat-input:empty:before {
    content: attr(data-placeholder);
    color: #bbb;
    pointer-events: none;
}
.chat-plus, .chat-hash, .chat-send {
    background: none;
    border: none;
    font-size: 1.2rem;
    margin-left: 8px;
    cursor: pointer;
    color: #FF9800;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    transition: background 0.2s;
}
.chat-send:disabled {
    color: #FF9800;
    cursor: not-allowed;
}
.footer {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 18px;
    font-size: 0.95rem;
    color: #b2b2b2;
}
/* 도구 화면 */
.page-tools {
    padding: 24px 32px 0 32px;
    flex-direction: column;
    align-items: flex-start;
}
.tools-header {
    display: flex;
    align-items: center;
    width: 100%;
    margin-bottom: 18px;
}
.tools-title {
    font-size: 1.2rem;
    font-weight: bold;
    margin-right: 24px;
}
.tools-filters {
    display: flex;
    gap: 10px;
}
.filter-btn {
    background: #fff;
    border: 1px solid #FFE0B2;
    border-radius: 16px;
    padding: 6px 16px;
    color: #FF9800;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}
.filter-btn.active, .filter-btn:hover {
    background: #FFCC80;
    color: #FF9800;
    font-weight: bold;
}
.tools-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 18px;
    width: 100%;
}
.tool-card {
    position: relative;
    background: #FFF8E1;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 8px #FFE0B2;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid transparent;
}
.tool-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px #FFD180;
    border-color: #FFB74D;
}
.tool-card.selected {
    border-color: #ff6b4a;
    background: linear-gradient(135deg, #fff6f3 0%, #fff 100%);
    box-shadow: 0 4px 20px rgba(255, 107, 74, 0.2);
}
.tool-card:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px #ffe0d3;
}
.tool-title {
    font-size: 1.1rem;
    font-weight: bold;
    color: #222;
}
.tool-desc {
    font-size: 0.98rem;
    color: #666;
}
.tool-fav {
    position: absolute;
    top: 14px;
    right: 14px;
    font-size: 1.2rem;
    color: #FFD6C2;
    cursor: pointer;
    transition: color 0.2s;
}
.tool-fav.active {
    color: #FF9800;
}
@media (max-width: 900px) {
    .tools-list {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    }
    .chat-input-wrapper {
        width: calc(95vw - 80px); /* 메인 사이드바 고려 */
        min-width: 0;
    }
    .chat-input-area {
        width: 100%;
        min-width: 0;
    }
    .image-preview-area {
        width: 100%;
        min-width: 0;
    }
    
    /* 모바일에서 파일 사이드바 너비 축소 */
    .file-sidebar {
        width: 200px;
    }
    
    .page-chat.has-file-sidebar .chat-center {
        left: calc(50% + 100px); /* 축소된 파일 사이드바(200px)의 절반만큼 이동 */
        max-width: calc(95vw - 280px); /* 메인 사이드바(80px) + 파일 사이드바(200px) 고려 */
        transform: translate(-50%, -50%);
    }
    
    .page-chat.has-file-sidebar .chat-input-wrapper {
        left: calc(50% + 100px); /* 축소된 파일 사이드바(200px)의 절반만큼 이동 */
        max-width: calc(95vw - 280px); /* 메인 사이드바(80px) + 파일 사이드바(200px) 고려 */
        width: calc(100% - 200px); /* 축소된 파일 사이드바 영역 제외 */
        transform: translateX(-50%);
    }
}

/* 아주 작은 화면에서 추가 여백 확보 */
@media (max-width: 600px) {
    .chat-input-wrapper {
        width: calc(90vw - 80px); /* 더 많은 여백 확보 */
        max-width: calc(90vw - 80px);
    }
    
    /* 작은 화면에서 파일 사이드바 더 축소 */
    .file-sidebar {
        width: 180px;
    }
    
    .page-chat.has-file-sidebar .chat-center {
        left: calc(50% + 90px); /* 더 축소된 파일 사이드바(180px)의 절반만큼 이동 */
        max-width: calc(90vw - 260px); /* 메인 사이드바(80px) + 파일 사이드바(180px) 고려 */
        transform: translate(-50%, -50%);
    }
    
    .page-chat.has-file-sidebar .chat-input-wrapper {
        left: calc(50% + 90px); /* 더 축소된 파일 사이드바(180px)의 절반만큼 이동 */
        max-width: calc(90vw - 260px); /* 메인 사이드바(80px) + 파일 사이드바(180px) 고려 */
        width: calc(100% - 180px); /* 더 축소된 파일 사이드바 영역 제외 */
        transform: translateX(-50%);
    }
}
/* 채팅 메시지 스타일 */
.chat-message {
    margin: 10px 0;
    padding: 10px 15px;
    border-radius: 15px;
    max-width: 80%;
    word-wrap: break-word;
    position: relative;
}

.user-message {
    background-color: #007bff;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 5px;
}

.bot-message {
    background-color: #FFF7ED; /* 주 배경 톤과 어울리는 밝은 주황 계열 */
    color: #333;
    margin-right: auto;
    border-bottom-left-radius: 5px;
    border: 1px solid #FFE0B2;
}

.message-content {
    margin-bottom: 5px;
    line-height: 1.4;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    text-align: right;
}

.user-message .message-time {
    text-align: left;
}

/* 로딩 애니메이션 */
@keyframes typing {
    0%, 20% { opacity: 0; }
    50% { opacity: 1; }
    100% { opacity: 0; }
}

.bot-message.loading .message-content::after {
    content: '...';
    animation: typing 1.5s infinite;
}

/* 이미지 미리보기 영역 */
.image-preview-area {
    margin-bottom: 8px;
    width: 100%;
    max-width: 100%;
}
.image-preview-box {
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border: 1px solid #eee;
    border-radius: 12px;
    padding: 8px 12px;
    position: relative;
    min-width: 120px;
    max-width: 220px;
    box-shadow: 0 2px 8px #ffe0d3;
}
.image-preview-thumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 8px;
    margin-right: 10px;
    background: #fff;
    border: 1px solid #eee;
}
.image-preview-info {
    display: flex;
    flex-direction: column;
    font-size: 0.95rem;
    color: #444;
}
.image-preview-name {
    font-weight: 500;
    margin-bottom: 2px;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.image-preview-size {
    font-size: 0.85rem;
    color: #888;
}
.image-preview-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #fff0ee;
    border: none;
    color: #FF9800;
    font-size: 1.1rem;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.image-preview-remove:hover {
    background: #FF9800;
    color: #fff;
}
/* 도구 채팅 헤더 */
.tool-chat-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 16px;
    box-shadow: 0 2px 12px rgba(255, 107, 74, 0.1);
}
.tool-chat-title {
    font-size: 1.4rem;
    font-weight: bold;
    color: #FF9800;
    margin-bottom: 8px;
}
.tool-chat-desc {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
}
.progress-bar {
    width: 60px;
    height: 6px;
    background: #eee;
    border-radius: 3px;
    margin-top: 6px;
    overflow: hidden;
}
.progress-bar-inner {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #FF9800 0%, #FFD6C2 100%);
    animation: progressBarAnim 1s linear infinite;
}
@keyframes progressBarAnim {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
} 
.model-toggle-group {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-right: 8px;
}
.model-toggle-btn {
    background: #FFE0D3;
    border: 1.5px solid #FFD6C2;
    color: #FF9800;
    font-weight: 500;
    border-radius: 16px;
    padding: 4px 16px;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border 0.2s;
    outline: none;
}
.model-toggle-btn.active,
.model-toggle-btn:focus {
    background: #FF9800;
    color: #fff;
    border: 1.5px solid #FF9800;
}
.model-toggle-btn:hover:not(.active) {
    background: #FFD6C2;
    color: #FF9800;
} 
.external-iframe {
    width: 100%;
    height: 100%;
    border: none;
} 

/* iframe 모드 시 채팅 영역 전체 확장 */
.chat-center.iframe-mode {
    position: absolute;
    top: 0;
    left: 0;
    transform: none;
    width: 100%;
    max-width: none;
    height: 100%;
    padding: 0;
} 

/* 파일 사이드바 */
.file-sidebar {
    position: absolute;
    left: 0;
    top: 0;
    width: 240px;
    height: 100%;
    background: #fff8ef;
    border-right: 1px solid #ffd6c2;
    overflow-y: auto;
    z-index: 3;
}
.file-sidebar-header {
    padding: 12px;
    font-weight: bold;
    border-bottom: 1px solid #ffd6c2;
}
.file-list {
    list-style: none;
    margin: 0;
    padding: 0;
}
.file-list li {
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #ffe8d5;
    display:flex;
    justify-content: space-between;
    align-items:center;
}
.file-del-btn{
    background:none;
    border:none;
    color:#ff6b4a;
    cursor:pointer;
    font-size:1rem;
}

/* (추가) 긴 파일명도 버튼이 가려지지 않도록 처리 */
.file-list li span{
    flex:1 1 auto;          /* 남는 공간을 차지하면서 필요하면 축소 */
    min-width:0;            /* flex-shrink 가 동작하도록 최소폭 0 */
    overflow:hidden;        /* 넘치는 텍스트 숨김 */
    text-overflow:ellipsis; /* 말줄임표 표시 */
    white-space:nowrap;     /* 한 줄 유지 */
}
.file-list li:hover { background: #fff1e6; }

/* 파일 슬라이드 팝업 */
.file-slide {
    position: fixed;
    left: 240px; /* 옆 사이드바 너비 */
    bottom: -60%;
    width: calc(100% - 240px);
    height: 60%;
    background: #ffffff;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
    overflow-y: auto;
    transition: bottom 0.3s ease;
    z-index: 4;
    padding: 16px;
}
.file-slide.show { bottom: 0; } 
.file-progress {
    padding:8px 12px;
    color:#aaa;
    font-style:italic;
}
@keyframes pulseProgress {
    0% { opacity: 0.3; }
    50% { opacity: 1; }
    100% { opacity: 0.3; }
}
.file-progress {
    animation: pulseProgress 1.5s infinite;
} 
.file-slide-close {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 6px; /* 팝업 내부 상단 */
    width: 32px;
    height: 32px;
    background: #fff;
    border: 2px solid #ff6b4a;
    border-radius: 50%;
    font-size: 1.3rem;
    line-height: 28px;
    text-align: center;
    cursor: pointer;
    color: #ff6b4a;
    font-weight: bold;
    z-index: 5;
}
.file-slide-close:hover { background:#ff6b4a; color:#fff; }
.file-slide-content {
    white-space: pre-wrap;
    font-family: "Noto Sans KR", sans-serif;
} 

/* PDF 로딩 오버레이 */
.file-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    color: #ff6b4a;
    font-style: italic;
    z-index: 4; /* iframe 위에 표시 */
    animation: pulseProgress 1.5s infinite;
} 

/* --- Sidebar fixed width to prevent layout shift --- */
.file-sidebar {
  flex: 0 0 240px;
}
.file-sidebar .file-list li {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
} 

/* --- Community page adjustments --- */
.page-community {
    overflow-y: visible; /* use outer body scrollbar only */
    overflow-x: hidden;
}
.page-community.active {
    display: block !important; /* show only when active; override .page.active flex */
}
#community-img { display:none; }

/* 커뮤니티 내부 레이아웃 */
.community-container { display:flex; height:100%; }
.community-sidebar { width:180px; background:#fff8ef; border-right:1px solid #ffd6c2; }
.community-sidebar ul{ list-style:none; margin:0; padding:0; }
.community-menu-item{ padding:12px 18px; cursor:pointer; color:#333; font-size:1rem; }
.community-menu-item.active,.community-menu-item:hover{ background:#fff1e6; color:#ff9800; font-weight:bold; }
.community-content{ flex:1; overflow-y:auto; } 
.newsletter-list{ list-style:none; margin:0; padding:0 0 0 20px; }
.newsletter-list li{ padding:6px 0; }
.newsletter-list a{ color:#007acc; text-decoration:none; font-size:1rem; }
.newsletter-list a:hover{ text-decoration:underline; }
.newsletter-title{ margin:16px 0 8px 20px; font-size:1.4rem; }
.newsletter-content-area{ height: calc(100% - 56px); /* adapt below title */ }
.newsletter-pdf-wrapper{ position:relative; height:100%; }
.newsletter-iframe{ width:100%; height:100%; border:none; }
.newsletter-close{ position:absolute; top:-16px; left:50%; transform:translateX(-50%); width:32px; height:32px; background:#fff; border:2px solid #ff6b4a; border-radius:50%; font-size:1.3rem; line-height:26px; text-align:center; color:#ff6b4a; cursor:pointer; z-index:5; }
.newsletter-close:hover{ background:#ff6b4a; color:#fff; } 

/* Lecture styles */
.lecture-title{ margin:16px 0 8px 20px; font-size:1.4rem; }
.lecture-topic{ margin:8px 0 12px 20px; font-size:1.2rem; color:#555; }
.lecture-video-list{ display:flex; flex-wrap:wrap; gap:12px; padding:0 0 0 20px; }
.lecture-video{ width:140px; display:block; }
.lecture-video img{ width:100%; border-radius:8px; box-shadow:0 2px 6px rgba(0,0,0,0.1); }
.lecture-video:hover img{ transform:scale(1.03); transition:transform .2s; } 

/* QnA board */
.qna-title-head{ margin:16px 0 8px 20px; font-size:1.4rem; }
.qna-table{ width:calc(100% - 40px); margin:0 20px; border-collapse:collapse; }
.qna-table th,.qna-table td{ border-bottom:1px solid #eee; padding:10px; text-align:left; }
.qna-table th{ background:#fff8ef; font-weight:600; color:#333; }
.qna-table tr:hover td{ background:#fff1e6; }
.qna-title{ color:#007acc; cursor:pointer; }
.qna-title:hover{ text-decoration:underline; }

/* Document Translation styles */
.download-original-link,
.download-result-link {
    color: #007acc;
    text-decoration: none;
    font-weight: bold;
    margin-right: 6px;
    padding: 2px 6px;
    border-radius: 4px;
    border: 1px solid #007acc;
    font-size: 0.8rem;
    display: inline-block;
}
.download-original-link:hover,
.download-result-link:hover {
    background: #007acc;
    color: #fff;
    text-decoration: none;
}
.download-original-link {
    background-color: #f8f9fa;
    border-color: #6c757d;
    color: #6c757d;
}
.download-original-link:hover {
    background-color: #6c757d;
    color: #fff;
}
.translating {
    color: #ff6b4a;
    font-weight: bold;
    margin-right: 8px;
    font-size: 0.8rem;
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* File item layout for translation results */
.file-list li.translation-result-item {
    display: block !important;
    align-items: initial !important;
    justify-content: initial !important;
}
.file-item-content {
    width: 100%;
}
.original-file {
    font-weight: bold;
    color: #333;
    margin-bottom: 2px;
    font-size: 0.9rem;
}
.result-file {
    color: #666;
    font-size: 0.85rem;
    margin-bottom: 4px;
    font-style: italic;
}
.file-actions {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-wrap: wrap;
}
.file-actions .download-original-link,
.file-actions .download-result-link {
    margin-right: 0;
}
.file-actions .file-del-btn {
    margin-left: auto;
}

/* 파일 사이드바가 있을 때 채팅 영역 조정 */
.page-chat.has-file-sidebar .chat-center {
    left: calc(50% + 120px); /* 파일 사이드바 넓이(240px)의 절반만큼 오른쪽으로 이동 */
    max-width: calc(95vw - 320px); /* 메인 사이드바(80px) + 파일 사이드바(240px) 고려 */
    transform: translate(-50%, -50%); /* 중앙 정렬 유지 */
}

.page-chat.has-file-sidebar .chat-input-wrapper {
    left: calc(50% + 120px); /* 파일 사이드바 넓이(240px)의 절반만큼 오른쪽으로 이동 */
    max-width: calc(95vw - 320px); /* 메인 사이드바(80px) + 파일 사이드바(240px) 고려 */
    width: calc(100% - 240px); /* 파일 사이드바 영역 제외 */
    transform: translateX(-50%); /* 중앙 정렬 유지 */
} 