@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

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

body {
  font-family: 'Roboto', sans-serif;
  background: #0a0e1a;
  color: #d4dce8;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  gap: 16px;
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(0, 120, 160, 0.1) 0%, transparent 60%),
    radial-gradient(ellipse at 70% 80%, rgba(0, 80, 130, 0.08) 0%, transparent 60%);
}

.chat-container {
  width: 400px;
  max-width: 100%;
  height: 700px;
  max-height: 90vh;
  background: linear-gradient(180deg, #161a30 0%, #0e1220 50%, #111528 100%);
  border-radius: 18px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  box-shadow:
    0 0 30px rgba(0, 100, 180, 0.1),
    0 20px 40px rgba(0, 0, 0, 0.5);
}

/* Border gradient */
.chat-container::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 18px;
  padding: 1.5px;
  background: linear-gradient(180deg,
    rgba(70, 85, 150, 0.5) 0%,
    rgba(40, 55, 85, 0.3) 50%,
    rgba(55, 65, 130, 0.45) 100%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
  z-index: 10;
}

/* ── Header ── */
.chat-header {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(18, 24, 42, 0.8);
  border-bottom: 1px solid rgba(50, 70, 130, 0.25);
  flex-shrink: 0;
}

.chat-header .logo {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(37, 99, 235, 0.2);
  border: 1.5px solid rgba(37, 99, 235, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: #5588ff;
}

.chat-header .header-text h1 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #d4dce8;
}

.chat-header .header-text p {
  font-size: 11px;
  color: #556688;
  margin-top: 2px;
}

.chat-header .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  margin-left: auto;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.5);
}

/* ── Messages Area ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.message {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.5;
  animation: msgIn 0.25s ease;
}

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.bot {
  align-self: flex-start;
  background: rgba(25, 35, 60, 0.7);
  border: 1px solid rgba(50, 70, 130, 0.3);
  color: #c8d4e4;
}

.message.user {
  align-self: flex-end;
  background: rgba(37, 99, 235, 0.3);
  border: 1px solid rgba(37, 99, 235, 0.4);
  color: #d4dce8;
}

.message.bot .bot-name {
  font-size: 10px;
  color: #5588ff;
  font-weight: 500;
  margin-bottom: 4px;
  letter-spacing: 1px;
}

.message.error {
  align-self: center;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ff8888;
  font-size: 12px;
  text-align: center;
}

/* Typing indicator */
.typing {
  align-self: flex-start;
  padding: 10px 18px;
  background: rgba(25, 35, 60, 0.7);
  border: 1px solid rgba(50, 70, 130, 0.3);
  border-radius: 12px;
  display: flex;
  gap: 4px;
  align-items: center;
}

.typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #556688;
  animation: blink 1.4s infinite;
}

.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1); }
}

/* ── Input Area ── */
.chat-input-area {
  padding: 12px 16px;
  background: rgba(12, 18, 32, 0.9);
  border-top: 1px solid rgba(50, 70, 130, 0.25);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  background: rgba(20, 28, 50, 0.6);
  border: 1px solid rgba(50, 70, 130, 0.35);
  border-radius: 20px;
  color: #d4dce8;
  font-family: 'Roboto', sans-serif;
  font-size: 13px;
  outline: none;
  transition: all 0.2s ease;
}

.chat-input::placeholder {
  color: #445566;
}

.chat-input:focus {
  border-color: rgba(37, 99, 235, 0.5);
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.1);
}

.send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #2563eb;
  border: none;
  color: white;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.send-btn:hover {
  background: #3b82f6;
  transform: scale(1.05);
}

.send-btn:disabled {
  background: #334466;
  cursor: not-allowed;
  transform: none;
}

/* ── Footer ── */
.chat-footer {
  padding: 8px 16px;
  text-align: center;
  font-size: 9px;
  color: #334455;
  letter-spacing: 1px;
  flex-shrink: 0;
}

/* ── Scrollbar ── */
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(50, 70, 120, 0.4); border-radius: 2px; }

/* ── Markdown-like formatting in bot messages ── */
.message.bot ul, .message.bot ol {
  margin: 4px 0 4px 16px;
}

.message.bot li {
  margin-bottom: 2px;
}

.message.bot strong {
  color: #e0e8f4;
}

.message.bot code {
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
}

/* ══════════════════════════════════════════ */
/* ═══ USAGE DASHBOARD                   ═══ */
/* ══════════════════════════════════════════ */

.dashboard {
  width: 800px;
  max-width: 100%;
  background: linear-gradient(180deg, #111828 0%, #0d1220 100%);
  border: 1px solid rgba(50, 70, 130, 0.3);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.dash-header {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: #7888a8;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(50, 70, 130, 0.2);
  margin-bottom: 12px;
}

.dash-header i {
  color: #2563eb;
  font-size: 14px;
}

.dash-started {
  margin-left: auto;
  font-weight: 400;
  font-size: 10px;
  color: #556678;
  letter-spacing: 0.5px;
}

.dash-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 12px;
}

.dash-card {
  background: rgba(15, 22, 40, 0.6);
  border: 1px solid rgba(50, 70, 130, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
}

.dash-card-header {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #6878a0;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(50, 70, 130, 0.15);
}

.dash-card-header i {
  color: #2563eb;
  margin-right: 4px;
}

.dash-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 0;
}

.dash-label {
  font-size: 11px;
  color: #556688;
}

.dash-value {
  font-size: 13px;
  font-weight: 600;
  color: #d0d8e8;
  font-variant-numeric: tabular-nums;
}

.dash-cost {
  color: #22c55e;
}

/* ── Mini bar chart ── */
.dash-chart {
  background: rgba(15, 22, 40, 0.6);
  border: 1px solid rgba(50, 70, 130, 0.25);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 10px;
}

.dash-chart-header {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  color: #6878a0;
  margin-bottom: 8px;
}

.dash-chart-header i {
  color: #2563eb;
  margin-right: 4px;
}

.dash-bars {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: 50px;
  padding: 0 2px;
}

.dash-bar {
  flex: 1;
  max-width: 30px;
  min-width: 6px;
  background: linear-gradient(180deg, #2563eb 0%, #1a4ab8 100%);
  border-radius: 3px 3px 0 0;
  position: relative;
  transition: all 0.3s ease;
  cursor: default;
}

.dash-bar:hover {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
}

.dash-bar .bar-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: #1a2540;
  border: 1px solid #2a3a60;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 9px;
  color: #aabbcc;
  white-space: nowrap;
  z-index: 10;
}

.dash-bar:hover .bar-tooltip {
  display: block;
}

.dash-bars-empty {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #334455;
  font-size: 11px;
  font-style: italic;
}

/* Reset button */
.dash-reset {
  background: none;
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #885555;
  font-size: 10px;
  padding: 4px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-family: 'Roboto', sans-serif;
  transition: all 0.2s;
}

.dash-reset:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.5);
}

/* ── Responsive ── */
@media (max-width: 840px) {
  .dash-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 440px) {
  body { padding: 10px; }
  .dashboard { padding: 10px; }
  .dash-grid {
    grid-template-columns: 1fr;
  }
  .chat-container {
    width: 100%;
    height: auto;
    max-height: none;
    border-radius: 14px;
  }
}
