/* Modern Dark Theme Design System for Xtream-Masters IPTV Manager & N8N Flow Studio */
:root {
  --bg-dark: #090d16;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-input: rgba(30, 41, 59, 0.6);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-highlight: rgba(99, 102, 241, 0.4);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --purple: #8b5cf6;
  --purple-bg: rgba(139, 92, 246, 0.12);
  --cyan: #06b6d4;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(at 10% 10%, rgba(99, 102, 241, 0.15) 0px, transparent 40%),
    radial-gradient(at 90% 90%, rgba(139, 92, 246, 0.12) 0px, transparent 40%),
    radial-gradient(at 50% 50%, rgba(16, 185, 129, 0.05) 0px, transparent 60%);
  background-attachment: fixed;
  color: var(--text-main);
  min-height: 100vh;
  padding-bottom: 60px;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px 20px;
}

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

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

.brand-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  box-shadow: 0 0 20px var(--primary-glow);
}

.brand h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #ffffff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand p {
  font-size: 13px;
  color: var(--text-muted);
}

/* Workspace Navigation Bar */
.workspace-tabs {
  display: flex;
  gap: 8px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 6px;
  margin-bottom: 24px;
  overflow-x: auto;
}

.ws-tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  white-space: nowrap;
}

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

.ws-tab-btn.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

/* Tab Panels */
.tab-content-panel {
  display: none;
  animation: fadeIn 0.25s ease-in-out;
}

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

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

/* ========================================================= */
/* 🗺️ FLOW CANVAS STYLES (N8N STYLE VISUALIZER)             */
/* ========================================================= */
.canvas-wrapper-card {
  background: #090d16;
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  position: relative;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0,0,0,0.6);
  margin-bottom: 24px;
}

.canvas-toolbar {
  padding: 16px 20px;
  background: rgba(15, 23, 42, 0.9);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.wf-selector-group {
  display: flex;
  gap: 8px;
}

.wf-selector-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.wf-selector-btn:hover, .wf-selector-btn.active {
  color: #fff;
  border-color: var(--primary);
  background: rgba(99, 102, 241, 0.2);
}

.flow-canvas-viewport {
  width: 100%;
  height: 480px;
  position: relative;
  overflow: auto;
  background-color: #0b1120;
  background-image: radial-gradient(rgba(255, 255, 255, 0.1) 1px, transparent 1px);
  background-size: 24px 24px;
}

.flow-svg-layer {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 1;
}

.flow-wire-bg {
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 4;
  fill: none;
}

.flow-wire {
  stroke: var(--primary);
  stroke-width: 2.5;
  fill: none;
  stroke-dasharray: 6;
  animation: dash 20s linear infinite;
}

@keyframes dash {
  to { stroke-dashoffset: -1000; }
}

.flow-particle {
  fill: var(--cyan);
  filter: drop-shadow(0 0 6px var(--cyan));
}

.flow-wire-label {
  fill: var(--text-muted);
  font-size: 11px;
  font-family: 'Fira Code', monospace;
  text-anchor: middle;
}

.flow-nodes-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 2;
}

.flow-node {
  position: absolute;
  width: 200px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: 0 10px 25px rgba(0,0,0,0.5);
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
  user-select: none;
}

.flow-node:hover {
  transform: translateY(-3px) scale(1.02);
  border-color: var(--primary);
  box-shadow: 0 12px 30px var(--primary-glow);
}

.flow-node.selected {
  border-color: var(--cyan);
  box-shadow: 0 0 20px rgba(6, 182, 212, 0.4);
}

.flow-node-header {
  border-top: 3px solid var(--primary);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}

.flow-node-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

.flow-node-titles h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
}

.flow-node-titles span {
  font-size: 11px;
  color: var(--text-dim);
}

.flow-node-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-left: auto;
  box-shadow: 0 0 8px var(--success);
}

.flow-node-body {
  padding: 8px 12px 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.flow-node-type-badge {
  font-size: 9.5px;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.flow-port {
  width: 10px;
  height: 10px;
  background: var(--primary);
  border: 2px solid #090d16;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.flow-port-in { left: -5px; }
.flow-port-out { right: -5px; }

/* Node Inspector Drawer */
.node-inspector-drawer {
  position: fixed;
  right: -420px;
  top: 0;
  width: 400px;
  height: 100vh;
  background: #0f172a;
  border-left: 1px solid var(--border-highlight);
  box-shadow: -10px 0 30px rgba(0,0,0,0.6);
  z-index: 1000;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.node-inspector-drawer.active {
  right: 0;
}

.drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
}

.drawer-keyvals {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.drawer-keyval-row {
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid var(--border-color);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.drawer-key {
  font-size: 11.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  font-weight: 600;
}

.drawer-val {
  font-size: 13.5px;
  color: var(--text-main);
  font-family: 'Fira Code', monospace;
  word-break: break-all;
}

/* ========================================================= */
/* 📋 EXECUTION LOGS & DEBUGGER STYLES                       */
/* ========================================================= */
.logs-header-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 12px;
}

.log-status-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  text-transform: uppercase;
}

.log-status-success { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.log-status-error { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }

/* ========================================================= */
/* ⚙️ RULE MAPPER & SETTINGS STYLES                          */
/* ========================================================= */
.settings-section-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.editable-table input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 13px;
  width: 100%;
}

.editable-table input:focus {
  border-color: var(--primary);
  outline: none;
}

/* ========================================================= */
/* 🧪 SANDBOX SIMULATOR STYLES                               */
/* ========================================================= */
.sim-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
}

.sim-form-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sim-results-card {
  background: #090d16;
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sim-step-item {
  background: rgba(15, 23, 42, 0.8);
  border-left: 3px solid var(--primary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  animation: slideIn 0.3s ease;
}

/* Common Layout and Elements */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-highlight);
  box-shadow: var(--shadow);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
}

.stat-icon.total { background: var(--primary-glow); color: var(--primary); }
.stat-icon.demo { background: var(--success-bg); color: var(--success); }
.stat-icon.monthly { background: var(--purple-bg); color: var(--purple); }
.stat-icon.annual { background: var(--warning-bg); color: var(--warning); }

.stat-info h3 { font-size: 22px; font-weight: 700; }
.stat-info p { font-size: 12px; color: var(--text-muted); }

/* Controls & Filters Bar */
.controls-section {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.search-box-container { position: relative; width: 100%; }
.search-icon { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: var(--text-dim); }
.search-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 14px 16px 14px 44px;
  color: var(--text-main);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
}

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
  background: rgba(30, 41, 59, 0.9);
}

.keyboard-hint {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-color);
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-muted);
}

