/* ==========================================================================
   SpamShield AI — Modern Design System & Stylesheet
   ========================================================================== */

:root {
  --bg-main: #0b0f19;
  --bg-card: rgba(17, 24, 39, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-input: #0f172a;
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.6);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.35);
  
  --accent-cyan: #38bdf8;
  
  --spam-red: #f43f5e;
  --spam-red-bg: rgba(244, 63, 94, 0.12);
  --spam-red-border: rgba(244, 63, 94, 0.3);
  --spam-glow: rgba(244, 63, 94, 0.4);
  
  --ham-green: #10b981;
  --ham-green-bg: rgba(16, 185, 129, 0.12);
  --ham-green-border: rgba(16, 185, 129, 0.3);
  --ham-glow: rgba(16, 185, 129, 0.4);
  
  --warning-amber: #f59e0b;
  --warning-amber-bg: rgba(245, 158, 11, 0.15);
  
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(56, 189, 248, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
}

.app-wrapper {
  max-width: 1360px;
  margin: 0 auto;
  padding: 24px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   Header
   ========================================================================== */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-wrap: wrap;
  gap: 16px;
}

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

.brand-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--accent-cyan));
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 0 20px var(--primary-glow);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
}

.brand-text h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.accent-text {
  background: linear-gradient(135deg, #a5b4fc, var(--accent-cyan));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  font-size: 0.82rem;
  color: var(--text-secondary);
  font-weight: 400;
}

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

.badge {
  padding: 6px 14px;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
}

.pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--ham-green);
  box-shadow: 0 0 10px var(--ham-green);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

.metric-badge strong {
  color: var(--accent-cyan);
}

/* ==========================================================================
   Main Grid Layout
   ========================================================================== */
.main-content {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 24px;
  flex: 1;
}

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

.panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==========================================================================
   Left Panel: Editor & Samples
   ========================================================================== */
.panel-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-primary);
}

.panel-title svg {
  width: 20px;
  height: 20px;
  color: var(--primary);
}

.panel-title h2 {
  font-size: 1.1rem;
  font-weight: 600;
}

.preset-selector-wrapper {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.preset-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.sample-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-family: inherit;
  padding: 5px 12px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.pill-btn.spam:hover {
  border-color: var(--spam-red-border);
  color: #fda4af;
}

.pill-btn.ham:hover {
  border-color: var(--ham-green-border);
  color: #6ee7b7;
}

.editor-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.textarea-container {
  flex: 1;
  min-height: 380px;
  display: flex;
}

textarea#emailInput {
  width: 100%;
  height: 100%;
  min-height: 380px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea#emailInput:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.editor-footer {
  margin-top: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.text-stats {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.stat-separator {
  margin: 0 6px;
}

.editor-actions {
  display: flex;
  gap: 10px;
}

/* ==========================================================================
   Buttons
   ========================================================================== */
.btn {
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  border: none;
  outline: none;
}

.btn svg {
  width: 16px;
  height: 16px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #4338ca);
  color: white;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5, #3730a3);
  box-shadow: 0 6px 20px var(--primary-glow);
  transform: translateY(-1px);
}

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

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

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

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

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

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8rem;
}

/* ==========================================================================
   Right Panel: Tabs & Content
   ========================================================================== */
.tabs-nav {
  display: flex;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.86rem;
  font-weight: 500;
  padding: 14px 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

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

.tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--primary);
  background: rgba(99, 102, 241, 0.06);
}

.tab-content {
  padding: 24px;
  display: none;
  flex: 1;
}

