/* ==========================================================================
   GeoLead 3D - Ultra-Modern Cyberpunk & Executive Dark Glassmorphic Design
   ========================================================================== */

:root {
  --bg-primary: #060911;
  --bg-secondary: #0b1120;
  --bg-card: rgba(15, 23, 42, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --bg-glass: rgba(15, 23, 42, 0.65);
  
  --border-glass: rgba(0, 242, 254, 0.2);
  --border-glass-bright: rgba(0, 242, 254, 0.55);
  --border-dark: rgba(255, 255, 255, 0.09);

  --accent-cyan: #00f2fe;
  --accent-blue: #3b82f6;
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #a855f7;
  --accent-gradient: linear-gradient(135deg, #00f2fe 0%, #3b82f6 50%, #9333ea 100%);

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --glow-cyan: 0 0 25px rgba(0, 242, 254, 0.4);
  --glow-emerald: 0 0 25px rgba(16, 185, 129, 0.4);
  --glow-blue: 0 0 25px rgba(59, 130, 246, 0.4);
  --glow-purple: 0 0 25px rgba(168, 85, 247, 0.4);

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-xl: 30px;
  --radius-full: 9999px;

  --font-ar: 'Cairo', 'Tajawal', sans-serif;
  --font-en: 'Outfit', sans-serif;
  --transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

/* Custom Sleek Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: rgba(0, 242, 254, 0.25);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-cyan);
}

/* Background Animated Gradient Mesh */
.bg-gradient-mesh {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: 
    radial-gradient(circle at 15% 25%, rgba(0, 242, 254, 0.12) 0%, transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(168, 85, 247, 0.12) 0%, transparent 50%),
    radial-gradient(circle at 50% 50%, rgba(15, 23, 42, 0.92) 0%, #060911 100%);
  z-index: -2;
  pointer-events: none;
}

/* 3D WebGL Canvas Container */
#threejs-canvas-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: auto;
}

/* Glassmorphism Surface */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
  transition: var(--transition);
}

.glass-panel:hover {
  border-color: var(--border-glass-bright);
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.15rem 2.5rem;
  background: rgba(6, 9, 17, 0.78);
  backdrop-filter: blur(24px);
  border-bottom: 1px solid var(--border-dark);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.brand-icon {
  width: 48px;
  height: 48px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #060911;
  font-size: 1.55rem;
  box-shadow: var(--glow-cyan);
  animation: float-icon 4s ease-in-out infinite;
}

@keyframes float-icon {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.brand-text h1 {
  font-size: 1.4rem;
  font-weight: 900;
  background: linear-gradient(90deg, #ffffff, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-text span {
  font-size: 0.82rem;
  color: var(--text-muted);
  display: block;
}

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

/* Badges */
.badge-tech {
  padding: 0.38rem 0.9rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(0, 242, 254, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 242, 254, 0.3);
}

.badge-pulse {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent-emerald);
  box-shadow: 0 0 12px var(--accent-emerald);
  animation: pulse-dot 1.8s infinite;
}

@keyframes pulse-dot {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.35); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.68rem 1.4rem;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  text-decoration: none;
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-cyan) 0%, #0284c7 100%);
  color: #060911;
  box-shadow: var(--glow-cyan);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(0, 242, 254, 0.6);
}

.btn-emerald {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: var(--glow-emerald);
}

.btn-emerald:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(16, 185, 129, 0.6);
}

.btn-purple {
  background: linear-gradient(135deg, #a855f7 0%, #7e22ce 100%);
  color: #ffffff;
  box-shadow: var(--glow-purple);
}

.btn-purple:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px rgba(168, 85, 247, 0.6);
}

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--border-glass-bright);
}

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: var(--radius-md);
}

/* Main Layout */
.main-layout {
  max-width: 1480px;
  margin: 0 auto;
  padding: 2.25rem 2.5rem 6rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

/* 3D Scene Controls Badge */
.scene-overlay-badge {
  position: absolute;
  top: 1.5rem;
  left: 1.5rem;
  background: rgba(6, 9, 17, 0.88);
  backdrop-filter: blur(16px);
  padding: 0.55rem 1.15rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-glass);
  font-size: 0.82rem;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 0.6rem;
  z-index: 10;
  pointer-events: none;
}

/* Hero & Search Section */
.hero-search-card {
  position: relative;
  padding: 2.5rem;
  overflow: hidden;
}

.hero-header {
  margin-bottom: 2rem;
}

