/* ==========================================================================
   Design Tokens & Variables
   ========================================================================== */
:root {
  /* Brand & Neutrals */
  --bg-main: #0b1329;
  --bg-card: #131f3b;
  --bg-card-subtle: #1a284c;
  --bg-input: #0e172e;
  --border-color: #24355a;
  --border-hover: #3b5284;
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --primary-accent: #3b82f6;
  --primary-accent-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.15);

  /* Status Colors */
  --color-safe: #10b981;
  --color-safe-bg: rgba(16, 185, 129, 0.12);
  --color-safe-border: rgba(16, 185, 129, 0.35);

  --color-suspicious: #f59e0b;
  --color-suspicious-bg: rgba(245, 158, 11, 0.12);
  --color-suspicious-border: rgba(245, 158, 11, 0.35);

  --color-dangerous: #ef4444;
  --color-dangerous-bg: rgba(239, 68, 68, 0.12);
  --color-dangerous-border: rgba(239, 68, 68, 0.35);

  /* Radii & Shadows */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 40px -10px rgba(59, 130, 246, 0.25);
  
  /* Font */
  --font-main: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ==========================================================================
   Base & Reset
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow-x: hidden;
}

/* Ambient glow */
.bg-glow {
  position: fixed;
  top: -150px;
  left: 50%;
  transform: translateX(-50%);
  width: 700px;
  height: 350px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.15) 0%, rgba(11, 19, 41, 0) 70%);
  pointer-events: none;
  z-index: 0;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  position: relative;
  z-index: 1;
}

/* ==========================================================================
   Header
   ========================================================================== */
.app-header {
  padding: 2rem 0 1.5rem;
  border-bottom: 1px solid var(--border-color);
  background: rgba(11, 19, 41, 0.7);
  backdrop-filter: blur(8px);
}

.header-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #2563eb, #10b981);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
}

.brand-text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.brand-text h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(to right, #ffffff, #93c5fd);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.badge-subtle {
  font-size: 0.75rem;
  font-weight: 600;
  color: #93c5fd;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.02em;
}

.tagline {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ==========================================================================
   Main Layout (Two Columns)
   ========================================================================== */
.main-layout {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 1.5rem;
  padding-top: 2rem;
  padding-bottom: 2.5rem;
  flex: 1;
}

@media (max-width: 900px) {
  .main-layout {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   Card Styles
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease;
}

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

/* ==========================================================================
   Tab Navigation & Panels
   ========================================================================== */
.tab-header {
  display: flex;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 4px;
  gap: 4px;
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.7rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.tab-btn.active {
  background: var(--bg-card-subtle);
  color: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border-color);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.tab-panel[hidden] {
  display: none !important;
}

.panel-intro h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.panel-intro p {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* ==========================================================================
   Forms & Inputs
   ========================================================================== */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.input-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.input-wrapper {
  display: flex;
  gap: 0.5rem;
}

@media (max-width: 550px) {
  .input-wrapper {
    flex-direction: column;
  }
}

input[type="url"],
input[type="text"],
textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.8rem 1rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="url"]:focus,
input[type="text"]:focus,
textarea:focus {
  border-color: var(--primary-accent);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.4;
}

.form-actions {
  margin-top: 0.75rem;
  display: flex;
  justify-content: flex-end;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.8rem 1.4rem;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--primary-accent-hover);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.btn-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* Quick preview chips */
.demo-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.75rem;
}

.demo-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 600;
}

.chip {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.chip:hover {
  background: var(--border-color);
  color: var(--text-primary);
}

/* ==========================================================================
   Result Box Display
   ========================================================================== */
.result-box {
  margin-top: 1rem;
  border-radius: var(--radius-md);
  padding: 1.25rem;
  border: 1px solid transparent;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: fadeIn 0.3s ease-in-out;
}

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

.result-box.status-safe {
  background: var(--color-safe-bg);
  border-color: var(--color-safe-border);
}

.result-box.status-suspicious {
  background: var(--color-suspicious-bg);
  border-color: var(--color-suspicious-border);
}

.result-box.status-dangerous {
  background: var(--color-dangerous-bg);
  border-color: var(--color-dangerous-border);
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.result-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
}

.status-safe .result-badge {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.status-suspicious .result-badge {
  background: rgba(245, 158, 11, 0.2);
  color: #fbbf24;
}

.status-dangerous .result-badge {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.confidence-meter {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.result-reason {
  font-size: 0.92rem;
  color: var(--text-primary);
  line-height: 1.45;
}

.result-details {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 0.75rem;
  margin-top: 0.25rem;
}

.result-details h4 {
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-secondary);
  letter-spacing: 0.04em;
  margin-bottom: 0.35rem;
}

.result-details ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.result-details li {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: flex;
  align-items: flex-start;
  gap: 0.4rem;
}

.result-details li::before {
  content: "•";
  color: var(--text-muted);
}

/* ==========================================================================
   AI Assistant Chat Card
   ========================================================================== */
.chat-card {
  height: 580px;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.chat-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.avatar-assistant {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-header h3 {
  font-size: 1rem;
  font-weight: 700;
}

.online-indicator {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  color: var(--color-safe);
  font-weight: 500;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-safe);
  box-shadow: 0 0 6px var(--color-safe);
}

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

.message {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  gap: 0.25rem;
}

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

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

.message-bubble {
  padding: 0.8rem 1rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.45;
}

.message-assistant .message-bubble {
  background: var(--bg-card-subtle);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-top-left-radius: 4px;
}

.message-user .message-bubble {
  background: var(--primary-accent);
  color: #fff;
  border-top-right-radius: 4px;
}

.message-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.message-user .message-time {
  text-align: right;
}

.quick-questions {
  margin-top: 0.6rem;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.quick-questions li {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: #93c5fd;
  cursor: pointer;
  transition: all 0.15s;
}

.quick-questions li:hover {
  background: var(--border-color);
  color: #fff;
}

/* Chat Input Form */
.chat-input-form {
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card-subtle);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.chat-input-form input {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.7rem 0.9rem;
  color: var(--text-primary);
  font-size: 0.9rem;
}

.btn-send {
  background: var(--primary-accent);
  border: none;
  color: #fff;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

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

.btn-send:active {
  transform: scale(0.96);
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
  margin-top: auto;
  border-top: 1px solid var(--border-color);
  padding: 1.25rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.app-footer code {
  color: #93c5fd;
  background: var(--bg-card-subtle);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.8rem;
}
