@import url("https://fonts.googleapis.com/css2?family=Gowun+Dodum&display=swap");

/* ===== 무채색 + 슬림 사이드바 (텍스트 메뉴) =====
   index.html / app.js 는 수정 불필요. 이 파일만 교체하면 됩니다. */
:root {
    --bg: #ffffff;
    --side: #f5f5f5;
    --text: #1a1a1a;
    --muted: #8a8a8a;
    --line: #dcdcdc;
    --soft: #f4f4f4;
    --accent: #0b4a36;          /* 주 버튼/사용자 말풍선: 딥그린 */
    --accent-hover: #0f6048;
    --green: #0b4a36;        /* 딥그린 */
    --glass: rgba(255, 255, 255, .30);   /* 입력/내용 칸 투명도 (숫자↓ = 더 투명) */
    --green-soft: rgba(11, 74, 54, .10);
}

html { font-size: 17px; }   /* 기본 글씨 크기 아주 조금 키움 (16px → 17px) */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Pretendard', Roboto, 'Noto Sans KR', sans-serif;
    color: var(--text);
    height: 100vh;
    background-color: #fff9e3;        /* 따뜻한 크림 옐로 */
    background-image:
        /* 모서리 4곳 (작고 은은하게) */
        radial-gradient(circle 280px at 0 0,       rgba(11, 74, 54, .26), transparent 75%),
        radial-gradient(circle 280px at 100% 0,    rgba(11, 74, 54, .26), transparent 75%),
        radial-gradient(circle 280px at 0 100%,    rgba(11, 74, 54, .26), transparent 75%),
        radial-gradient(circle 280px at 100% 100%, rgba(11, 74, 54, .26), transparent 75%),
        /* 가운데 큰 글로우 */
        radial-gradient(circle 720px at 50% 50%, rgba(11, 74, 54, .48), rgba(11, 74, 54, .14) 55%, transparent 80%);
    background-attachment: fixed;
}

/* 전체: [사이드바 | 본문] 한 덩어리를 화면 가운데에 배치.
   제목·입력칸·푸터는 모두 "본문 열(2열)"의 가운데를 기준축으로 정렬 */
.container {
    --col: 840px;                      /* 본문 폭 (제목/입력칸 공통 기준) */
    display: grid;
    grid-template-columns: 96px minmax(0, 1fr);
    grid-template-rows: auto 1fr auto;
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    height: 100vh;
}

/* ---- 상단 제목: 본문 열 가운데 ---- */
header {
    grid-column: 2;
    grid-row: 1;
    text-align: right;                 /* 제목+로고를 오른쪽(입력칸 오른쪽 끝선)에 정렬 */
    padding: 32px max(24px, calc((100% - var(--col)) / 2)) 20px;
    background: transparent;
}
header h1 .logo { width: 2.3em; height: 2.3em; flex: none; }   /* 로고는 글씨보다 크게 */
header h1 { display: flex; align-items: center; justify-content: flex-end; gap: 10px; font-family: 'Gowun Dodum', 'Noto Sans KR', sans-serif; font-size: 1.35em; font-weight: 400; -webkit-text-stroke: 1.2px currentColor; letter-spacing: 0; margin-bottom: 0; color: var(--green); }
header p  { display: none; }   /* 챗봇 설명 숨김 */

/* ---- 사이드바: 칸 없이 글씨만, 본문 바로 왼쪽 ---- */
.tabs {
    grid-column: 1;
    grid-row: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 0 0 40px;
    background: transparent;
    border-right: none;
}

