/* ==============================================
   Lead Hunter V2 Dashboard — Premium Dark Theme
   ============================================== */

:root {
  --bg: #0a0a1a;
  --bg-panel: #111128;
  --bg-card: #1a1a3e;
  --bg-hover: #222252;
  --primary: #667eea;
  --primary-light: #8b9cf7;
  --accent: #764ba2;
  --success: #0cce6b;
  --warning: #ffa400;
  --danger: #ff4e42;
  --text: #e8e8f0;
  --text-muted: #8888aa;
  --border: rgba(255,255,255,0.08);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 24px rgba(0,0,0,0.3);
  --transition: all 0.25s cubic-bezier(0.4,0,0.2,1);
}

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

body {
  font-family:'Inter',system-ui,sans-serif;
  background:var(--bg);
  color:var(--text);
  line-height:1.6;
  overflow-x:hidden;
}

/* ─── Header ─── */
.header {
  display:flex; justify-content:space-between; align-items:center;
  padding:16px 24px;
  background:rgba(17,17,40,0.95);
  backdrop-filter:blur(20px);
  border-bottom:1px solid var(--border);
  position:sticky; top:0; z-index:50;
}
.header h1 { font-size:1.3rem; font-weight:700; cursor:pointer; }
.header-left { display:flex; align-items:center; gap:12px; }
.badge {
  font-size:0.7rem; padding:4px 10px;
  background:linear-gradient(135deg,var(--primary),var(--accent));
  border-radius:50px; font-weight:600; text-transform:uppercase;
}
.usage-mini {
  display:flex; align-items:center; gap:8px;
  font-size:0.85rem; color:var(--text-muted);
}
.usage-dot {
  width:8px; height:8px; border-radius:50%;
  background:var(--success); animation:pulse 2s infinite;
}
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:0.4;} }

/* ===== VIEWS MANAGER ===== */
.view-container {
  display: none;
  padding: 24px;
  max-width: 1400px;
  margin: 0 auto;
  animation: fadeIn 0.3s ease;
}
.view-container.active { display: block; }

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

/* ─── Toolbar ─── */
.toolbar {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
}
.toolbar h2 { font-size: 1.4rem; font-weight: 600; }
.tools { display: flex; gap: 12px; align-items:center; }
.breadcrumb { display:flex; align-items:center; gap:8px; font-size:1.4rem; font-weight:600; }
.back-link { color:var(--text-muted); cursor:pointer; transition:var(--transition); }
.back-link:hover { color:var(--primary-light); }
.separator { color:var(--text-muted); font-size:1rem; }

/* ─── Buttons ─── */
.btn {
  padding:10px 18px; border:none; border-radius:var(--radius-sm);
  font-weight:600; font-size:0.85rem; cursor:pointer;
  transition:var(--transition); display:inline-flex;
  align-items:center; gap:6px; color:var(--text); background:var(--bg-card);
  border:1px solid var(--border);
}
.btn:hover:not(:disabled) { background:var(--bg-hover); transform:translateY(-1px); }
.btn:active:not(:disabled) { transform:translateY(0); }
.btn:disabled { opacity:0.5; cursor:not-allowed; }

