@font-face {
  font-family: "HYWenHei 85W";
  font-style: normal;
  font-weight: normal;
  src:
    local("HYWenHei-85W"),
    url("../../src/fonts/zhcn.woff") format("woff");
}

:root {
  --ui-scale: 1.0;
  --active-bg: none;
  
  /* Central Theme Colors */
  --bg-primary: #1e2235;
  --bg-secondary: #22283e;
  --bg-tertiary: #3d4655;
  --text-primary: #eceef5;
  --text-muted: #8b97b0;
  --accent-blue: #2196f3;
  
  /* Nation Thematic Colors */
  --color-mondstadt: #4abbbb;  /* Anemo green-blue */
  --color-liyue: #d8a032;      /* Geo gold */
  --color-inazuma: #af7cf0;    /* Electro purple */
  --color-sumeru: #5ab347;     /* Dendro green */
  --color-fontaine: #2b82f6;   /* Hydro blue */
  --color-natlan: #f15c3a;     /* Pyro orange-red */
  --color-snezhnaya: #8ab7e5;  /* Cryo light-blue */
  --color-nodkrai: #6c5ce7;    /* Deep Indigo/Void */
  --color-others: #a1a5b5;     /* Default greyish */
}

*, *::before, *::after {
  cursor: url(../../assets/cursor-small.png), auto !important;
}

html {
  font-size: calc(16px * var(--ui-scale, 1));
  cursor: url(../../assets/cursor-small.png), auto;
}

#background-pic {
  background-color: var(--bg-primary);
  background-image: var(--active-bg);
  background-size: cover;
  background-position: center;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: -10;
}

body {
  margin: 0;
  padding: 0;
  cursor: url(../../assets/cursor-small.png), auto;
  font-family: "HYWenHei 85W", Arial, sans-serif !important;

  background: #f2f2f2;
}

/* Loading animation */
/* copied from portfolio site ehe */

.loading {
  border: 8px solid #22283e;
  border-top: 8px solid #00000000; 
  border-radius: 50%;

  width: 60px;
  height: 60px;

  animation: spin 1s linear infinite;

  position: fixed;
  top: 45%;
  left: 50%;

  transform: translate(-50%, -50%);

  z-index: 999;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Reusable classes */

.hidden {
  display: none !important;
}

.flex {
  display: flex;
}

/* Container for the entire chatbox */
.chat-container {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 600px;
  border: none;
  background: none;
  display: flex;
  flex-direction: column;
}

@media (max-width: 600px) {
  .chat-container {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    border: none;
    background: none;
    display: flex;
    flex-direction: column;
  }
}

#container {
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  position: relative;
}

/* Header styling */
.chat-header {
  background: #22283e;
  color: #fff;
  padding: 20px;
  text-align: center;
  font-size: 20px;
}

.chat-header:hover {
  cursor: pointer;
  text-decoration: underline;
}

/* Messages area uses flex-grow */

/* 
  notes for background - linear gradient: 
  - need to blur the right part (the 100% part)
  - last gradient line (100%) should NOT be absolute zero
*/
#chat-messages {
  flex: 1 1 auto; /* Grow to fill, shrink to fit, basis auto */
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
  height:100%;
}

.chat-messages {
  flex: 1;
  padding: 10px 15px;
  word-wrap: break-word;
  font-size: 16px;
  background: linear-gradient(
    90deg,
    rgba(34, 40, 62, 1) 70%,
    rgba(34, 40, 62, 0.47) 85%,
    rgba(34, 40, 62, 0) 100%
  );
  flex-grow: 1;
  overflow-y: auto;
  width: 100%; /* ✅ ensures same width as header */
  max-width: 100%; /* ✅ override the 70% */
  height:100%; /* ✅ ensures it fills the remaining vertical space */
}

/* scroll bar for chat */

.chat-messages::-webkit-scrollbar {
  width: 5px;
  border-radius: 20px;
}

.chat-messages::-webkit-scrollbar-track {
  background-color: rgba(0, 0, 0, 0);
}

.chat-messages::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 20px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* Each message container */
.chat-message {
  margin: 0;
  display: flex;
  flex-direction: row; /* instead of column */
  align-items: flex-start; /* keeps image and bubble aligned */
  font-size: 15px;
}

/* Align sender messages to the right */
.chat-message.sender {
  align-items: flex-end;
  align-self: flex-end;
  justify-content: flex-end;
  color: #000;
}

/* Chat bubble styling for both sender and receiver */
.chat-bubble {
  max-width: 90%;
  padding: 10px 15px;
  border-radius: 20px;
  position: relative;
}

/* Specific style for sender bubble */
.chat-message.sender .chat-bubble {
  background: #d1c9c1;
  border-top-right-radius: 0;
}

