:root {
  --bg-base: #0a0a0f;
  --bg-surface: #13131a;
  --bg-card: #1c1c26;
  --accent-primary: #7c6dfa;
  --accent-secondary: #4fd1c5;
  --accent-glow: rgba(124,109,250,0.25);
  --text-primary: #f0f0ff;
  --text-muted: #8888aa;
  --border: #2a2a3d;
  --radius-lg: 1.25rem;
  --radius-md: 0.75rem;
  --shadow-glow: 0 0 24px var(--accent-glow);
  --font-main: 'Inter', sans-serif;
}

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

body {
  background-color: var(--bg-base);
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
  transition: all 0.2s ease;
}

a:hover {
  text-shadow: var(--shadow-glow);
}

.auth-container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  padding: 1rem;
}

.glass-card {
  background-color: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.glass-card h1 {
  margin-bottom: 1.5rem;
  text-align: center;
  font-size: 1.5rem;
}

.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-main);
  transition: all 0.2s ease;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.btn {
  width: 100%;
  padding: 0.75rem 1rem;
  background-color: var(--accent-primary);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  line-height: 1;
  text-decoration: none;
}

.btn:hover {
  background-color: #6a5cd6;
  box-shadow: var(--shadow-glow);
}

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

.mt-3 {
  margin-top: 1rem;
}

/* Navbar */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 2rem;
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.bot-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent-primary);
    box-shadow: 0 10px 30px rgba(124, 109, 250, 0.15);
}