.btn-accent { background:var(--primary); color:#fff; border-color:transparent; }
.btn-accent:hover:not(:disabled) { background:var(--primary-light); }
.btn-discover { background:linear-gradient(135deg,#667eea,#764ba2); color:#fff; border:none; }
.btn-scan { background:linear-gradient(135deg,#0cce6b,#06a155); color:#fff; border:none; }
.btn-success { background:var(--success); color:#000; border:none; }

/* ===== VIEW 1: SECTORS GRID ===== */
.sectors-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;
}
.sector-card {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  cursor: pointer; transition: var(--transition);
}
.sector-card:hover { transform: translateY(-3px); border-color: var(--primary); box-shadow: var(--shadow); }
.sector-card h3 { margin-bottom: 12px; font-size: 1.1rem; }
.sector-stats { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 15px; }
.sector-bar { width:100%; height:6px; background:var(--bg-card); border-radius:10px; overflow:hidden; }
.sector-bar-fill { height:100%; background:var(--success); width:0%; }

/* ===== VIEW 2: LINE ITEMS (Table) ===== */
.table-card {
  background: var(--bg-panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow-x: auto;
}
.line-items-table {
  width: 100%; border-collapse: collapse; min-width: 900px;
}
.line-items-table th {
  text-align: left; padding: 14px 16px; font-size: 0.75rem; text-transform: uppercase;
  color: var(--text-muted); border-bottom: 1px solid var(--border); font-weight: 600;
  background: rgba(0,0,0,0.2);
}
.line-items-table td {
  padding: 14px 16px; font-size: 0.9rem; border-bottom: 1px solid var(--border);
}
.line-items-table tr:hover td { background: var(--bg-hover); }
.status-dot {
  width: 12px; height: 12px; border-radius: 50%; display: inline-block;
}
.dot-green { background: var(--success); box-shadow: 0 0 8px rgba(12,206,107,0.4); }
.dot-yellow { background: var(--warning); box-shadow: 0 0 8px rgba(255,164,0,0.4); }
.dot-gray { background: #555; }

.themes-section { margin-top: 40px; }
.themes-section h3 { margin-bottom: 16px; font-size: 1.1rem; color: var(--text-muted); }
.themes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.theme-card { background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden; }
.mock-iframe { height: 250px; background: var(--bg-card); display:flex; align-items:center; justify-content:center; color:var(--text-muted); }

/* ===== VIEW 3: DISCOVERY MATCH ===== */
.discovery-layout {
  display: grid; grid-template-columns: 350px 1fr; gap: 20px;
  height: 450px; margin-bottom: 20px;
}
.discovery-sidebar {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; display: flex; flex-direction: column; gap: 20px; overflow-y:auto;
}
.discovery-map-area {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.map-container { width: 100%; height: 100%; min-height:400px; }
.control-section h3 { font-size: 0.9rem; margin-bottom: 10px; color: var(--text-muted); }
.input-group { display: flex; gap: 8px; }
.input-group input, .disabled-input {
  flex: 1; padding: 10px 14px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: 0.9rem; outline: none; width:100%;
}
.input-group input:focus { border-color: var(--primary); }
.disabled-input { opacity: 0.7; cursor: not-allowed; }
.radius-control, .search-limit { display:flex; align-items:center; gap:10px; font-size:0.85rem; }
.radius-control input, .search-limit input { flex:1; accent-color:var(--primary); }

/* ===== VIEW 4: WORKSPACE ===== */
.workspace-layout {
  display: grid; grid-template-columns: 280px 1fr; gap: 20px;
}
.workspace-sidebar {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px;
}
.workspace-main {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius); overflow:hidden;
}

.pipeline-steps { display: flex; flex-direction: column; gap: 8px; }
.btn-step { width: 100%; text-align: left; padding: 12px; }
.btn-step .step-num {
  display: inline-block; width: 24px; height: 24px; line-height: 24px; text-align: center;
  background: var(--primary); color: #fff; border-radius: 4px; font-size: 0.75rem; margin-right: 8px;
}

.status-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.status-card { text-align: center; padding: 12px 0; background: var(--bg-card); border-radius: var(--radius-sm); border: 1px solid var(--border); }
.status-num { font-size: 1.4rem; font-weight: 700; color: var(--primary-light); }
.status-label { font-size: 0.7rem; color: var(--text-muted); }

.result-tabs { display: flex; border-bottom: 1px solid var(--border); background:rgba(0,0,0,0.2); }
.tab { padding: 14px 20px; border: none; background: transparent; color: var(--text-muted); cursor: pointer; font-weight: 500; }
.tab.active { color: var(--primary-light); border-bottom: 2px solid var(--primary-light); }

.table-wrap { overflow-x: auto; padding: 20px; }
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding-bottom: 12px; border-bottom: 1px solid var(--border); color: var(--text-muted); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; }
.data-table td { padding: 12px 0; border-bottom: 1px solid var(--border); font-size: 0.85rem; }

/* ─── Modals & Overlays ─── */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  z-index: 100; align-items: center; justify-content: center;
}
.modal {
  background: var(--bg-panel); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; width: 400px; box-shadow: var(--shadow);
}
.modal h3 { margin-bottom: 10px; }

.loading-overlay { display: none; position: fixed; inset: 0; background: rgba(10,10,26,0.85); backdrop-filter: blur(8px); z-index: 900; align-items: center; justify-content: center; }
.loading-overlay.active { display: flex; }
.spinner { width: 48px; height: 48px; margin: 0 auto 16px; border: 4px solid var(--border); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-content { text-align: center; }

/* Toast */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 1000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius-sm); font-size: 0.85rem; animation: slideIn 0.3s ease; box-shadow: var(--shadow); }
.toast.success { background: var(--success); color: #000; }
.toast.error { background: var(--danger); color: #fff; }
.toast.info { background: var(--primary); color: #fff; }
@keyframes slideIn { from { transform: translateX(100px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* ─── CUSTOM CHECKBOX ─── */
.custom-cb {
  appearance: none; -webkit-appearance: none;
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-radius: 4px;
  background: var(--surface-1);
  cursor: pointer; position: relative;
  transition: all 0.2s ease;
  display: inline-block; vertical-align: middle;
}
.custom-cb:hover { border-color: var(--accent); }
.custom-cb:checked { background: var(--accent); border-color: var(--accent); }
.custom-cb:checked::after {
  content: '✔'; color: #fff; font-size: 13px; font-weight: bold;
  position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%);
}

/* ─── ACTION DROPDOWN ─── */
.action-dropdown { position: relative; display: inline-block; }
.action-btn {
  background: var(--surface-1); color: var(--text);
  border: 1px solid var(--border); padding: 6px 16px;
  border-radius: 4px; cursor: pointer; font-weight: 600;
  display: flex; align-items: center; gap: 8px; font-family: inherit;
}
.action-btn:hover { background: var(--surface-2); }
.action-dropdown-content {
  display: none; position: absolute; top: 100%; left: 0;
  background: var(--bg-panel); min-width: 160px;
  box-shadow: var(--shadow); border: 1px solid var(--border);
  border-radius: 4px; z-index: 1000; margin-top: 4px; padding: 4px 0;
}
.action-dropdown.active .action-dropdown-content { display: block; }
.action-dropdown-item {
  padding: 10px 16px; cursor: pointer; color: var(--text);
  display: block; width: 100%; text-align: left;
  border: none; background: none; font-size: 0.85rem; font-family: inherit;
}
.action-dropdown-item:hover { background: var(--surface-1); color: var(--accent); }
