/* 테마 변수 정의 */
:root[data-theme="dark"] {
  --bg-primary: rgb(10, 10, 10);
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #121212;
  --bg-card: #222222;
  --bg-message: #212121;

  --border-primary: #262626;

  --text-primary: white;
  --text-secondary: oklch(0.708 0 0);
  --text-tertiary: oklch(0.5 0 0);
  --text-highlight: rgb(209, 209, 209);

  --icon-bg: white;
  --icon-stroke: black;

  --overlay-bg: rgba(0, 0, 0, 0.5);
  --hover-brightness: 2.2;
}

:root[data-theme="light"] {
  --bg-primary: rgb(250, 250, 250);
  --bg-secondary: #ffffff;
  --bg-tertiary: #f5f5f5;
  --bg-card: #e8e8e8;
  --bg-message: #f0f0f0;

  --border-primary: #e0e0e0;

  --text-primary: #0a0a0a;
  --text-secondary: oklch(0.5 0 0);
  --text-tertiary: oklch(0.6 0 0);
  --text-highlight: rgb(60, 60, 60);

  --icon-bg: #0a0a0a;
  --icon-stroke: white;

  --overlay-bg: rgba(0, 0, 0, 0.3);
  --hover-brightness: 0.95;
}

/* 기본 테마 설정 (다크) */
:root {
  --bg-primary: rgb(10, 10, 10);
  --bg-secondary: #0a0a0a;
  --bg-tertiary: #121212;
  --bg-card: #222222;
  --bg-message: #212121;

  --border-primary: #262626;

  --text-primary: white;
  --text-secondary: oklch(0.708 0 0);
  --text-tertiary: oklch(0.5 0 0);
  --text-highlight: rgb(209, 209, 209);

  --icon-bg: white;
  --icon-stroke: black;

  --overlay-bg: rgba(0, 0, 0, 0.5);
  --hover-brightness: 2.2;
}

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

body {
  width: 100%;
  height: 100vh;
  background: var(--bg-primary);
  color: var(--text-primary);
}

.container {
  width: 98%;
  max-width: 850px;
  margin: 0 auto;
}

button {
  cursor: pointer;
}

/* 헤더 */

header {
  width: 100%;
  border-bottom: 1px solid var(--border-primary);
  padding: 15px 0;
  .container {
    display: flex;
    justify-content: space-between;
  }
  .header_logo {
    display: flex;
    align-items: center;
  }
  .header_logo_svg {
    background: var(--icon-bg);
    border-radius: 10px;
    width: 38px;
    height: 38px;
    display: flex;
    justify-content: center;
    align-items: center;
  }
  svg {
    margin: 0;
    padding: 0;
    fill: var(--icon-bg);
    stroke: var(--icon-stroke);
  }
  .header_logo_text {
    display: flex;
    flex-direction: column;
    margin-left: 10px;
    h1 {
      font-size: 20px;
    }
    p {
      font-size: 12px;
      color: var(--text-secondary);
    }
  }
  .header_right {
    display: flex;
    align-items: center;
    gap: 15px;
  }
  .setting_div {
    button {
      padding: 8px;
      background: none;
      border: 1px solid var(--border-primary);
      border-radius: 5px;
      font-size: 14px;
      color: var(--text-primary);
      svg {
        stroke: var(--text-primary);
      }
    }
  }
  .header_newchat {
    button {
      padding: 8px 13px;
      background: none;
      border: 1px solid var(--border-primary);
      color: var(--text-primary);
      border-radius: 5px;
      font-size: 14px;
    }
  }
}

/* 메인 */
#main {
  width: 100%;
  height: calc(100vh - 240px);
  display: flex;
  justify-content: center;
  align-items: center;
  .container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 25px;
    height: 100%;
  }
  .main_welcome_svg {
    width: 80px;
    height: 80px;
    background: var(--bg-card);
    border-radius: 15px;
    display: flex;
    justify-content: center;
    align-items: center;
    svg {
      width: 40px;
      height: 40px;
    }
  }
  .main_welcome_text {
    display: flex;
    flex-direction: column;
    gap: 5px;
    h1 {
      font-size: 24px;
    }
    p {
      font-size: 16px;
      color: var(--text-secondary);
    }
  }
  .main_welcome_autocomplete {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    .autocomplete_btn {
      padding: 13px 15px;
      background: var(--bg-secondary);
      border: 1px solid var(--border-primary);
      border-radius: 8px;
      font-size: 14px;
      color: var(--text-primary);
      flex: 0 1 calc(50% - 5px);
      text-align: left;
      transition: 0.2s ease;
    }
    .autocomplete_btn:hover {
      filter: brightness(var(--hover-brightness));
    }
  }
}

/* 푸터 */
footer {
  width: 100%;
  position: static;
  bottom: 0;
  border-top: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  .container {
    display: flex;
    flex-direction: column;
    padding: 10px 0;
  }
  .input_div {
    display: flex;
    width: 100%;
    justify-content: space-around;
    padding: 10px;
    border: 1px solid var(--border-primary);
    border-radius: 10px;
    background: var(--bg-secondary);
  }
  textarea {
    resize: none;
    width: 93%;
    min-height: 40px;
    outline: none;
    color: var(--text-primary);
    border: 0;
    background: var(--bg-secondary);
    font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS",
      sans-serif;
  }
  button {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: none;
  }
  .footer_disclaimer {
    text-align: center;
    font-size: 12px;
    color: var(--text-tertiary);
    margin: 0 auto;
    margin-top: 10px;
  }
}

