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

:root {
  /* Color System */
  --bg-main: #0a0b10;
  --bg-card: rgba(17, 19, 28, 0.75);
  --bg-card-hover: rgba(26, 29, 43, 0.85);
  --bg-input: rgba(13, 14, 21, 0.9);
  
  --accent-primary: #6366f1; /* Indigo */
  --accent-secondary: #d97706; /* Amber/Silk */
  --accent-success: #10b981; /* Emerald */
  --accent-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --accent-gradient-hover: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --gold-gradient: linear-gradient(135deg, #d97706 0%, #f59e0b 100%);
  
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dark: #1f2937;
  
  --border-glass: rgba(255, 255, 255, 0.08);
  --border-glass-focus: rgba(99, 102, 241, 0.4);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
  --shadow-md: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --shadow-glow: 0 0 15px rgba(99, 102, 241, 0.25);
  
  --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  --font-title: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

body {
  font-family: var(--font-body);
  background-color: var(--bg-main);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  /* Premium backdrop mesh gradient */
  background-image: 
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(139, 92, 246, 0.1) 0px, transparent 50%),
    radial-gradient(at 50% 50%, rgba(217, 119, 6, 0.03) 0px, transparent 50%);
}

/* App Container */
.app-container {
  display: flex;
  width: 95vw;
  height: 90vh;
  max-width: 1440px;
  max-height: 900px;
  border-radius: 24px;
  border: 1px solid var(--border-glass);
  background: rgba(10, 11, 16, 0.5);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  position: relative;
}

/* Sidebar Catalog */
.sidebar {
  width: 380px;
  border-right: 1px solid var(--border-glass);
  background: #1a1a2e;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: var(--transition-normal);
  z-index: 10;
}

.chat-return-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px 16px;
  background: var(--accent-gradient);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: #ffffff;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 16px;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.chat-return-btn:hover {
  background: var(--accent-gradient-hover);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-glow);
}

.chat-return-btn:active {
  transform: translateY(1px);
}

.sidebar-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-glass);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.brand-logo {
  font-size: 24px;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
  font-family: var(--font-title);
  letter-spacing: -0.5px;
}

.brand-badge {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
  padding: 3px 8px;
  border-radius: 99px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.sidebar-title {
  font-family: var(--font-title);
  font-size: 15px;
  font-weight: 600;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Catalog Tabs */
.tabs-container {
  display: flex;
  padding: 0 16px;
  gap: 6px;
  border-bottom: 1px solid var(--border-glass);
  overflow-x: auto;
  scrollbar-width: none; /* Hide scrollbar */
}
.tabs-container::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-title);
  font-size: 13px;
  font-weight: 600;
  padding: 12px 14px;
  cursor: pointer;
  white-space: nowrap;
  position: relative;
  transition: var(--transition-fast);
}

.tab-btn:hover {
  color: var(--text-main);
}

.tab-btn.active {
  color: var(--accent-primary);
}

.tab-btn.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-gradient);
  border-radius: 99px;
}

/* Catalog Search */
.sidebar-search {
  padding: 16px 24px 8px 24px;
  position: relative;
}

.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 10px 16px 10px 40px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  transition: var(--transition-fast);
}

.search-input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 10px rgba(99, 102, 241, 0.15);
}

.search-icon {
  position: absolute;
  left: 36px;
  top: 24px;
  color: var(--text-muted);
  pointer-events: none;
}

/* Catalog Content Area */
.catalog-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.catalog-panel {
  display: none;
  flex-direction: column;
  gap: 12px;
}

.catalog-panel.active {
  display: flex;
}

/* Catalog Items */
.catalog-card {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: var(--transition-fast);
}

.catalog-card:hover {
  background: var(--bg-card-hover);
  border-color: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.card-title {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 600;
  color: var(--text-main);
}

.card-badge {
  background: rgba(217, 119, 6, 0.1);
  border: 1px solid rgba(217, 119, 6, 0.25);
  color: #fbbf24;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 500;
  white-space: nowrap;
}

.card-details {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
}

.detail-label {
  color: var(--text-muted);
}

.detail-val {
  color: var(--text-main);
  font-weight: 500;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.card-btn {
  flex: 1;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition-fast);
  text-decoration: none;
}

.card-btn-primary {
  background: rgba(99, 102, 241, 0.15);
  border: 1px solid rgba(99, 102, 241, 0.3);
  color: #a5b4fc;
}

.card-btn-primary:hover {
  background: var(--accent-primary);
  color: #fff;
}

.card-btn-secondary {
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-muted);
}

.card-btn-secondary:hover {
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--text-main);
}

/* Rules / FAQ Panel */
.faq-item {
  border-bottom: 1px solid var(--border-glass);
  padding-bottom: 12px;
}
.faq-item:last-child {
  border-bottom: none;
}

.faq-question {
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 600;
  color: #a5b4fc;
  margin-bottom: 6px;
}

