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

:root {
  --bg-deep: #030303;
  --bg-surface: #0a0a0c;
  --bg-card: rgba(14, 14, 18, 0.75);
  --bg-card-hover: rgba(22, 22, 28, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(92, 92, 252, 0.5);
  --primary: #5c5cfc;
  --primary-glow: rgba(92, 92, 252, 0.25);
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.2);
  --accent-amber: #f59e0b;
  --accent-rose: #ef4444;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --font-family: 'Vazirmatn', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --glass-blur: blur(28px);
}

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

body {
  background-color: var(--bg-deep);
  color: var(--text-main);
  font-family: var(--font-family);
  direction: rtl;
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* Background Canvas & Roadscape */
.prism-background {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  pointer-events: none;
}

.login-roadscape {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.road-line {
  position: absolute;
  background: linear-gradient(180deg, transparent, rgba(92, 92, 252, 0.15), transparent);
  width: 1px;
  height: 100%;
}

.road-line.line-1 { left: 15%; animation: pulseLine 6s ease-in-out infinite; }
.road-line.line-2 { left: 35%; animation: pulseLine 8s ease-in-out infinite 1s; }
.road-line.line-3 { left: 65%; animation: pulseLine 7s ease-in-out infinite 2s; }
.road-line.line-4 { left: 85%; animation: pulseLine 9s ease-in-out infinite 3s; }

@keyframes pulseLine {
  0%, 100% { opacity: 0.1; }
  50% { opacity: 0.45; }
}

/* Glassmorphism Card Style */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.glass-panel:hover {
  border-color: rgba(255, 255, 255, 0.14);
}

/* ========================================= */
/* LOGIN PAGE STYLES                         */
/* ========================================= */
.login-shell {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 440px;
  padding: 2.5rem 2rem;
  background: rgba(10, 10, 14, 0.82);
  backdrop-filter: blur(32px);
  -webkit-backdrop-filter: blur(32px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6), 0 0 40px var(--primary-glow);
  text-align: center;
}

.login-brand-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 1.25rem;
  background: linear-gradient(135deg, rgba(92, 92, 252, 0.2), rgba(16, 185, 129, 0.15));
  border: 1px solid rgba(92, 92, 252, 0.35);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px var(--primary-glow);
}

.login-brand h1 {
  font-size: 1.45rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.4rem;
  letter-spacing: -0.01em;
}

.login-brand p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 2rem;
}

.input-group {
  margin-bottom: 1.25rem;
  text-align: right;
}

.input-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.input-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-icon {
  position: absolute;
  right: 14px;
  color: var(--text-dim);
  pointer-events: none;
}

.input-field {
  width: 100%;
  padding: 0.75rem 2.8rem 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.92rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.input-field:focus {
  background: rgba(255, 255, 255, 0.07);
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

.toggle-pwd {
  position: absolute;
  left: 12px;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color 0.2s ease;
}

.toggle-pwd:hover {
  color: var(--text-main);
}

.btn-primary {
  width: 100%;
  padding: 0.85rem 1.25rem;
  background: linear-gradient(135deg, #5c5cfc, #4338ca);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  color: #ffffff;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  box-shadow: 0 8px 24px var(--primary-glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
  margin-top: 1.5rem;
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(92, 92, 252, 0.4);
}

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

.login-security-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 1.75rem;
  padding: 0.35rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

.login-error-msg {
  display: none;
  padding: 0.75rem 1rem;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  color: #fca5a5;
  font-size: 0.82rem;
  margin-bottom: 1.25rem;
  text-align: right;
}

/* ========================================= */
/* DASHBOARD MASTER LAYOUT                   */
/* ========================================= */
.app-container {
  position: relative;
  z-index: 10;
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.25rem 2rem 4rem;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.8rem;
  margin-bottom: 1.75rem;
}

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

.brand-symbol {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, rgba(92, 92, 252, 0.25), rgba(16, 185, 129, 0.2));
  border: 1px solid rgba(92, 92, 252, 0.4);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--primary-glow);
}

.brand-info h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-info p {
  font-size: 0.8rem;
  color: var(--text-muted);
}

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

.system-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.9rem;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.25);
  border-radius: 20px;
  font-size: 0.78rem;
  color: #6ee7b7;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
  animation: pulseDot 2s infinite;
}

@keyframes pulseDot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
}

.btn-trigger-run {
  padding: 0.5rem 1rem;
  background: rgba(92, 92, 252, 0.15);
  border: 1px solid rgba(92, 92, 252, 0.35);
  border-radius: var(--radius-sm);
  color: #a5b4fc;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn-trigger-run:hover {
  background: rgba(92, 92, 252, 0.25);
  color: #ffffff;
  box-shadow: 0 0 16px var(--primary-glow);
}

.user-profile-menu {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.35rem 0.75rem 0.35rem 0.35rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: 24px;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  color: #ffffff;
}