/* 채팅 */
#chat {
  width: 100%;
  height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 10px;
  padding: 20px 0;
  .me {
    width: 100%;
    display: flex;
    justify-content: flex-end;
    span {
      background: var(--bg-message);
      padding: 8px 15px;
      border-radius: 10px;
      text-align: left;
      max-width: 500px;
    }
  }
  .ai {
    width: 100%;
    display: flex;
    justify-content: flex-start;
    text-align: left;
    span {
      display: inline-block;
      width: 100%;
      max-width: 500px;
    }
  }
}

/* 모달창 */
#modal_overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 900;
  background: var(--overlay-bg);
}

#modal {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  width: 90%;
  transform: translate(-50%, -50%);
  max-width: 400px;
  background: var(--bg-tertiary);
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  flex-direction: column;
  gap: 15px;
  z-index: 1000;
  text-align: center;
}

#modal button {
  padding: 10px 13px;
  background: none;
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  border-radius: 5px;
  font-size: 14px;
}

#modal h1 {
  font-size: 20px;
}

#modal p {
  font-size: 14px;
  color: var(--text-secondary);
  span {
    color: var(--text-highlight);
    font-size: 15px;
    font-weight: 700;
  }
}

/* Model_select */
.model_div {
  position: relative;
}

#model_btn {
  width: auto;
  min-width: 120px;
  height: 35px;
  display: flex;
  justify-content: space-between; /* 변경 */
  align-items: center;
  gap: 5px;
  padding: 0 12px; /* 패딩 증가 */
  background: none;
  border: 1px solid var(--border-primary);
  color: var(--text-primary);
  border-radius: 5px;
  font-size: 14px;
  transition: all 0.2s ease;
  white-space: nowrap; /* 추가 */
  svg {
    margin: 0;
    padding: 0;
  }
}

#model_btn:hover {
  background-color: var(--bg-tertiary);
}

/* 마지막 svg만 회전하도록 수정 */
#model_btn svg:last-child {
  transition: transform 0.2s ease;
}

#model_btn.active svg:last-child {
  transform: rotate(180deg);
}

#model_select_div {
  display: none;
  flex-direction: column;
  position: absolute;
  top: calc(100% + 5px);
  left: 0;
  min-width: 120px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-primary);
  border-radius: 5px;
  overflow: hidden;
  z-index: 1001;
  padding: 5px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  opacity: 0;
  transform: translateY(-10px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

#model_select_div.active {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

#model_select_div button {
  width: 100%;
  padding: 8px 13px;
  background: none;
  border: none;
  border-radius: 5px;
  text-align: left;
  color: var(--text-primary);
  font-size: 14px;
  transition: background-color 0.2s;
}

#model_select_div button:hover {
  background: var(--bg-tertiary);
}

/* setting modal */

#setting_modal {
  display: none;
  width: 90%;
  max-width: 500px;
  z-index: 1002;
  background: var(--bg-tertiary);
  height: auto;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  border-radius: 10px;
}

.setting_header {
  width: 100%;
  border-bottom: 1px solid var(--border-primary);
  padding: 15px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  h1 {
    font-size: 20px;
    color: var(--text-primary);
  }
  svg {
    cursor: pointer;
    margin: 0;
    padding: 0;
    width: 26px;
    height: 26px;
  }
}

.setting_main {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 15px;
  overflow-y: auto;
  max-height: 300px;
}

.setting_section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting_section_title {
  display: flex;
  align-items: center;
  gap: 10px;
  h2 {
    font-size: 20px;
    color: var(--text-primary);
  }
  svg {
    margin: 0;
    padding: 0;
    width: 16px;
    height: 16px;
    stroke: var(--text-secondary);
  }
}

.bi-moon {
  fill: var(--text-secondary);
}

.setting_section_box {
  display: flex;
  flex-direction: column;
  gap: 8px;
  h3 {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 400;
  }
  .theme_btn {
    width: 49%;
    height: 80px;
    background: var(--bg-card);
    color: var(--text-primary);
    stroke: var(--text-primary);
    fill: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    border: none;
    border-radius: 8px;
    gap: 3px;
  }
}

.active_btn {
  border: 2px solid var(--text-primary) !important;
}

.setting_section_box_btndiv {
  display: flex;
  justify-content: space-between;
}

#System {
  width: 100%;
  height: 82px;
  padding: 8px 12px;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-primary);
  outline: none;
  border-radius: 5px;
  resize: none;
  font-family: "Gill Sans", "Gill Sans MT", Calibri, "Trebuchet MS", sans-serif;
}

@media (max-width: 530px) {
  .main_welcome_text {
    h1 {
      font-size: 16px !important;
    }
    p {
      font-size: 10px;
    }
  }
  .main_welcome_svg {
    width: 60px !important;
    height: 60px !important;
    svg {
      width: 30px !important;
      height: 30px !important;
    }
  }
  #modal p {
    font-size: 12px !important;
    span {
      font-size: 13px !important;
    }
  }
}

@media (max-width: 390px) {
  .main_welcome_autocomplete .autocomplete_btn {
    flex: 1 1 100% !important;
    min-width: 0 !important;
  }
}

.limit {
  width: 100%;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding-top: 10px;
  color: var(--text-secondary);
}

.setting_section_box_data {
  display: flex;
  flex-direction: column;
}

.setting_section_box_data p {
  font-size: 12px;
  color: var(--text-secondary);
}

.setting_section_box_data button {
  width: 120px;
  height: 30px;
  margin-bottom: 5px;
  border: 0;
  border-radius: 5px;
  background: rgb(238, 69, 69);
  color: white;
}