.filters-wrapper { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 16px; }
.filter-tabs { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; }
.filter-tab {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: var(--transition);
}
.filter-tab:hover { color: var(--text-main); background: rgba(255, 255, 255, 0.04); }
.filter-tab.active { background: var(--primary); color: #fff; border-color: var(--primary); box-shadow: 0 4px 12px var(--primary-glow); }

.filter-selects { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.custom-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  outline: none;
  cursor: pointer;
}

.packages-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(310px, 1fr)); gap: 20px; }
.pkg-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: var(--transition);
}
.pkg-card:hover { transform: translateY(-4px); border-color: var(--border-highlight); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4); }

.pkg-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 14px; }
.pkg-id-badge {
  background: rgba(99, 102, 241, 0.15);
  color: var(--primary);
  border: 1px solid rgba(99, 102, 241, 0.3);
  font-family: monospace;
  font-weight: 700;
  font-size: 14px;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
}
.pkg-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.badge { font-size: 11px; font-weight: 600; padding: 3px 8px; border-radius: 50px; text-transform: uppercase; }
.badge-demo { background: var(--success-bg); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-official { background: var(--purple-bg); color: var(--purple); border: 1px solid rgba(139, 92, 246, 0.3); }
.badge-xxx { background: var(--danger-bg); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-no-xxx { background: rgba(6, 182, 212, 0.12); color: var(--cyan); border: 1px solid rgba(6, 182, 212, 0.3); }

.pkg-title { font-size: 16px; font-weight: 600; line-height: 1.4; margin-bottom: 16px; min-height: 44px; }
.pkg-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: rgba(15, 23, 42, 0.6);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 18px;
}
.metric-item { display: flex; flex-direction: column; }
.metric-label { font-size: 11px; color: var(--text-dim); }
.metric-val { font-size: 14px; font-weight: 600; }

.pkg-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: var(--transition);
}
.btn:hover { background: rgba(255, 255, 255, 0.08); border-color: rgba(255, 255, 255, 0.2); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); box-shadow: 0 4px 12px var(--primary-glow); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }

.table-container {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow-x: auto;
}
.packages-table { width: 100%; border-collapse: collapse; text-align: left; }
.packages-table th {
  background: rgba(30, 41, 59, 0.8);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
}
.packages-table td {
  padding: 14px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  font-size: 13.5px;
}
.packages-table tr:hover td { background: rgba(30, 41, 59, 0.4); }

/* Modals & Toasts */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(9, 13, 22, 0.85);
  backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center;
  z-index: 999;
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-box {
  background: #0f172a;
  border: 1px solid var(--border-highlight);
  border-radius: var(--radius-lg);
  width: 90%; max-width: 760px; max-height: 85vh;
  display: flex; flex-direction: column;
  box-shadow: 0 20px 50px rgba(0,0,0,0.7);
}
.modal-header { padding: 20px 24px; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-close { background: transparent; border: none; color: var(--text-muted); font-size: 20px; cursor: pointer; }
.modal-body { padding: 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 20px; }

.code-block-wrapper { position: relative; background: #090d16; border: 1px solid var(--border-color); border-radius: var(--radius-md); padding: 16px; }
.code-block { font-family: 'Fira Code', monospace; font-size: 13px; color: #a5b4fc; white-space: pre-wrap; word-break: break-all; max-height: 250px; overflow-y: auto; }
.btn-copy-code { position: absolute; top: 10px; right: 10px; padding: 4px 10px; font-size: 11px; }

.toast-container { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 10px; z-index: 9999; }
.toast {
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--primary);
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  display: flex; align-items: center; gap: 12px;
  font-size: 13.5px;
  animation: slideIn 0.3s ease;
}
@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

@media (max-width: 900px) {
  .sim-grid { grid-template-columns: 1fr; }
  .node-inspector-drawer { width: 100%; right: -100%; }
}