.btn-logout {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.2s ease, background 0.2s ease;
}

.btn-logout:hover {
  color: var(--accent-rose);
  background: rgba(239, 68, 68, 0.1);
}

/* Nav Tabs */
.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem;
  margin-bottom: 2rem;
  background: rgba(10, 10, 14, 0.7);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  width: fit-content;
}

.nav-tab-btn {
  padding: 0.6rem 1.25rem;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

.nav-tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.04);
}

.nav-tab-btn.active {
  color: #ffffff;
  background: rgba(92, 92, 252, 0.18);
  border: 1px solid rgba(92, 92, 252, 0.3);
  box-shadow: 0 4px 14px var(--primary-glow);
}

/* ========================================= */
/* TAB 1: BENTO STATS & GEOLOCATION          */
/* ========================================= */
.bento-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.25rem;
  margin-bottom: 1.75rem;
}

.metric-card {
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 90px;
  height: 90px;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  pointer-events: none;
}

.metric-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.metric-title {
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
}

.metric-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--primary);
}

.metric-value {
  font-size: 1.95rem;
  font-weight: 800;
  color: #ffffff;
  letter-spacing: -0.02em;
  font-family: 'Inter', var(--font-family);
}

.metric-footer {
  margin-top: 0.5rem;
  font-size: 0.76rem;
  color: var(--text-dim);
}

/* Map & Telemetry Split */
.telemetry-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.map-panel {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.map-container {
  width: 100%;
  height: 420px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border-subtle);
  background: #090b10;
}

/* Live Stream Table */
.stream-panel {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
}

.stream-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  overflow-y: auto;
  max-height: 420px;
  padding-left: 0.25rem;
}

.stream-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.9rem;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.stream-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(92, 92, 252, 0.3);
}

.stream-recipient {
  font-weight: 600;
  font-size: 0.85rem;
  color: #ffffff;
}

.stream-location {
  font-size: 0.74rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin-top: 2px;
}

.stream-meta {
  text-align: left;
  direction: ltr;
}

.stream-time {
  font-size: 0.72rem;
  color: var(--text-dim);
}

.stream-client-badge {
  display: inline-block;
  font-size: 0.68rem;
  padding: 2px 6px;
  background: rgba(92, 92, 252, 0.12);
  border: 1px solid rgba(92, 92, 252, 0.25);
  border-radius: 4px;
  color: #a5b4fc;
  margin-top: 3px;
}

/* Dispatches Archive Table */
.dispatches-panel {
  padding: 1.5rem;
}

.data-table-wrap {
  overflow-x: auto;
  margin-top: 1rem;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.86rem;
}

.data-table th {
  padding: 0.75rem 1rem;
  color: var(--text-muted);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}

.data-table td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.data-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.table-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.74rem;
  font-weight: 600;
}

.badge-to {
  background: rgba(92, 92, 252, 0.15);
  border: 1px solid rgba(92, 92, 252, 0.3);
  color: #a5b4fc;
}

.badge-cc {
  background: rgba(245, 158, 11, 0.15);
  border: 1px solid rgba(245, 158, 11, 0.3);
  color: #fcd34d;
}

.badge-active {
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.25);
  color: #6ee7b7;
}

.badge-paused {
  background: rgba(100, 116, 139, 0.15);
  border: 1px solid rgba(100, 116, 139, 0.3);
  color: #cbd5e1;
}

/* ========================================= */
/* TAB 2: KEYWORDS & AI LOGIC                */
/* ========================================= */
.keywords-studio-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.5rem;
}

.keyword-chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.keyword-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.85rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.keyword-chip:hover {
  background: rgba(255, 255, 255, 0.07);
  border-color: rgba(92, 92, 252, 0.3);
}

.keyword-chip.paused {
  opacity: 0.55;
  border-style: dashed;
}

.keyword-chip-name {
  font-size: 0.84rem;
  font-weight: 500;
  color: #ffffff;
}

.keyword-chip-cat {
  font-size: 0.7rem;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

.chip-action-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color 0.15s ease;
}

.chip-action-btn:hover {
  color: var(--accent-rose);
}

/* Prompts Textareas */
.prompt-card {
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

.prompt-textarea {
  width: 100%;
  min-height: 140px;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: #f1f5f9;
  font-family: inherit;
  font-size: 0.86rem;
  line-height: 1.6;
  outline: none;
  resize: vertical;
  margin: 0.75rem 0;
  transition: border-color 0.2s ease;
}

.prompt-textarea:focus {
  border-color: var(--primary);
}

.prompt-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 100%;
  max-width: 500px;
  padding: 2rem;
  background: rgba(14, 14, 20, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.7);
}

/* Responsive */
@media (max-width: 1024px) {
  .bento-metrics-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .telemetry-grid, .keywords-studio-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .bento-metrics-grid {
    grid-template-columns: 1fr;
  }
  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }
}