.role-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}
.role-free { background: rgba(79, 209, 197, 0.1); color: #4fd1c5; }
.role-pro { background: rgba(246, 201, 14, 0.1); color: #f6c90e; }
.role-platinum { background: var(--accent-gradient); color: white; }
.role-admin { background: #ff6b6b; color: white; }

.nav-brand {
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-brand::before {
  content: '';
  display: inline-block;
  width: 28px;
  height: 28px;
  background-image: url('../img/logo.png');
  background-size: cover;
  border-radius: 6px;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.lang-switch {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-md);
  padding: 0.25rem 0.5rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-switch:hover, .lang-switch.active {
  color: var(--accent-primary);
  border-color: var(--accent-primary);
}

/* Toast System */
#toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 9999;
}

.toast {
  background-color: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem 1.5rem;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 250px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
  animation: slideInRight 0.3s ease forwards;
  transition: opacity 0.3s ease;
}

.toast.fade-out {
  opacity: 0;
}

.toast.success { border-left: 4px solid #4fd1c5; box-shadow: 0 0 12px rgba(79, 209, 197, 0.2); }
.toast.error { border-left: 4px solid #ff6b6b; box-shadow: 0 0 12px rgba(255, 107, 107, 0.2); }
.toast.info { border-left: 4px solid #7c6dfa; box-shadow: 0 0 12px rgba(124, 109, 250, 0.2); }
.toast.warning { border-left: 4px solid #f6c90e; box-shadow: 0 0 12px rgba(246, 201, 14, 0.2); }

.toast-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  margin-left: 1rem;
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Chat Layout */
.chat-layout {
  height: 100vh;
  overflow: hidden;
}

.chat-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.chat-input-area {
  padding: 1.5rem 2rem;
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border);
}

#chat-form {
  display: flex;
  gap: 1rem;
  max-width: 900px;
  margin: 0 auto;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 0.6rem 0.6rem 0.6rem 1.5rem;
  align-items: center;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

#chat-form:focus-within {
  border-color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2), 0 0 0 4px rgba(124, 109, 250, 0.1);
}

#chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 1rem;
  resize: none;
  outline: none;
  padding: 0.5rem 0;
  min-height: 24px;
  max-height: 150px;
}

.btn-send {
  background: var(--accent-primary);
  color: white;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-send:hover {
  background-color: #6a5cd6;
  box-shadow: var(--shadow-glow);
}

.message-wrap {
  display: flex;
  gap: 1rem;
  align-items: flex-end;
  max-width: 80%;
}

.message-wrap.user {
  align-self: flex-end;
  flex-direction: row;
}

.message-wrap.bot {
  align-self: flex-start;
}

.message {
  padding: 1rem 1.25rem;
  border-radius: var(--radius-lg);
  font-size: 0.95rem;
  line-height: 1.5;
  white-space: pre-wrap;
}

.bubble-user {
  background: linear-gradient(135deg, var(--accent-primary) 0%, #6355d8 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px rgba(124, 109, 250, 0.2);
}

.bubble-bot {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

/* Avatars */
.bot-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}

.bot-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.5);
}

.user-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  color: #fff;
  flex-shrink: 0;
}

.role-free { background-color: #4fd1c5; }
.role-pro { background-color: #7c6dfa; }
.role-platinum { background-color: #f6c90e; color: #000; }
.role-admin { background-color: #ff6b6b; }

.role-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-md);
  font-weight: 600;
}

.btn-logout {
  font-size: 0.875rem;
  color: var(--text-muted);
}
.btn-logout:hover {
  color: #ff6b6b;
}

/* Typing Indicator */
.typing-indicator-wrap .message {
  padding: 1rem;
}

.typing span {
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: var(--text-muted);
  border-radius: 50%;
  margin: 0 2px;
  animation: bounce 1.4s infinite ease-in-out both;
}

.typing span:nth-child(1) { animation-delay: -0.32s; }
.typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Chat Links */
.chat-link {
    color: var(--accent-secondary);
    text-decoration: underline;
    font-weight: 600;
    transition: color 0.2s;
}

.chat-link:hover {
    color: #fff;
}

/* CTA Offer Card */
.cta-offer-card {
    background: linear-gradient(135deg, rgba(124, 109, 250, 0.12), rgba(79, 209, 197, 0.08));
    border: 1px solid rgba(124, 109, 250, 0.35);
    border-radius: 16px;
    padding: 1rem;
    max-width: 260px;
    text-align: center;
    animation: fadeInUp 0.3s ease;
}
.cta-offer-img {
    width: 100%;
    border-radius: 10px;
    margin-bottom: 0.75rem;
    object-fit: cover;
    max-height: 150px;
    display: block;
}
.cta-offer-text {
    color: var(--text-primary);
    font-size: 0.85rem;
    margin: 0 0 0.85rem;
    line-height: 1.5;
}
.cta-offer-btn {
    display: inline-block;
    background: var(--accent-primary);
    color: #fff;
    padding: 0.45rem 1.25rem;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: opacity 0.2s, transform 0.15s;
}
.cta-offer-btn:hover {
    opacity: 0.88;
    transform: translateY(-1px);
}

/* Sidebar and History */
.app-container {
  display: flex;
  height: calc(100vh - 65px); /* Subtract navbar height */
  overflow: hidden;
}

.sidebar {
  width: 260px;
  background-color: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
}

.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 1rem 0;
}

.conv-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  cursor: pointer;
  color: var(--text-primary);
  border-left: 3px solid transparent;
}

.conv-item:hover, .conv-item.active {
  background-color: rgba(255,255,255,0.05);
  border-left-color: var(--accent-primary);
}

.conv-title {
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.conv-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.conv-item:hover .conv-delete {
  opacity: 1;
}

.conv-delete:hover {
  color: #ff6b6b;
}

@media (max-width: 768px) {
  .sidebar {
    position: absolute;
    z-index: 100;
    height: calc(100vh - 65px);
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .app-container {
    position: relative;
  }
}

.history-page {
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
}

.history-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.2s ease;
}

.history-card:hover {
  border-color: var(--accent-primary);
}

.history-card-info {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.history-card-title {
  font-weight: 600;
  color: var(--text-primary);
}

.history-card-date {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Admin Sidebar */
.admin-sidebar .sidebar-nav {
  display: flex;
  flex-direction: column;
  padding: 1rem 0;
  flex: 1;
}

.sidebar-footer {
  margin-top: auto;
}

.sidebar-link {
  padding: 0.75rem 1.5rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-weight: 500;
  border-left: 3px solid transparent;
}

.sidebar-link:hover, .sidebar-link.active {
  background-color: rgba(255,255,255,0.05);
  color: var(--text-primary);
  border-left-color: var(--accent-primary);
}

.admin-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 2rem;
  margin-top: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 140px;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-primary);
  opacity: 0.5;
  transition: opacity 0.3s ease;
}

.stat-card:hover {
  transform: translateY(-5px);
  border-color: var(--accent-primary);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

.stat-card:hover::before {
  opacity: 1;
}

.stat-card h3 {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stat-card .value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1.5rem;
  background-color: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--border);
}

.data-table th, .data-table td {
  padding: 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background-color: rgba(255,255,255,0.02);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 3rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 1.5rem;
  background-color: rgba(255,255,255,0.01);
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent-primary);
  background-color: rgba(124, 109, 250, 0.05);
}