/* Specific style for receiver bubble */
.chat-message.receiver .chat-bubble {
  background: #3d4655;
  color: white;
  border: none;
  border-top-left-radius: 0;
  /* user-select: none; */
}

/* Image of chat sender/receiver */
.chat-image {
  display: flex;

	min-height: 45px;
	max-height: 45px;

	min-width: 45px;
	max-width: 45px;

	border-radius: 50%;
  border: 2px solid #d1c9c1;

  background: #f3c19a;
  
  object-fit: cover; /* Ensures image covers the area without distortion */
  margin: 0 10px; /* Spacing between image and bubble */
}

/* Sender image alignment */
.chat-message.sender .chat-image {
	order: 2; /* Places image after the bubble */
}
/* Receiver image alignment */
.chat-message.receiver .chat-image {
	order: 0; /* Places image before the bubble */
}

/* Image of chat sender/receiver */
/* TBA : add image */

/* Sender */
.chat-image.sender {
	align-items: flex-end;
	align-self: flex-end;
}

/* Receiver */
.chat-image.receiver {
	align-items: flex-start;
  align-self: flex-start;
  justify-content: flex-start;
  background-color: #ffffff;
  color: #000;
}

/* for hiding input menu - reason: maximization of chat */

#toggleInputMenu {
  color: white;

  position: absolute;
  bottom: 6px;
  left: 6px;

  border: 0;

  background-color: none;

  width: 100%;

  display: flex;
  justify-content: flex-start; /* Aligns to the left side cleanly without covering content */

  padding: 5px 10px;
  box-sizing: border-box;
}

#chatInputLower.chat-input {
  border: 0;
  padding: 8px;
}

#toggleInputBtn {
  position: relative; /* Removes it from any accidental absolute overlays */
  background-color: #3d4655;
  color: #ffffff;
  border: 1px solid #525c6c;
  border-radius: 4px;
  padding: 4px 12px;
  font-size: 12px;
  z-index: 10; /* Keeps it layered cleanly without intersecting baseline input fields */
  transition: background-color 0.2s;
  cursor: pointer;
  margin: 0;
}

#toggleInputBtn:hover {
  background-color: #2196f3;
}

/* Input area styling */
.chat-input {
  padding: 12px 5px 0;
  border-top: 1px solid #ccc;
  display: flex;
  align-items: center;
  background: #22283e;
  flex-shrink: 0; /* Prevents them from being squished when messages grow */
  min-height: 35px;
  justify-content: space-between; /* ✅ spread input + buttons */
}

.chat-input input {
  flex: 1;
  padding: 10px;
  border: 1px solid #ccc;
  font-size: 15px;
  border-radius: 20px;
  outline: none;

  font-family: "HYWenHei 85W", Arial, sans-serif !important;
}

.chat-input button {
  margin: 0 7px;
  padding: 10px 15px;
  border: none;
  background: #fff;
  color: #3d4655;
  border-radius: 20px;
  cursor: pointer;

  font-family: "HYWenHei 85W", Arial, sans-serif !important;
}

.chat-input button:disabled {
  color: #ccc;
  background: #666;
  cursor: not-allowed;

}

.chat-input #settings {
  position: absolute;
  right: 10px;
  font-size: 26px;
  color: white;
  cursor: pointer;

  background: none;
  border:none;
}

#chatInputUpper {
  margin-top: 5px;
}

/* for switch */

.center {
  display: flex;
  justify-content: center;
  align-items: center;
}

.switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 20px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: 0.4s;
  transition: 0.4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 14px;
  width: 14px;
  left: 4px;
  bottom: 3px;
  background-color: white;
  -webkit-transition: 0.4s;
  transition: 0.4s;
}

input:checked + .slider {
  background-color: #2196f3;
}

input:focus + .slider {
  box-shadow: 0 0 1px #2196f3;
}

input:checked + .slider:before {
  -webkit-transform: translateX(18px);
  -ms-transform: translateX(18px);
  transform: translateX(18px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

#toggleChat {
  color: white;

}

/* for floating window */

/* Modal overlay covers entire viewport */
.floating-window {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5); /* Semi-transparent black */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

/* Floating window content */
.floating-content {
  display: flex;
  flex-direction: column;

  background: #22283e;
  color: white;
  padding: 20px;
  border-radius: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  min-width: 400px;
  width: 40%;
  max-width: 60%; /* Responsive width */
  max-height: 90%; /* Responsive height */
  position: relative;
  overflow-y: auto; /* Scroll if content exceeds window size */
  /* overflow: hidden; */
}

/* Close button styling */
.close-button {
  display: flex;
  flex-direction: row-reverse;

  padding: 0;
  margin: 0;
  background: none;
  border: none;
  font-size: 28px;
  color: #bbb;
  cursor: pointer;
}

.close-button:hover {
  color: white;
}

.chat-input .charlist input {
  font-size: 17px;
  min-height: fit-content;
}

.charlist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-top: 12px;
}

