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

body {
    font-family: Arial, sans-serif;
    background: #0f1117;
    color: #e8eaf0;
}

.main {
    width: min(100% - 30px, 900px);
    margin: 40px auto;
}

/* =========================
   AI CARDS
========================= */

.ai-card {
    background: #171a21;
    padding: 25px;
    border-radius: 15px;
    margin-bottom: 25px;

    border: 1px solid #272c36;

    box-shadow:
        0 8px 25px rgba(0, 0, 0, 0.25);
}

.ai-card h1,
.ai-card h2 {
    color: #ffffff;
    margin-bottom: 8px;
}

.subtitle {
    color: #9ca3af;
    margin-bottom: 20px;
}

/* =========================
   INPUTS
========================= */

input,
select {
    width: 100%;

    padding: 13px 15px;

    margin-bottom: 15px;

    background: #101319;
    color: #e8eaf0;

    border: 1px solid #303641;
    border-radius: 8px;

    font-size: 15px;

    outline: none;
}

input::placeholder {
    color: #777f8e;
}

input:focus,
select:focus {
    border-color: #6366f1;

    box-shadow:
        0 0 0 2px rgba(99, 102, 241, 0.15);
}

/* Dropdown */

select option {
    background: #171a21;
    color: #e8eaf0;
}

/* =========================
   BUTTON
========================= */

button {
    width: 100%;

    padding: 13px 15px;

    border: none;
    border-radius: 8px;

    background: #6366f1;
    color: white;

    font-size: 15px;
    font-weight: bold;

    cursor: pointer;

    transition: 0.2s ease;
}

button:hover {
    background: #5558e8;
}

button:active {
    transform: scale(0.99);
}

/* =========================
   AI RESPONSE
========================= */

.response-container {
    margin-top: 25px;
}

.ai-response {
    background: #171a21;

    padding: 25px;

    border-radius: 15px;

    border: 1px solid #272c36;

    line-height: 1.7;

    color: #dfe3ea;

    box-shadow:
        0 8px 25px rgba(0, 0, 0, 0.25);

    overflow-wrap: break-word;
}

.ai-response h2 {
    color: #ffffff;
    margin: 20px 0 10px;
}

.ai-response h3 {
    color: #c7c9ff;
    margin: 18px 0 8px;
}

.ai-response h4 {
    color: #b5b8ff;
    margin: 15px 0 7px;
}

.ai-response ul {
    margin: 10px 0 15px;
    padding-left: 25px;
}

.ai-response li {
    margin-bottom: 7px;
}

.ai-response strong {
    color: #ffffff;
}

/* =========================
   LOADING
========================= */

.loading {
    text-align: center;
    padding: 35px;
    color: #9ca3af;
}

.loader {
    width: 35px;
    height: 35px;

    margin: 0 auto 15px;

    border: 4px solid #2b303a;
    border-top: 4px solid #6366f1;

    border-radius: 50%;

    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* =========================
   ERROR
========================= */

.error {
    padding: 15px;

    border-radius: 8px;

    background: #2a171a;

    border: 1px solid #57252a;

    color: #ff8585;

    font-weight: 500;
}

/* =========================
   MOBILE
========================= */

@media (max-width: 600px) {

    .main {
        width: calc(100% - 20px);
        margin: 20px auto;
    }

    .ai-card {
        padding: 18px;
        border-radius: 12px;
    }

    .ai-response {
        padding: 18px;
        font-size: 14px;
        line-height: 1.6;
    }
}
/* ================================
USTAD CHAT — TOGGLE BUTTON
================================ */

#ustadToggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: #00a884;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  z-index: 1100;
  transition: transform 0.2s ease;
}

#ustadToggle:hover {
  transform: scale(1.08);
}

/* ================================
CHAT WINDOW
================================ */

#ustadWindow {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 500px;
  height: 600px;
  background: #0b141a; /* WhatsApp dark mode chat background */
  border-radius: 14px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transform: translateY(20px);
  color: #e9edef;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  z-index: 1100;
}

#ustadWindow.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* ================================
HEADER
================================ */

.ustad-header {
  background: #202c33; /* WhatsApp dark header */
  color: #e9edef;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid #2a3942;
}

.ustad-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #00a884;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.ustad-header-info {
  flex: 1;
  line-height: 1.3;
}

.ustad-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: #e9edef;
}