.hero-header h2 {
  font-size: 2rem;
  font-weight: 900;
  margin-bottom: 0.45rem;
  display: flex;
  align-items: center;
  gap: 0.85rem;
  background: linear-gradient(90deg, #ffffff, var(--accent-cyan));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-header p {
  color: var(--text-muted);
  font-size: 1rem;
}

/* Search Form Grid */
.search-form-grid {
  display: grid;
  grid-template-columns: 1.3fr 1.3fr 0.8fr auto;
  gap: 1.35rem;
  align-items: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.form-group label {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

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

.input-wrapper i {
  position: absolute;
  right: 1.15rem;
  color: var(--accent-cyan);
  font-size: 1.05rem;
  pointer-events: none;
}

.form-control {
  width: 100%;
  background: rgba(6, 9, 17, 0.82);
  border: 1px solid var(--border-glass);
  color: var(--text-main);
  font-family: inherit;
  font-size: 0.96rem;
  padding: 0.9rem 2.95rem 0.9rem 1.15rem;
  border-radius: var(--radius-md);
  transition: var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 20px rgba(0, 242, 254, 0.35);
  background: rgba(15, 23, 42, 0.95);
}

select.form-control {
  appearance: none;
  cursor: pointer;
}

/* Quick Tags */
.quick-tags-wrapper {
  margin-top: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.quick-tags-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-left: 0.5rem;
}

.tag-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
  padding: 0.35rem 0.95rem;
  border-radius: var(--radius-full);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.tag-btn:hover {
  background: rgba(0, 242, 254, 0.16);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  transform: translateY(-2px);
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1.35rem;
}

.metric-card {
  padding: 1.65rem;
  display: flex;
  align-items: center;
  gap: 1.35rem;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--accent-cyan);
}

.metric-card.emerald::before { background: var(--accent-emerald); }
.metric-card.amber::before { background: var(--accent-amber); }
.metric-card.purple::before { background: var(--accent-purple); }

.metric-icon-box {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: rgba(0, 242, 254, 0.12);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
}

.metric-card.emerald .metric-icon-box { background: rgba(16, 185, 129, 0.12); color: var(--accent-emerald); }
.metric-card.amber .metric-icon-box { background: rgba(245, 158, 11, 0.12); color: var(--accent-amber); }
.metric-card.purple .metric-icon-box { background: rgba(168, 85, 247, 0.12); color: var(--accent-purple); }

.metric-data h4 {
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.metric-data .metric-value {
  font-size: 1.9rem;
  font-weight: 900;
  font-family: var(--font-en), var(--font-ar);
  color: var(--text-main);
}

/* Results Card */
.results-card {
  padding: 2.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.75rem;
}

.results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.results-title-group h3 {
  font-size: 1.45rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.results-title-group span {
  font-size: 0.88rem;
  color: var(--text-muted);
}

.results-toolbar {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.table-filter-input {
  background: rgba(6, 9, 17, 0.88);
  border: 1px solid var(--border-glass);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 0.9rem;
  outline: none;
  min-width: 240px;
  transition: var(--transition);
}

.table-filter-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 15px rgba(0, 242, 254, 0.25);
}

/* View Mode Switcher (Table vs 3D Cards) */
.view-mode-toggle {
  display: flex;
  background: rgba(6, 9, 17, 0.85);
  padding: 0.25rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-dark);
}

.view-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  transition: var(--transition);
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.view-btn.active {
  background: rgba(0, 242, 254, 0.15);
  color: var(--accent-cyan);
  font-weight: 700;
}

/* Sticky Bulk Action Bar */
.bulk-actions-bar {
  display: none;
  background: linear-gradient(90deg, rgba(15, 23, 42, 0.95), rgba(30, 41, 59, 0.95));
  border: 1px solid var(--border-glass-bright);
  padding: 0.85rem 1.5rem;
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
  animation: slide-down 0.3s ease forwards;
}

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

/* Responsive Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-dark);
}

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

.leads-table th {
  background: rgba(6, 9, 17, 0.9);
  color: var(--accent-cyan);
  padding: 1.1rem 1.25rem;
  font-weight: 800;
  border-bottom: 1px solid var(--border-glass);
  white-space: nowrap;
}

.leads-table td {
  padding: 1.1rem 1.25rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  vertical-align: middle;
  transition: var(--transition);
}

.leads-table tbody tr {
  background: rgba(15, 23, 42, 0.45);
}

.leads-table tbody tr:hover {
  background: rgba(0, 242, 254, 0.08);
}

.leads-table input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent-cyan);
  cursor: pointer;
}

.lead-name-cell {
  font-weight: 800;
  color: #fff;
  font-size: 0.98rem;
  cursor: pointer;
  transition: var(--transition);
}

.lead-name-cell:hover {
  color: var(--accent-cyan);
}

.lead-sub-info {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin-top: 0.25rem;
}

/* 3D Interactive Grid Cards View */
.leads-grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.35rem;
}

.lead-card-3d {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.15rem;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

.lead-card-3d:hover {
  transform: translateY(-6px);
  border-color: var(--accent-cyan);
  box-shadow: 0 15px 35px rgba(0, 242, 254, 0.25);
  background: rgba(30, 41, 59, 0.9);
}

.lead-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.lead-avatar-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: rgba(0, 242, 254, 0.12);
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border: 1px solid rgba(0, 242, 254, 0.25);
}

.lead-card-body h4 {
  font-size: 1.1rem;
  font-weight: 800;
  color: #fff;
  margin-bottom: 0.35rem;
}

.lead-card-details {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  font-size: 0.86rem;
  color: var(--text-muted);
}

.lead-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.85rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Action Buttons Inside Table & Cards */
.table-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-action-wa {
  background: rgba(37, 211, 102, 0.16);
  color: #25d366;
  border: 1px solid rgba(37, 211, 102, 0.4);
  padding: 0.45rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  text-decoration: none;
}

.btn-action-wa:hover {
  background: #25d366;
  color: #060911;
  box-shadow: 0 0 18px rgba(37, 211, 102, 0.5);
  transform: translateY(-2px);
}

.btn-action-map {
  background: rgba(59, 130, 246, 0.16);
  color: var(--accent-blue);
  border: 1px solid rgba(59, 130, 246, 0.35);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  text-decoration: none;
  transition: var(--transition);
}

.btn-action-map:hover {
  background: var(--accent-blue);
  color: #060911;
}

/* Status Badges */
.status-badge {
  padding: 0.32rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.8rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.status-badge.not_sent {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.status-badge.sent {
  background: rgba(16, 185, 129, 0.18);
  color: var(--accent-emerald);
  border: 1px solid rgba(16, 185, 129, 0.35);
}

.status-badge.replied {
  background: rgba(0, 242, 254, 0.18);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 242, 254, 0.35);
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(16px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  opacity: 0;
  pointer-events: none;
  transition: var(--transition);
}

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

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-glass-bright);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.8);
  display: flex;
  flex-direction: column;
}

.modal-header {
  padding: 1.6rem 2rem;
  border-bottom: 1px solid var(--border-dark);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.35rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}

.modal-body {
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.35rem;
}

.modal-footer {
  padding: 1.35rem 2rem;
  border-top: 1px solid var(--border-dark);
  display: flex;
  justify-content: flex-end;
  gap: 0.95rem;
}

/* Code Snippet Box in n8n Modal */
.code-preview-box {
  background: #020617;
  border: 1px solid rgba(0, 242, 254, 0.2);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.85rem;
  color: #38bdf8;
  max-height: 320px;
  overflow-y: auto;
  direction: ltr;
  text-align: left;
  white-space: pre-wrap;
}

/* Template Variable Pills */
.template-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.45rem;
}

.var-pill {
  background: rgba(0, 242, 254, 0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(0, 242, 254, 0.35);
  padding: 0.25rem 0.7rem;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.var-pill:hover {
  background: var(--accent-cyan);
  color: #060911;
  transform: translateY(-1px);
}

/* Toast Notifications */
#toast-container {
  position: fixed;
  bottom: 2.25rem;
  left: 2.25rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.toast {
  background: rgba(15, 23, 42, 0.96);
  backdrop-filter: blur(20px);
  border-left: 4px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  padding: 1.1rem 1.5rem;
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 300px;
  animation: slide-in 0.3s ease forwards;
}

.toast.success { border-left-color: var(--accent-emerald); }
.toast.error { border-left-color: var(--accent-rose); }
.toast.warning { border-left-color: var(--accent-amber); }

@keyframes slide-in {
  from { transform: translateX(-100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

@media (max-width: 680px) {
  .app-header {
    padding: 1rem 1.25rem;
  }
  .main-layout {
    padding: 1rem 1.25rem 4rem;
  }
  .search-form-grid {
    grid-template-columns: 1fr;
  }
  .metrics-grid {
    grid-template-columns: 1fr;
  }
  .results-header {
    flex-direction: column;
    align-items: stretch;
  }
}