.faq-answer {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Chat Section */
.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: rgba(10, 11, 16, 0.2);
  position: relative;
}

/* Chat Header */
.chat-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(13, 15, 24, 0.3);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-sm);
}

img.agent-avatar {
  background: transparent;
  object-fit: contain;
  padding: 2px;
  border: 1px solid var(--border-glass);
}

.agent-status-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.agent-name {
  font-family: var(--font-title);
  font-size: 16px;
  font-weight: 600;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-success);
  box-shadow: 0 0 8px var(--accent-success);
  animation: pulse 2s infinite;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}

.icon-btn-whatsapp {
  background: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.3);
  color: #34d399;
}

.icon-btn-whatsapp:hover {
  background: var(--accent-success);
  color: #fff;
  border-color: var(--accent-success);
}

/* Chat Messages */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.message {
  display: flex;
  gap: 12px;
  max-width: 80%;
  animation: fadeIn 0.3s ease-out;
}

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

.message-assistant {
  align-self: flex-start;
}

.msg-bubble {
  padding: 14px 18px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  position: relative;
}

.message-user .msg-bubble {
  background: var(--accent-gradient);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: var(--shadow-glow);
}

.message-assistant .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}

.msg-timestamp {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 6px;
  display: block;
}

.message-user .msg-timestamp {
  color: rgba(255, 255, 255, 0.7);
  text-align: right;
}

/* Markdown styling inside assistant bubble */
.msg-bubble p {
  margin-bottom: 8px;
}
.msg-bubble p:last-child {
  margin-bottom: 0;
}

.msg-bubble a {
  color: #a5b4fc;
  text-decoration: underline;
  font-weight: 500;
  transition: var(--transition-fast);
}

.msg-bubble a:hover {
  color: #c7d2fe;
}

.msg-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
  font-size: 13px;
}

.msg-bubble th, .msg-bubble td {
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 10px;
  text-align: left;
}

.msg-bubble th {
  background: rgba(255, 255, 255, 0.05);
  font-weight: 600;
  color: #a5b4fc;
}

.msg-bubble ul, .msg-bubble ol {
  margin: 8px 0;
  padding-left: 20px;
}

.msg-bubble li {
  margin-bottom: 4px;
}

/* Suggestions Container */
.suggestions-container {
  padding: 8px 24px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.suggestion-chip {
  background: rgba(99, 102, 241, 0.08);
  border: 1px solid rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  padding: 8px 14px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
}

.suggestion-chip:hover {
  background: var(--accent-gradient);
  border-color: transparent;
  color: #fff;
  transform: translateY(-1px);
}

/* Chat Input Bar */
.chat-input-area {
  padding: 16px 24px 24px 24px;
  background: transparent;
}

.input-container {
  display: flex;
  align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: 16px;
  padding: 8px 12px 8px 16px;
  gap: 12px;
  transition: var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.input-container:focus-within {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}

.chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  resize: none;
  height: 24px;
  max-height: 120px;
  line-height: 24px;
}

.input-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.send-btn {
  background: var(--accent-gradient);
  border: none;
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.send-btn:hover {
  background: var(--accent-gradient-hover);
  transform: scale(1.05);
}

/* Typing Indicator */
.typing-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px !important;
}

.typing-dot {
  width: 6px;
  height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.4s infinite ease-in-out both;
}

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

/* Config Settings Modal */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition-normal);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.modal-card {
  background: #11131c;
  border: 1px solid var(--border-glass);
  border-radius: 24px;
  width: 90%;
  max-width: 480px;
  padding: 32px;
  box-shadow: var(--shadow-md);
  transform: translateY(20px);
  transition: var(--transition-normal);
}

.modal-overlay.active .modal-card {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.modal-title {
  font-family: var(--font-title);
  font-size: 20px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.modal-close:hover {
  color: var(--text-main);
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 13px;
  color: var(--text-muted);
  font-weight: 500;
}

.form-input {
  background: var(--bg-input);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--text-main);
  font-family: var(--font-body);
  font-size: 14px;
  outline: none;
  transition: var(--transition-fast);
}

.form-input:focus {
  border-color: var(--accent-primary);
}

.form-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.btn {
  flex: 1;
  padding: 12px;
  border-radius: 12px;
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition-fast);
}

.btn-primary {
  background: var(--accent-gradient);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-gradient-hover);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Mobile Layout Controls */
.mobile-menu-btn {
  display: none;
}

/* Animations */
@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.2);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

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

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

/* Responsive Media Queries */
@media (max-width: 900px) {
  .app-container {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    border: none;
  }
}

@media (max-width: 800px) {
  .sidebar {
    position: absolute;
    left: -100%;
    top: 0;
    bottom: 0;
    width: 320px;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
  }
  
  .sidebar.active {
    left: 0;
  }
  
  .mobile-menu-btn {
    display: flex;
    margin-right: 12px;
  }
  
  .chat-header-info {
    flex: 1;
  }
}
