:root {
  --primary-text-color: #222;
  --secondary-text-color: #fff;
  --primary-bg-color: #f7f7f7;
  --secondary-bg-color: #e8e8e8;
  --tertiary-bg-color: #d0d0d0;
  --button-bg-color: #75fead;
  --button-color: #0b0d11;
  --user-pill-bg-color: #aff5b4;
  --container-bg-color: #dcdcdc; /* Gray background */
}

@media (prefers-color-scheme: dark) {
  :root {
    --primary-text-color: #fff;
    --secondary-text-color: #000;
    --primary-bg-color: #1e1e1e;
    --secondary-bg-color: #2b2b2b;
    --tertiary-bg-color: #3e3e3e;
    --user-pill-bg-color: #287131;
    --container-bg-color: #2a2a2a;
  }
}

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

html, body {
  overflow-x: hidden; /* Prevent horizontal scroll */
}

body {
  font-family: 'Segoe UI', sans-serif;
  background-color: var(--primary-bg-color);
  color: var(--primary-text-color);
  height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background-color: #1f1f1f;
  color: #fff;
  text-align: center;
  padding: 0.75rem 0;
  font-size: 1rem;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.container {
  display: flex;
  flex: 1;
  margin: 1rem;
  background: var(--container-bg-color);
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: 0 4px 16px rgba(0,0,0,0.1);
  width: 100%; /* ✅ Full width without overflow */
}

aside {
  width: 220px;
  background-color: var(--secondary-bg-color);
  padding: 1rem;
  border-right: 1px solid #ccc;
  overflow-y: auto;
  max-height: 100vh;
}

aside h2 {
  font-size: 0.8rem;
  margin-bottom: 1rem;
}

aside ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

aside li {
  background-color: var(--user-pill-bg-color);
  padding: 0.4rem 1rem;
  border-radius: 999px;
  text-align: center;
  font-weight: 500;
  transition: transform 0.2s ease;
}

aside li:hover {
  transform: scale(1.05);
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem;
}

.tabs {
  display: flex;
  flex-direction: column;
  flex-wrap: wrap; /* ✅ Prevent horizontal overflow */
  width: 100%;
}

/* Hide unused tabs via dynamic class */
.tabs:not(.has-blg) .if-blg,
.tabs:not(.has-svc) .if-svc {
  display: none !important;
}

/* Hide radio buttons */
.tabs input[type="radio"] {
  display: none;
}

/* Style tab labels like pills */
.tabs label {
  display: inline-block;
  margin-right: 0.5rem;
  margin-bottom: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: var(--secondary-bg-color);
  color: var(--primary-text-color);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.3s;
}

/* Tab selected state */
.tabs input[type="radio"]:checked + label {
  background-color: var(--button-bg-color);
  color: var(--button-color);
  box-shadow: 0 0 0 2px var(--button-bg-color);
}

/* Tab content visibility */
.tab-content {
  display: none;
  padding: 1rem 0;
  flex: 1;
  overflow-y: auto; /* ✅ Keep vertical scroll */
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.tabs input[type="radio"]:checked + label + .tab-content {
  display: block;
}

/* Chat message styling */
.messages {
  display: flex;
  flex-direction: column-reverse;
  font-size: 0.8rem;
  font-weight: bold;
  gap: 1rem;
  max-height: 55vh;
  width: 100%;
  max-width: 100%; /* ✅ Prevent overflow */
  overflow-y: auto;
  box-sizing: border-box;
}

.messages > div {
  width: 100%; /* ✅ Fill available space */
  max-width: 100%; /* ✅ Never overflow parent */
  min-width: 10px; /* Optional minimum */
  padding: 1rem;
  background-color: var(--secondary-bg-color);
  border-radius: 1rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.1);
  box-sizing: border-box;
}

.messages time {
  float: right;
  font-size: 0.8rem;
  opacity: 0.6;
}

.messages .info {
  font-weight: 100;
  margin-right: 1rem;
}

.messages .op {
  background: var(--tertiary-bg-color);
  padding: 0.5rem;
  border-radius: 0.5rem;
  margin: 0.5rem 0;
}

.messages .op::before {
  content: "⮞ ";
}

.messages .pill {
  display: inline-block;
  background-color: var(--user-pill-bg-color);
  border-radius: 999px;
  padding: 0.3rem 0.8rem;
  margin: 0.3rem 0.5rem 0.3rem 0;
  font-size: 0.85rem;
  font-weight: bold;
}

.messages .text {
  font-size: 1rem;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Play button for audio */
button.play {
  padding: 0.5rem 1rem;
  background-color: var(--button-bg-color);
  color: var(--button-color);
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .container {
    flex-direction: column;
    border-radius: 0;
    margin: 0;
    width: 100%;
  }

  aside {
    width: 100%;
    border-right: none;
    border-bottom: 1px solid #ccc;
  }

  .tabs label {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
  }
}
