/* ==================================================
   VARIABEL WARNA
================================================== */

:root {
  --primary: #1f6548;
  --primary-dark: #164a35;
  --primary-light: #eaf3ee;

  --background: #f7faf8;
  --surface: #ffffff;

  --text-primary: #132019;
  --text-secondary: #68756e;

  --border: #d9e2dd;

  --shadow-small:
    0 4px 15px rgba(20, 50, 35, 0.07);

  --shadow-medium:
    0 10px 30px rgba(20, 50, 35, 0.11);
}


/* ==================================================
   PENGATURAN DASAR
================================================== */

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;

  font-family:
    "Segoe UI",
    Arial,
    sans-serif;

  background: var(--background);
  color: var(--text-primary);

  overflow: hidden;
}

button,
textarea {
  font-family: inherit;
}


/* ==================================================
   CONTAINER UTAMA
================================================== */

.app {
  width: 100%;
  height: 100vh;
  height: 100dvh;

  display: flex;
  flex-direction: column;

  background: var(--background);
}


/* ==================================================
   HEADER
================================================== */

.topbar {
  flex-shrink: 0;

  min-height: 72px;

  display: flex;
  align-items: center;

  gap: 16px;

  padding:
    10px
    clamp(18px, 3vw, 40px);

  background: var(--surface);

  border-bottom:
    1px solid var(--border);

  z-index: 30;
}


/* Logo dan nama aplikasi */

.brand {
  flex-shrink: 0;

  display: flex;
  align-items: center;

  gap: 11px;
}

.brand-logo {
  width: 42px;
  height: 42px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 13px;

  background: var(--primary);

  font-size: 23px;

  box-shadow:
    0 5px 14px
    rgba(31, 101, 72, 0.24);
}

.brand-text h1 {
  margin: 0;

  font-size: 17px;
  font-weight: 700;

  white-space: nowrap;
}

.brand-text p {
  margin: 3px 0 0;

  color: var(--text-secondary);

  font-size: 11px;
}


/* ==================================================
   KATEGORI DI HEADER
================================================== */

/*
  Sebelum pertanyaan dikirim,
  bagian ini belum ditampilkan.
*/

.header-suggestions {
  flex: 1;
  min-width: 0;

  display: none;
  align-items: center;
  justify-content: flex-end;
}


/*
  Setelah pertanyaan pertama dikirim
*/

.header-suggestions.active {
  display: flex;
}


/*
  Grid kategori dipindahkan dari welcome
  ke bagian kanan header
*/

.header-suggestions .suggestion-grid {
  width: auto;

  display: flex;
  align-items: center;
  justify-content: flex-end;

  gap: 7px;

  margin: 0;
}

