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

:root {
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.04);
  --border-glass: rgba(255, 255, 255, 0.08);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-primary: #6366f1;
  --accent-secondary: #8b5cf6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-cyan: #06b6d4;
  --gradient-main: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #06b6d4 100%);
  --gradient-card: linear-gradient(135deg, rgba(99,102,241,0.1), rgba(139,92,246,0.05));
  --shadow-glow: 0 0 30px rgba(99, 102, 241, 0.15);
  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3);
  --radius: 16px;
  --radius-sm: 10px;
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Animated Background */
body::before {
  content: '';
  position: fixed;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 20% 50%, rgba(99,102,241,0.08) 0%, transparent 50%),
              radial-gradient(circle at 80% 20%, rgba(139,92,246,0.06) 0%, transparent 50%),
              radial-gradient(circle at 50% 80%, rgba(6,182,212,0.05) 0%, transparent 50%);
  animation: bgShift 20s ease-in-out infinite;
  z-index: -1;
}

@keyframes bgShift {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(-2%, 1%) rotate(1deg); }
  66% { transform: translate(1%, -2%) rotate(-1deg); }
}

/* Header */
.header {
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  padding: 12px 32px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-brand img {
  height: 44px;
  object-fit: contain;
  filter: brightness(1.1);
  transition: var(--transition);
}

.header-brand img.logo-jaga {
  filter: invert(1) brightness(1.8);
}

.header-brand img.logo-jaga:hover {
  filter: invert(1) brightness(2) drop-shadow(0 0 10px rgba(99,102,241,0.6));
  transform: scale(1.08);
}

.header-brand img:hover {
  filter: brightness(1.3) drop-shadow(0 0 8px rgba(99,102,241,0.4));
  transform: scale(1.05);
}

.header-title {
  display: flex;
  flex-direction: column;
}

.header-title h1 {
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.02em;
}

.header-title span {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 400;
}

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

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-emerald);
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
  50% { opacity: 0.7; box-shadow: 0 0 0 6px rgba(16,185,129,0); }
}

.status-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Main Layout */
.main-container {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px;
  min-height: calc(100vh - 72px);
}

/* Glass Card */
.glass-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-card);
  transition: var(--transition);
}

.glass-card:hover {
  border-color: rgba(99, 102, 241, 0.15);
}

/* Search Section */
.search-section {
  margin-bottom: 24px;
}

.search-section h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.search-section h2 .icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--gradient-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.search-input-wrapper {
  position: relative;
}

.search-input {
  width: 100%;
  min-height: 120px;
  padding: 16px 20px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.95rem;
  line-height: 1.6;
  resize: vertical;
  transition: var(--transition);
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
  background: rgba(255, 255, 255, 0.05);
}

.search-input::placeholder {
  color: var(--text-muted);
  font-style: italic;
}

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

.btn {
  padding: 10px 24px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-primary {
  background: var(--gradient-main);
  color: white;
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(99, 102, 241, 0.45);
}

.btn-primary:active { transform: translateY(0); }

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

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

/* Loading spinner */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Results Section */
.results-section {
  display: grid;
  gap: 20px;
}

.result-category {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius);
  overflow: hidden;
}

.result-category-header {
  padding: 14px 20px;
  background: var(--gradient-card);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: var(--transition);
}

.result-category-header:hover {
  background: rgba(99, 102, 241, 0.08);
}

.result-category-header h3 {
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.result-count {
  background: rgba(99, 102, 241, 0.2);
  color: var(--accent-primary);
  padding: 2px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.result-list {
  padding: 8px;
  max-height: 400px;
  overflow-y: auto;
}

.result-item {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  transition: var(--transition);
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: start;
}

.result-item:hover {
  background: rgba(99, 102, 241, 0.06);
}

.result-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--accent-cyan);
  background: rgba(6, 182, 212, 0.1);
  padding: 3px 10px;
  border-radius: 6px;
  white-space: nowrap;
}

.result-desc {
  font-size: 0.83rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.result-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}

.confidence-badge {
  font-size: 0.7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.confidence-alta {
  background: rgba(16, 185, 129, 0.15);
  color: var(--accent-emerald);
}

.confidence-media {
  background: rgba(245, 158, 11, 0.15);
  color: var(--accent-amber);
}

.confidence-baja {
  background: rgba(244, 63, 94, 0.15);
  color: var(--accent-rose);
}

.historical-badge {
  font-size: 0.65rem;
  color: var(--accent-amber);
  display: flex;
  align-items: center;
  gap: 3px;
}

/* AI Chat Panel */
.chat-panel {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 120px);
  position: sticky;
  top: 96px;
}

.chat-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--gradient-main);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 12px rgba(99, 102, 241, 0.35);
}