.ustad-status {
  font-size: 0.75rem;
  color: #8696a0;
}

.ustad-close {
  cursor: pointer;
  font-size: 16px;
  opacity: 0.8;
  padding: 4px;
  color: #aebac1;
}

.ustad-close:hover {
  opacity: 1;
}

/* ================================
MESSAGES AREA
================================ */

.ustad-messages {
  flex: 1;
  padding: 14px 10px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #0b141a;
  /* subtle repeating pattern feel without an image asset */
  background-image: radial-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 18px 18px;
}

.ustad-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
}

.ustad-msg.user {
  align-self: flex-end;
  align-items: flex-end;
}

.ustad-msg.bot {
  align-self: flex-start;
  align-items: flex-start;
}

.bubble {
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.88rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.3);
}

.ustad-msg.user .bubble {
  background: #005c4b; /* WhatsApp dark-mode outgoing green */
  color: #e9edef;
  border-top-right-radius: 2px;
}

.ustad-msg.bot .bubble {
  background: #1f2c34; /* WhatsApp dark-mode incoming grey */
  color: #e9edef;
  border-top-left-radius: 2px;
}

.ustad-time {
  font-size: 0.68rem;
  color: #8696a0;
  margin-top: 2px;
  padding: 0 4px;
}

.ustad-msg.typing .bubble {
  font-style: italic;
  color: #8696a0;
}

/* --- Code blocks inside AI responses --- */

.bubble pre {
  background: #0a0f13;
  color: #d1d7db;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 0.8rem;
  line-height: 1.5;
  border: 1px solid #2a3942;
}

.bubble code {
  font-family: "Courier New", monospace;
}

.bubble p code, .bubble li code {
  background: rgba(255, 255, 255, 0.08);
  color: #d1d7db;
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ================================
INPUT ROW
================================ */

.ustad-input-row {
  display: flex;
  align-items: center;
  padding: 8px;
  background: #202c33; /* WhatsApp dark input bar */
  gap: 8px;
  border-top: 1px solid #2a3942;
}

.ustad-input-row input {
  flex: 1;
  padding: 10px 14px;
  border: none;
  color: #e9edef;
  font-family: "Poppins", sans-serif;
  border-radius: 20px;
  outline: none;
  font-size: 1rem;
  background: #2a3942; /* WhatsApp dark input pill */
}

.ustad-input-row input::placeholder {
  color: #8696a0;
}

.ustad-input-row button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #00a884;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.ustad-input-row button:hover {
  background: #06cf9c;
}

/* ================================
FORMATTED AI RESPONSE ELEMENTS
================================ */

.bubble strong {
  font-weight: 700;
  color: #ffffff;
}

.bubble em {
  font-style: italic;
}

.bubble h4 {
  font-size: 0.95rem;
  margin: 10px 0 4px 0;
  color: #06cf9c;
}

.bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 0.8rem;
}

.bubble th,
.bubble td {
  border: 1px solid #2a3942;
  padding: 4px 8px;
  text-align: left;
}

.bubble th {
  background: #202c33;
  color: #e9edef;
  font-weight: 600;
}

.bubble td {
  color: #d1d7db;
}

/* ================================
RESPONSIVE — MOBILE
================================ */

@media (max-width: 500px) {
  #ustadWindow {
    width: 92vw;
    height: 70vh;
    bottom: 84px;
    right: 4vw;
  }
}

@media (max-width: 460px) {
  #ustadWindow {
    width: 60vw;
    height: 70vh;
    bottom: 84px;
    right: 4vw;
  }
}

/* ================================
AI RESPONSE — TABLES & HR
(add to css/ai.css)
================================ */

#ai-response table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
  font-size: 0.9rem;
  background: rgba(126, 203, 218, 0.04);
  border-radius: 10px;
  overflow: hidden;
}

#ai-response th,
#ai-response td {
  border: 1px solid rgba(126, 203, 218, 0.25);
  padding: 10px 14px;
  text-align: left;
  color: #e9edef;
}

#ai-response th {
  background: rgba(126, 203, 218, 0.15);
  color: #7ecbda;
  font-weight: 600;
}

#ai-response tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

#ai-response hr {
  border: none;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(126, 203, 218, 0.4), transparent);
  margin: 24px 0;
}

#ai-response em {
  font-style: italic;
  color: #c9e7fb;
}