.header-suggestions .suggestion-card {
  width: auto;
  min-width: 120px;
  min-height: 42px;

  display: flex;
  align-items: center;

  gap: 7px;

  padding: 6px 9px;

  border:
    1px solid var(--border);

  border-radius: 11px;

  background: var(--surface);
  color: var(--text-primary);

  box-shadow: none;

  white-space: nowrap;

  cursor: pointer;

  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

.header-suggestions .suggestion-card:hover {
  background: var(--primary-light);

  border-color: var(--primary);

  transform: translateY(-1px);
}

.header-suggestions .suggestion-icon {
  flex-shrink: 0;

  width: 31px;
  height: 31px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 9px;

  background: var(--primary-light);

  font-size: 16px;
}

.header-suggestions .suggestion-text {
  display: flex;
  flex-direction: column;
}

.header-suggestions .suggestion-text strong {
  font-size: 10px;
}

.header-suggestions .suggestion-text small {
  display: none;
}


/* ==================================================
   TOMBOL PERCAKAPAN BARU
================================================== */

.new-chat-button {
  flex-shrink: 0;

  min-height: 40px;

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 7px;

  padding: 9px 15px;

  border:
    1px solid var(--border);

  border-radius: 11px;

  background: var(--surface);
  color: var(--primary);

  font-size: 13px;
  font-weight: 600;

  cursor: pointer;

  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.2s ease;
}

.new-chat-button:hover {
  background: var(--primary-light);

  border-color: var(--primary);
}

.new-chat-button:active {
  transform: scale(0.97);
}

.new-chat-icon {
  font-size: 17px;
}


/* ==================================================
   AREA CHAT
================================================== */

.chat-box {
  flex: 1;

  width: 100%;

  padding:
    30px
    clamp(15px, 4vw, 45px)
    25px;

  overflow-y: auto;

  scroll-behavior: smooth;

  background: var(--background);
}

.chat-box.chat-active {
  padding-top: 16px;
}


/* Scrollbar */

.chat-box::-webkit-scrollbar {
  width: 7px;
}

.chat-box::-webkit-scrollbar-track {
  background: transparent;
}

.chat-box::-webkit-scrollbar-thumb {
  background: #c7d2cc;

  border-radius: 20px;
}

.chat-box::-webkit-scrollbar-thumb:hover {
  background: #aebcb4;
}


/* ==================================================
   WELCOME AWAL
================================================== */

.welcome-screen {
  width: 100%;
  max-width: 850px;

  min-height:
    calc(100dvh - 245px);

  margin: 0 auto;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  text-align: center;

  transition:
    min-height 0.3s ease,
    margin 0.3s ease,
    padding 0.3s ease;
}

.welcome-main {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.welcome-logo {
  width: 68px;
  height: 68px;

  display: flex;
  align-items: center;
  justify-content: center;

  margin-bottom: 18px;

  border-radius: 21px;

  background:
    linear-gradient(
      145deg,
      var(--primary),
      #378460
    );

  font-size: 38px;

  box-shadow:
    0 10px 27px
    rgba(31, 101, 72, 0.23);

  transition:
    width 0.3s ease,
    height 0.3s ease,
    margin 0.3s ease,
    font-size 0.3s ease;
}

.welcome-text h2 {
  margin: 0;

  font-size:
    clamp(26px, 4vw, 34px);

  font-weight: 750;

  letter-spacing: -0.5px;
}

.welcome-description {
  max-width: 660px;

  margin: 13px auto 26px;

  color: var(--text-secondary);

  font-size: 14px;
  line-height: 1.7;
}


/* ==================================================
   KARTU KATEGORI PADA WELCOME
================================================== */

.suggestion-grid {
  width: 100%;

  display: grid;

  grid-template-columns:
    repeat(2, minmax(0, 1fr));

  gap: 12px;
}

.suggestion-card {
  min-height: 70px;

  display: flex;
  align-items: center;

  gap: 12px;

  padding: 13px 14px;

  border:
    1px solid var(--border);

  border-radius: 14px;

  background: var(--surface);
  color: var(--text-primary);

  text-align: left;

  box-shadow: var(--shadow-small);

  cursor: pointer;

  transition:
    border-color 0.2s ease,
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.suggestion-card:hover {
  border-color: var(--primary);

  transform: translateY(-2px);

  box-shadow: var(--shadow-medium);
}

.suggestion-card:active {
  transform: scale(0.98);
}

.suggestion-icon {
  flex-shrink: 0;

  width: 40px;
  height: 40px;

  display: flex;
  align-items: center;
  justify-content: center;

  border-radius: 12px;

  background: var(--primary-light);

  font-size: 21px;
}

.suggestion-text {
  min-width: 0;

  display: flex;
  flex-direction: column;

  gap: 4px;
}

.suggestion-text strong {
  font-size: 13px;
}

.suggestion-text small {
  color: var(--text-secondary);

  font-size: 11px;
  line-height: 1.4;
}


/* ==================================================
   WELCOME SETELAH BERTANYA
================================================== */

/*
  Welcome tidak dihapus.
  Welcome hanya berubah menjadi panel kecil.
*/

.welcome-screen.compact {
  max-width: 900px;
  min-height: auto;

  align-items: stretch;

  margin: 0 auto 20px;

  padding: 12px 14px;

  background: var(--surface);

  border:
    1px solid var(--border);

  border-radius: 15px;

  text-align: left;

  box-shadow: var(--shadow-small);
}

.welcome-screen.compact .welcome-main {
  display: flex;
  flex-direction: row;
  align-items: center;

  gap: 11px;
}

.welcome-screen.compact .welcome-logo {
  flex-shrink: 0;

  width: 44px;
  height: 44px;

  margin: 0;

  border-radius: 13px;

  font-size: 23px;

  box-shadow:
    0 5px 15px
    rgba(31, 101, 72, 0.18);
}

.welcome-screen.compact .welcome-text {
  min-width: 0;
}

.welcome-screen.compact .welcome-text h2 {
  margin: 0;

  font-size: 16px;
}

.welcome-screen.compact .welcome-description {
  max-width: none;

  margin: 3px 0 0;

  font-size: 10px;
  line-height: 1.4;
}


/* ==================================================
   PESAN CHAT
================================================== */

.message {
  width: 100%;
  max-width: 900px;

  display: flex;

  margin: 0 auto 18px;
}

.message.user {
  justify-content: flex-end;
}

.message.bot {
  justify-content: flex-start;
}

.bubble {
  max-width: 76%;

  padding: 14px 17px;

  border-radius: 17px;

  font-size: 14px;
  line-height: 1.65;

  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.message.user .bubble {
  background: var(--primary);
  color: #ffffff;

  border-bottom-right-radius: 5px;

  box-shadow:
    0 5px 15px
    rgba(31, 101, 72, 0.18);
}

.message.bot .bubble {
  background: var(--surface);
  color: var(--text-primary);

  border:
    1px solid var(--border);

  border-bottom-left-radius: 5px;

  box-shadow: var(--shadow-small);
}

.message.bot .bubble.loading {
  color: var(--text-secondary);

  font-style: italic;
}


/* ==================================================
   KOLOM PERTANYAAN
================================================== */

.composer-area {
  flex-shrink: 0;

  width: 100%;

  padding:
    12px
    20px
    9px;

  background:
    linear-gradient(
      to top,
      var(--background) 80%,
      rgba(247, 250, 248, 0)
    );

  z-index: 20;
}

.composer {
  width: 100%;
  max-width: 900px;

  min-height: 54px;

  display: flex;
  align-items: flex-end;

  gap: 10px;

  margin: 0 auto;

  padding:
    6px
    7px
    6px
    16px;

  background: var(--surface);

  border:
    1.5px solid var(--primary);

  border-radius: 17px;

  box-shadow:
    0 7px 24px
    rgba(31, 101, 72, 0.09);

  transition:
    box-shadow 0.2s ease,
    border-color 0.2s ease;
}

.composer:focus-within {
  border-color: var(--primary-dark);

  box-shadow:
    0 8px 28px
    rgba(31, 101, 72, 0.16);
}

#questionInput {
  flex: 1;

  width: 100%;
  min-height: 39px;
  max-height: 150px;

  padding:
    10px
    0
    7px;

  border: none;
  outline: none;
  resize: none;

  background: transparent;
  color: var(--text-primary);

  font-size: 14px;
  line-height: 1.5;

  overflow-y: auto;
}

#questionInput::placeholder {
  color: #8b9891;
}

.send-button {
  flex-shrink: 0;

  width: 41px;
  height: 41px;

  display: flex;
  align-items: center;
  justify-content: center;

  border: none;
  border-radius: 12px;

  background: var(--primary);
  color: white;

  font-size: 17px;

  cursor: pointer;

  transition:
    background 0.2s ease,
    transform 0.2s ease;
}

.send-button:hover {
  background: var(--primary-dark);
}

.send-button:active {
  transform: scale(0.93);
}

.send-button:disabled {
  background: #9aa7a0;

  cursor: not-allowed;

  transform: none;
}

.footer-note {
  margin: 6px 0 0;

  color: var(--text-secondary);

  text-align: center;

  font-size: 9px;
}


/* ==================================================
   TABLET DAN LAPTOP KECIL
================================================== */

@media screen and (max-width: 1150px) {

  .topbar {
    flex-wrap: wrap;

    gap: 8px 14px;
  }

  .brand {
    order: 1;
  }

  .new-chat-button {
    order: 2;

    margin-left: auto;
  }

  /*
    Kategori turun ke baris kedua
    ketika layar tidak cukup lebar.
  */

  .header-suggestions.active {
    order: 3;

    flex: 0 0 100%;

    width: 100%;

    justify-content: flex-start;

    padding: 3px 0;

    overflow-x: auto;
  }

  .header-suggestions .suggestion-grid {
    width: max-content;
    min-width: max-content;

    justify-content: flex-start;
  }

  .header-suggestions .suggestion-card {
    min-width: 135px;
  }

}


/* ==================================================
   TABLET
================================================== */

@media screen and (max-width: 900px) {

  .topbar {
    padding-left: 17px;
    padding-right: 17px;
  }

  .chat-box {
    padding-left: 15px;
    padding-right: 15px;
  }

  .bubble {
    max-width: 85%;
  }

}


/* ==================================================
   HP
================================================== */

@media screen and (max-width: 600px) {

  .topbar {
    min-height: 62px;

    padding:
      8px
      10px;

    gap: 7px;
  }

  .brand {
    gap: 8px;
  }

  .brand-logo {
    width: 38px;
    height: 38px;

    border-radius: 11px;

    font-size: 21px;
  }

  .brand-text h1 {
    font-size: 13px;
  }

  .brand-text p {
    display: none;
  }


  /* Tombol percakapan baru HP */

  .new-chat-button {
    width: 40px;
    height: 40px;

    padding: 0;

    border-radius: 10px;
  }

  .new-chat-text {
    display: none;
  }

  .new-chat-icon {
    font-size: 21px;
  }


  /* Kategori di header HP */

  .header-suggestions.active {
    padding-bottom: 4px;

    scrollbar-width: none;
  }

  .header-suggestions.active::-webkit-scrollbar {
    display: none;
  }

  .header-suggestions .suggestion-grid {
    gap: 6px;
  }

  .header-suggestions .suggestion-card {
    min-width: 126px;
    min-height: 39px;

    padding: 5px 8px;
  }

  .header-suggestions .suggestion-icon {
    width: 29px;
    height: 29px;

    font-size: 14px;
  }

  .header-suggestions .suggestion-text strong {
    font-size: 9px;
  }


  /* Area chat HP */

  .chat-box {
    padding:
      16px
      10px
      15px;
  }


  /* Welcome awal HP */

  .welcome-screen {
    min-height: auto;

    padding:
      15px
      0
      18px;
  }

  .welcome-logo {
    width: 57px;
    height: 57px;

    margin-bottom: 13px;

    border-radius: 17px;

    font-size: 31px;
  }

  .welcome-text h2 {
    font-size: 23px;
  }

  .welcome-description {
    margin: 9px auto 18px;

    font-size: 12px;
    line-height: 1.55;
  }

  .suggestion-grid {
    grid-template-columns: 1fr;

    gap: 8px;
  }

  .suggestion-card {
    min-height: 61px;

    padding: 10px 11px;
  }

  .suggestion-icon {
    width: 38px;
    height: 38px;

    font-size: 19px;
  }


  /* Welcome kecil setelah bertanya */

  .welcome-screen.compact {
    margin-bottom: 14px;

    padding: 9px 10px;

    border-radius: 14px;
  }

  .welcome-screen.compact .welcome-main {
    gap: 9px;
  }

  .welcome-screen.compact .welcome-logo {
    width: 40px;
    height: 40px;

    border-radius: 12px;

    font-size: 21px;
  }

  .welcome-screen.compact .welcome-text h2 {
    font-size: 13px;
  }

  .welcome-screen.compact .welcome-description {
    font-size: 9px;
  }


  /* Bubble chat HP */

  .message {
    margin-bottom: 13px;
  }

  .bubble {
    max-width: 92%;

    padding: 11px 13px;

    border-radius: 14px;

    font-size: 12px;
    line-height: 1.55;
  }


  /* Kolom input HP */

  .composer-area {
    padding:
      8px
      9px
      7px;
  }

  .composer {
    min-height: 50px;

    padding:
      5px
      5px
      5px
      13px;

    border-radius: 15px;
  }

  #questionInput {
    min-height: 37px;
    max-height: 110px;

    padding:
      9px
      0
      6px;

    font-size: 13px;
  }

  .send-button {
    width: 38px;
    height: 38px;

    border-radius: 11px;

    font-size: 15px;
  }

  .footer-note {
    display: none;
  }

}


@media screen and (max-width: 370px) {

  .brand-text h1 {
    max-width: 175px;

    font-size: 11px;

    white-space: normal;
  }

  .welcome-text h2 {
    font-size: 20px;
  }

  .welcome-description {
    font-size: 11px;
  }

  .welcome-screen.compact .welcome-description {
    display: none;
  }

  .bubble {
    max-width: 95%;
  }

}