.chat-avatar::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 14px;
  background: conic-gradient(from 0deg, #6366f1, #8b5cf6, #06b6d4, #10b981, #6366f1);
  z-index: -1;
  animation: avatarGlow 3s linear infinite;
}

@keyframes avatarGlow {
  to { transform: rotate(360deg); }
}

.chat-avatar svg {
  width: 22px;
  height: 22px;
  fill: white;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}

.chat-header-info h3 {
  font-size: 0.9rem;
  font-weight: 600;
}

.chat-header-info span {
  font-size: 0.7rem;
  color: var(--text-muted);
}

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

.chat-message {
  max-width: 90%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.83rem;
  line-height: 1.6;
  animation: msgSlide 0.3s ease-out;
}

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

.chat-message.user {
  align-self: flex-end;
  background: var(--accent-primary);
  color: white;
  border-bottom-right-radius: 4px;
}

.chat-message.assistant {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-glass);
  border-bottom-left-radius: 4px;
  color: var(--text-secondary);
}

.chat-message.assistant strong {
  color: var(--text-primary);
}

.chat-message.system {
  align-self: center;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.2);
  color: var(--accent-amber);
  font-size: 0.78rem;
  text-align: center;
}

.chat-input-area {
  padding: 16px;
  border-top: 1px solid var(--border-glass);
  display: flex;
  gap: 8px;
}

.chat-input {
  flex: 1;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  color: var(--text-primary);
  font-family: 'Inter', sans-serif;
  font-size: 0.85rem;
  transition: var(--transition);
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: rgba(255, 255, 255, 0.06);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: var(--gradient-main);
  border: none;
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  font-size: 1.1rem;
}

.chat-send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.3);
}

/* Historical Section */
.historical-section {
  margin-top: 20px;
}

.historical-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}

.historical-table th {
  text-align: left;
  padding: 10px 14px;
  background: rgba(99, 102, 241, 0.08);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-glass);
}

.historical-table td {
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  vertical-align: top;
}

.historical-table tr:hover td {
  background: rgba(99, 102, 241, 0.04);
}

/* Stats Bar */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 16px;
  text-align: center;
  transition: var(--transition);
}

.stat-card:hover {
  border-color: rgba(99, 102, 241, 0.2);
  transform: translateY(-2px);
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Loading overlay */
.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(10, 14, 26, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.5s ease;
}

.loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-logo {
  width: 80px;
  height: 80px;
  animation: logoPulse 2s ease-in-out infinite;
  filter: invert(1) brightness(2);
}

@keyframes logoPulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.1); opacity: 1; }
}

.loading-text {
  margin-top: 20px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.loading-bar {
  width: 200px;
  height: 3px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  margin-top: 16px;
  overflow: hidden;
}

.loading-bar::after {
  content: '';
  display: block;
  width: 40%;
  height: 100%;
  background: var(--gradient-main);
  border-radius: 2px;
  animation: loadSlide 1.5s ease-in-out infinite;
}

@keyframes loadSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-muted);
}

.empty-state .icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state p {
  font-size: 0.85rem;
  line-height: 1.6;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  background: rgba(255, 255, 255, 0.03);
  padding: 4px;
  border-radius: var(--radius-sm);
}

.tab {
  flex: 1;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
}

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

.tab:hover:not(.active) {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.05);
}

/* Responsive */
@media (max-width: 1024px) {
  .main-container {
    grid-template-columns: 1fr;
  }
  .chat-panel {
    position: static;
    height: 500px;
  }
  .stats-bar {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .header { padding: 10px 16px; }
  .main-container { padding: 12px; }
  .stats-bar { grid-template-columns: 1fr 1fr; }
  .search-actions { flex-direction: column; }
  .header-brand img { height: 32px; }
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 8px 0;
}

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

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

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* Footer */
.site-footer {
  text-align: center;
  padding: 24px 32px;
  border-top: 1px solid var(--border-glass);
  background: rgba(10, 14, 26, 0.6);
  backdrop-filter: blur(12px);
}

.footer-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 6px;
}

.footer-brand img {
  height: 28px;
  filter: invert(1) brightness(1.5);
  opacity: 0.85;
  transition: var(--transition);
}

.footer-brand img:hover {
  opacity: 1;
  filter: invert(1) brightness(2) drop-shadow(0 0 8px rgba(99,102,241,0.5));
  transform: scale(1.05);
}

.footer-text {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
  letter-spacing: 0.03em;
}

.footer-text strong {
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-weight: 700;
}

.footer-sub {
  font-size: 0.68rem;
  color: rgba(100, 116, 139, 0.6);
  margin-top: 4px;
}