/* 아이콘 버튼: 원래 글씨/이모지는 숨기고 SVG 아이콘만 표시 */
.tab-button {
    position: relative;
    width: 52px;
    height: 52px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: none;
    cursor: pointer;
    font-size: 0;                      /* 버튼 안 텍스트 숨김 */
    color: #5f6b66;
    transition: background .15s, color .15s;
}
.tab-button::before {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 26px;
    height: 26px;
    background-color: currentColor;
    -webkit-mask: var(--icon) center / contain no-repeat;
            mask: var(--icon) center / contain no-repeat;
}
.tab-button[data-tab="chat"]       { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a8 8 0 0 1-11.5 7.2L4 20.5l1.4-4.6A8 8 0 1 1 21 12z'/%3E%3C/svg%3E"); }
.tab-button[data-tab="multimodal"] { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='16' rx='3'/%3E%3Ccircle cx='9' cy='10' r='1.8'/%3E%3Cpath d='M21 16l-5-5-8 8'/%3E%3C/svg%3E"); }
.tab-button[data-tab="web"]        { --icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='12' cy='12' r='9'/%3E%3Cpath d='M3 12h18M12 3c2.8 2.6 4 5.6 4 9s-1.2 6.4-4 9c-2.8-2.6-4-5.6-4-9s1.2-6.4 4-9z'/%3E%3C/svg%3E"); }

.tab-button:hover { background: var(--green-soft); color: var(--green); }
.tab-button.active { background: var(--green-soft); color: var(--green); font-weight: 400; }

/* 마우스를 올리면 오른쪽에 이름 표시 */
.tab-button::after {
    position: absolute;
    left: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    padding: 6px 12px;
    border-radius: 8px;
    background: var(--green);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity .15s;
    z-index: 10;
}
.tab-button[data-tab="chat"]::after       { content: "채팅"; }
.tab-button[data-tab="multimodal"]::after { content: "멀티모달"; }
.tab-button[data-tab="web"]::after        { content: "웹 요약"; }
.tab-button:hover::after, .tab-button:focus-visible::after { opacity: 1; }

footer {
    grid-column: 2;
    grid-row: 3;
    padding: 14px 20px;
    text-align: center;
    font-size: 0.75em;
    color: var(--muted);
    background: transparent;
}

/* ---- 본문 영역: 모든 내용이 같은 폭(--col), 같은 가운데 축 ---- */
.tab-content {
    display: none;
    grid-column: 2;
    grid-row: 2;
    min-height: 0;
    padding: 8px 24px 24px;
    overflow-y: auto;
    background: transparent;
}
.tab-content.active { display: flex; }
.tab-content > div { margin: auto; width: 100%; max-width: var(--col); }

/* 채팅 */
.chat-container { display: flex; flex-direction: column; height: 100%; }

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: var(--glass);
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    border: 1px solid var(--line);
    border-radius: 12px;
    margin-bottom: 16px;
}

.message {
    margin-bottom: 14px;
    padding: 12px 16px;
    border-radius: 12px;
    max-width: 80%;
    word-wrap: break-word;
}
.message.user { background: var(--accent); color: #fff; margin-left: auto; text-align: right; }
.message.assistant { background: rgba(255,255,255,.55); color: var(--text); border: 1px solid var(--line); }

.message-header { font-weight: 600; margin-bottom: 5px; font-size: 0.85em; }
.message-content { line-height: 1.6; }
.usage-info { font-size: 0.8em; color: var(--muted); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line); }
.message.user .usage-info { color: #bbb; border-top-color: #444; }

.chat-input-container { display: flex; gap: 10px; }
.chat-input-container input {
    flex: 1; padding: 12px 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--glass);
    font-size: 1em; outline: none; transition: border-color .2s;
}
.chat-input-container input:focus { border-color: var(--accent); }
.chat-input-container button {
    padding: 12px 22px; background: var(--accent); color: #fff; border: none;
    border-radius: 10px; cursor: pointer; font-weight: 600; transition: background .2s;
}
.chat-input-container button:hover { background: var(--accent-hover); }
.chat-input-container button:last-child { background: var(--glass); color: var(--green); border: 1px solid var(--green); }
.chat-input-container button:last-child:hover { background: var(--green-soft); }
.chat-input-container button:active { transform: scale(0.98); }

/* 멀티모달 / 웹 요약: 한 줄로 쌓고 가운데 정렬 */
.multimodal-container,
.web-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-section { display: flex; flex-direction: column; gap: 14px; }

/* 멀티모달: 이미지 삽입칸이 위, 프롬프트 입력칸이 아래 */
.multimodal-container .file-upload-section { order: 1; }
.multimodal-container .input-section textarea { order: 2; }
.multimodal-container .button-group { order: 3; }

.input-section textarea {
    padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--glass);
    font-size: 1em; font-family: inherit; resize: vertical; outline: none;
}
.input-section textarea:focus { border-color: var(--accent); }

.file-upload-section { display: flex; flex-direction: column; gap: 10px; }
.file-label {
    padding: 14px; background: var(--glass); border: 1px dashed #aaa; border-radius: 10px;
    cursor: pointer; text-align: center; font-weight: 600; color: var(--text); transition: background .2s;
}
.file-label:hover { background: #e6e6e6; }
.file-upload-section input[type="file"] { display: none; }

.image-preview { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; margin-top: 6px; }
.image-preview-item { position: relative; width: 100px; height: 100px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); }
.image-preview-item img { width: 100%; height: 100%; object-fit: cover; filter: grayscale(.2); }
.image-preview-item .remove-btn {
    position: absolute; top: 5px; right: 5px; background: rgba(0,0,0,.75); color: #fff;
    border: none; border-radius: 50%; width: 24px; height: 24px; cursor: pointer; font-size: 14px;
}

.button-group { display: flex; gap: 10px; }
.button-group button {
    flex: 1; padding: 12px; border: none; border-radius: 10px; font-size: 1em;
    font-weight: 600; cursor: pointer; transition: all .2s;
}
.button-group button:first-child { background: var(--accent); color: #fff; }
.button-group button:first-child:hover { background: var(--accent-hover); }
.button-group button:last-child { background: var(--glass); color: var(--green); border: 1px solid var(--green); }
.button-group button:last-child:hover { background: var(--green-soft); }

.multimodal-response,
.web-response {
    padding: 20px; background: var(--glass); border: 1px solid var(--line);
    border-radius: 12px; line-height: 1.8;
}
.multimodal-response:empty,
.web-response:empty { display: none; }
.multimodal-response { max-height: 45vh; overflow-y: auto; }

.web-container input[type="url"] {
    padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--glass); font-size: 1em; outline: none;
}
.web-container input[type="url"]:focus { border-color: var(--accent); }
.web-container button {
    padding: 12px 24px; background: var(--accent); color: #fff; border: none;
    border-radius: 10px; font-size: 1em; font-weight: 600; cursor: pointer; transition: background .2s;
}
.web-container button:hover { background: var(--accent-hover); }

.loading { text-align: center; padding: 20px; color: var(--muted); }
.error { background: #f0f0f0; color: #222; padding: 15px; border-radius: 8px; border-left: 4px solid #222; }

/* 스크롤바 */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #bdbdbd; border-radius: 4px; }

/* 모바일: 사이드바를 상단 가로 메뉴로 */
@media (max-width: 768px) {
    .container { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr auto; height: auto; min-height: 100vh; }
    header, footer, .tab-content { grid-column: 1; }
    header { grid-row: 1; padding: 16px 16px 8px; }
    header h1 { font-size: 1.1em; }
    header p { display: none; }
    .tabs { grid-column: 1; grid-row: 2; flex-direction: row; justify-content: center; gap: 4px; padding: 6px; border-right: none; border-bottom: 1px solid var(--line); }
    .tab-button { width: 48px; height: 48px; }
    .tab-button::after { left: 50%; top: calc(100% + 6px); transform: translateX(-50%); }
    .tab-content { grid-row: 3; padding: 16px; }
    footer { grid-row: 4; }
    .chat-container { height: 65vh; }
    .message { max-width: 92%; }
}

/* 초기화 버튼 → 새로고침(리로드) 아이콘 */
#chat-clear-btn, #multimodal-clear-btn {
    position: relative;
    flex: none;
    width: 48px;
    padding: 0;
    font-size: 0;                       /* "초기화" 글씨 숨김 */
}
#chat-clear-btn::before, #multimodal-clear-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 22px;
    height: 22px;
    background-color: currentColor;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 1 1-3.2-6.9L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3C/svg%3E") center / contain no-repeat;
            mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 12a9 9 0 1 1-3.2-6.9L21 8'/%3E%3Cpath d='M21 3v5h-5'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: transform .4s;
}
#chat-clear-btn:hover::before, #multimodal-clear-btn:hover::before { transform: rotate(180deg); }