.custom-character-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  margin-bottom: 10px;
}

.custom-character-section input[type="text"] {
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #3d4655;
  color: white;
}

.custom-character-section button {
  padding: 8px;
  background: #2196f3;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

#receiver-list,
#sender-list {
  height: 220px;
  overflow-y: auto;
}

.character-list-item {
  display: block; /* Make each character a block element */
  width: 100%;
  padding: 10px;
  margin-bottom: 5px;
  background-color: var(--bg-tertiary, #3d4655);
  color: white;
  border: none;
  border-left: 4px solid transparent;
  border-radius: 5px;
  text-align: left;
  cursor: pointer;
  transition: background 0.2s ease, border-left-color 0.2s ease, transform 0.1s ease;
  font-family: "HYWenHei 85W", Arial, sans-serif !important;
}

.character-list-item:hover, .character-list-item.selected {
  background-color: var(--accent-blue, #2196f3); /* Default Highlight */
  border-left-color: white;
}

/* Region-specific hover colors */
.character-list-item[data-region="Mondstadt"]:hover,
.character-list-item[data-region="Mondstadt"].selected {
  background: linear-gradient(135deg, rgba(74, 187, 187, 0.2), rgba(74, 187, 187, 0.5));
  border-left-color: var(--color-mondstadt);
}

.character-list-item[data-region="Liyue"]:hover,
.character-list-item[data-region="Liyue"].selected {
  background: linear-gradient(135deg, rgba(216, 160, 50, 0.2), rgba(216, 160, 50, 0.5));
  border-left-color: var(--color-liyue);
}

.character-list-item[data-region="Inazuma"]:hover,
.character-list-item[data-region="Inazuma"].selected {
  background: linear-gradient(135deg, rgba(175, 124, 240, 0.2), rgba(175, 124, 240, 0.5));
  border-left-color: var(--color-inazuma);
}

.character-list-item[data-region="Sumeru"]:hover,
.character-list-item[data-region="Sumeru"].selected {
  background: linear-gradient(135deg, rgba(90, 179, 71, 0.2), rgba(90, 179, 71, 0.5));
  border-left-color: var(--color-sumeru);
}

.character-list-item[data-region="Fontaine"]:hover,
.character-list-item[data-region="Fontaine"].selected {
  background: linear-gradient(135deg, rgba(43, 130, 246, 0.2), rgba(43, 130, 246, 0.5));
  border-left-color: var(--color-fontaine);
}

.character-list-item[data-region="Natlan"]:hover,
.character-list-item[data-region="Natlan"].selected {
  background: linear-gradient(135deg, rgba(241, 92, 58, 0.2), rgba(241, 92, 58, 0.5));
  border-left-color: var(--color-natlan);
}

.character-list-item[data-region="Snezhnaya"]:hover,
.character-list-item[data-region="Snezhnaya"].selected {
  background: linear-gradient(135deg, rgba(138, 183, 229, 0.2), rgba(138, 183, 229, 0.5));
  border-left-color: var(--color-snezhnaya);
}

.character-list-item[data-region="Nod-Krai"]:hover,
.character-list-item[data-region="Nod-Krai"].selected {
  background: linear-gradient(135deg, rgba(108, 92, 231, 0.15), rgba(45, 0, 85, 0.6));
  border-left-color: var(--color-nodkrai);
}
/* for tabs, sending and receiving */

.tab-buttons {
  display: flex;
}

.tab-button {
  flex: 1;
  padding: 15px 0;
  text-align: center;
  cursor: pointer;
  font-weight: bold;
  font-family: "HYWenHei 85W" !important;
  color: #000000;

  transition: background-color 0.3s ease, color 0.3s ease;

  border-bottom: 3px solid #2196f3;
}

/* need to fix color */
.tab-button:hover {
  background-color: #d0eaff;
  color: rgb(138, 138, 138);
}

.tab-button.active {
  background-color: #2196f3;
  color: #000000;

  border: 3px solid #2196f3;
  border-bottom: none;
}

.tab-content-container {
  display: flex;
  flex-direction: column;
  
  border-top: none;

  overflow: hidden;
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden !important; /* Force block overflow off the tab layer completely */
  border: none;
  min-height: 0;
}

/* Safely position the toggle layout row */
div#toggleInputMenu {
  display: flex !important;
  justify-content: flex-start;
  width: 100%;
  padding: 4px 8px;
  background: transparent;
  box-sizing: border-box;
}

/* for credits */

/* Container for the credits content inside the tab */
.credits-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 15px 10px;
  box-sizing: border-box;
  min-height: 0;
}