.tab-content.active {
  display: block;
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  min-height: 380px;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-icon svg {
  width: 54px;
  height: 54px;
  margin-bottom: 16px;
  color: var(--text-muted);
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 1.15rem;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.empty-state p {
  font-size: 0.88rem;
  max-width: 380px;
}

/* Hidden Utility */
.hidden {
  display: none !important;
}

/* Verdict Banner */
.verdict-banner {
  border-radius: var(--radius-md);
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  border: 1px solid transparent;
  transition: all 0.3s ease;
}

.verdict-banner.spam {
  background: var(--spam-red-bg);
  border-color: var(--spam-red-border);
  box-shadow: 0 0 25px var(--spam-glow);
}

.verdict-banner.ham {
  background: var(--ham-green-bg);
  border-color: var(--ham-green-border);
  box-shadow: 0 0 25px var(--ham-glow);
}

.verdict-icon-container {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.verdict-banner.spam .verdict-icon-container {
  background: rgba(244, 63, 94, 0.2);
  color: var(--spam-red);
}

.verdict-banner.ham .verdict-icon-container {
  background: rgba(16, 185, 129, 0.2);
  color: var(--ham-green);
}

.verdict-icon-container svg {
  width: 28px;
  height: 28px;
}

.verdict-text-group {
  flex: 1;
}

.verdict-sub {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.verdict-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.3px;
}

.verdict-banner.spam .verdict-title {
  color: #fda4af;
}

.verdict-banner.ham .verdict-title {
  color: #6ee7b7;
}

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

.meta-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
}

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

.risk-badge {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
}

.risk-badge.high {
  background: rgba(244, 63, 94, 0.2);
  color: #fca5a5;
  border: 1px solid var(--spam-red-border);
}

.risk-badge.low {
  background: rgba(16, 185, 129, 0.2);
  color: #86efac;
  border: 1px solid var(--ham-green-border);
}

.risk-badge.moderate {
  background: var(--warning-amber-bg);
  color: #fde047;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.latency-val {
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

/* Confidence Card */
.confidence-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 20px;
}

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

.conf-label {
  font-size: 0.84rem;
  color: var(--text-secondary);
}

.conf-score {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-primary);
}

.probability-bar-track {
  height: 10px;
  border-radius: var(--radius-full);
  background: #1e293b;
  display: flex;
  overflow: hidden;
  margin-bottom: 12px;
}

.prob-fill {
  height: 100%;
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.prob-fill.ham-fill {
  background: linear-gradient(90deg, #10b981, #34d399);
}

.prob-fill.spam-fill {
  background: linear-gradient(90deg, #f43f5e, #fb7185);
}

.probability-legend {
  display: flex;
  justify-content: space-between;
  font-size: 0.78rem;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.legend-item.ham .legend-dot {
  background: var(--ham-green);
}

.legend-item.spam .legend-dot {
  background: var(--spam-red);
}

/* Explainability Card */
.explain-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
}

.section-subheading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.section-subheading svg {
  width: 18px;
  height: 18px;
  color: var(--accent-cyan);
}

.section-subheading h3 {
  font-size: 0.98rem;
  font-weight: 600;
}

.explain-group {
  margin-bottom: 16px;
}

.explain-group:last-child {
  margin-bottom: 0;
}

.group-title {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 32px;
}

.feature-chip {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.feature-chip.spam-indicator {
  background: var(--spam-red-bg);
  border-color: var(--spam-red-border);
  color: #fda4af;
}

.chip-val {
  opacity: 0.75;
  font-size: 0.72rem;
}

.caps-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.cap-metric-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  text-align: center;
}

.cap-metric-val {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.cap-metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Tab 2: Metrics Grid & Confusion Matrix
   ========================================================================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

@media (max-width: 600px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

.metric-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
}

.metric-card.highlight {
  border-color: rgba(99, 102, 241, 0.4);
  background: rgba(99, 102, 241, 0.08);
}

.metric-val {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: var(--font-mono);
}

.metric-card.highlight .metric-val {
  color: var(--accent-cyan);
}

.metric-lbl {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 2px;
}

.metric-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Confusion Matrix */
.matrix-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
  margin-bottom: 20px;
}

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

.matrix-header h3 {
  font-size: 0.98rem;
  font-weight: 600;
}

.cm-table-container {
  overflow-x: auto;
}

.cm-table {
  width: 100%;
  border-collapse: collapse;
  text-align: center;
  font-size: 0.84rem;
}

.cm-table th, .cm-table td {
  padding: 12px 14px;
  border: 1px solid var(--border-subtle);
}

.cm-table th {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-weight: 600;
}

.th-pred {
  letter-spacing: 0.5px;
}

.row-label {
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
}

.cm-cell {
  border-radius: 4px;
  transition: background 0.2s;
}

.cm-cell.correct {
  background: rgba(16, 185, 129, 0.12);
  color: #6ee7b7;
}

.cm-cell.error {
  background: rgba(244, 63, 94, 0.12);
  color: #fda4af;
}

.cell-num {
  display: block;
  font-size: 1.15rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.cell-tag {
  font-size: 0.68rem;
  opacity: 0.8;
}

/* Report Table */
.report-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px;
}

.report-card h3 {
  font-size: 0.98rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.table-responsive {
  overflow-x: auto;
}

.report-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
  text-align: left;
}

.report-table th, .report-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-subtle);
}

.report-table th {
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
}

.report-table td {
  color: var(--text-secondary);
  font-family: var(--font-mono);
}

.report-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-primary);
}

/* ==========================================================================
   Tab 3: Accuracy Guide
   ========================================================================== */
.guide-card {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.guide-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(99, 102, 241, 0.15);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.3);
  margin-bottom: 8px;
}

.guide-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.guide-intro {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.tips-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}

@media (max-width: 768px) {
  .tips-grid {
    grid-template-columns: 1fr;
  }
}

.tip-card {
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  position: relative;
}

.tip-num {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--primary);
  opacity: 0.5;
  margin-bottom: 6px;
}

.tip-card h4 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.tip-card p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
}

.tip-card em, .tip-card code {
  color: var(--accent-cyan);
}

/* ==========================================================================
   Tab 4: API Documentation
   ========================================================================== */
.api-doc-card {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.api-doc-card h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.api-doc-card p {
  font-size: 0.86rem;
  color: var(--text-secondary);
}

.endpoint-block {
  background: rgba(0, 0, 0, 0.3);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
}

.endpoint-tag {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.method {
  font-size: 0.72rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 4px;
}

.method.post {
  background: rgba(16, 185, 129, 0.2);
  color: #6ee7b7;
}

.code-box {
  background: #090d16;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.code-title {
  padding: 8px 14px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
}

.code-box pre {
  padding: 14px;
  overflow-x: auto;
}

.code-box code {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: #e2e8f0;
}

/* ==========================================================================
   Footer
   ========================================================================== */
.app-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
}