.text-center {
  text-align: center;
}

.credits-wrapper h3 {
  margin-bottom: 5px;
  color: white; /* Change to match your text colors */
}

.credits-section {
  margin-bottom: 20px;
}

.credits-section h4 {
  margin-bottom: 8px;
  color: white;
  font-size: 1.1rem;
}

.credits-list {
  padding-left: 20px;
  margin: 0;
}

.credits-wrapper ul {
  padding-left: 20px;
  margin-bottom: 15px;
}

.credits-wrapper li {
  margin-bottom: 12px;
  line-height: 1.5;
  color: #dedede;
}

.credits-divider {
  border: 0;
  border-top: 1px solid #ddd;
  margin: 15px 0;
}

/* Optional: Style your links to match a Genshin UI color palette */
.credits-section a {
  color: #0076f6; 
  text-decoration: none;
}

.credits-section a:hover {
  text-decoration: underline;
}

.funny-subtext {
  display: block;
  font-size: 0.85rem;
  color: #9a9a9a; /* Subtle gray so it feels like a cheeky footnote */
  margin-top: 3px;
  margin-bottom: 5px;
}
.credits-role {
  margin: 5px 0;
  line-height: 1.4;
}

/* ========== ACTION LINES & MESSAGE CONTROLS ========== */

/* Action Lines */
.action-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px auto;
  font-size: 0.9em;
  color: #666;
  text-align: center;
  animation: fadeIn 0.3s ease-in;
  max-width: 90%;
}

.action-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.action-text {
  font-weight: 500;
}

#actionModeLabel {
  color: white;
}

/* Message Hover Controls */
.message-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  max-width: calc(100% - 65px);
}

.chat-message.sender .message-wrapper {
  align-items: flex-end;
}

.message-name {
  font-size: 0.8em;
  color: #666;
  margin: 0 5px;
}

.bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

.chat-message.sender .bubble-row {
  justify-content: flex-end;
}

.message-controls {
  display: none;
  gap: 4px;
  animation: fadeIn 0.2s ease-in;
  background: rgba(0, 0, 0, 0.7);
  padding: 4px;
  border-radius: 4px;
}

.message-wrapper:hover .message-controls,
.action-line:hover .message-controls {
  display: flex;
}

.control-btn {
  background: none;
  border: none;
  font-size: 1em;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  transition: background-color 0.2s ease, transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.control-btn:hover {
  background-color: rgba(255, 255, 255, 0.2);
  transform: scale(1.1);
}

.control-btn:active {
  transform: scale(0.95);
}

.edited-tag {
  font-size: 0.75em;
  color: #999;
  margin-left: 4px;
  font-style: italic;
}

.bubble-content {
  display: flex;
  align-items: center;
  gap: 4px;
}

@keyframes fadeIn {
  from { 
    opacity: 0; 
  }
  to { 
    opacity: 1; 
  }
}

/* Settings Controls Styles */
.settings-group {
  margin-bottom: 20px;
  padding: 10px;
  background-color: var(--bg-tertiary, #3d4655);
  border-radius: 8px;
  color: var(--text-primary, #eceef5);
}

.settings-group label {
  display: block;
  font-weight: bold;
  margin-bottom: 8px;
  font-size: 0.9em;
  color: var(--text-muted, #8b97b0);
  text-transform: uppercase;
}

.switcher-control {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg-secondary, #22283e);
  border-radius: 6px;
  padding: 5px;
}

.switcher-btn {
  background-color: var(--bg-tertiary, #3d4655);
  color: white;
  border: none;
  padding: 8px 15px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
  transition: background-color 0.2s, transform 0.1s;
}

.switcher-btn:hover {
  background-color: var(--accent-blue, #2196f3);
}

.switcher-btn:active {
  transform: scale(0.95);
}

#currentBgLabel, #fontScaleLabel {
  font-size: 0.9em;
  text-align: center;
  flex: 1;
  -webkit-user-select: none;
  user-select: none;
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message {
  animation: slideIn 0.3s ease-out;
}

/* ========== SETTINGS ========== */

.settings-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 15px 0;
}

.clear-btn {
  padding: 12px 16px;
  background: #e74c3c;
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: "HYWenHei 85W", Arial, sans-serif !important;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.clear-btn:hover {
  background: #c0392b;
  transform: translateY(-2px);
}

.clear-btn:active {
  transform: translateY(0);
}

.clear-btn.export-btn {
  background: #08e600;
}

.clear-btn.export-btn:hover {
  background: #06b900;
}