/* ==========================================================================
   Sales Engine CRM - Multi-User RBAC & Clean Stylesheet
   ========================================================================== */

:root {
  --bg-body: #0b0f19;
  --bg-header: #131b2e;
  --bg-card: #192338;
  --bg-card-hover: #1f2d48;
  --bg-input: #1f2b42;
  --border-color: #283754;
  --border-light: #35476c;

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

  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-purple: #8b5cf6;
  --accent-rose: #f43f5e;
  --leak-red: #ef4444;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-body);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Profile */
.app-header {
  background: var(--bg-header);
  border-bottom: 1px solid var(--border-color);
  padding: 0.85rem 1.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-weight: 800;
  font-size: 1.2rem;
  color: #fff;
}

.brand-icon {
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-cyan));
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 800;
}

.nav-tabs {
  display: flex;
  background: var(--bg-body);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  gap: 4px;
}

.nav-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.5rem 1.25rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-btn:hover {
  color: #fff;
}

.nav-btn.active {
  background: var(--accent-blue);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* User Profile Badge in Header */
.user-profile-badge {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.role-badge {
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.role-badge-admin {
  background: linear-gradient(135deg, var(--accent-purple), #7c3aed);
  color: #fff;
}

.role-badge-rep {
  background: linear-gradient(135deg, var(--accent-blue), #2563eb);
  color: #fff;
}

/* Revenue Goal Widget */
.goal-widget {
  background: var(--bg-body);
  border: 1px solid var(--border-color);
  padding: 0.4rem 0.8rem;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 190px;
}

.goal-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.goal-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.goal-value {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--accent-green);
}

.goal-bar-bg {
  flex: 1;
  height: 6px;
  background: rgba(255,255,255,0.1);
  border-radius: 3px;
  overflow: hidden;
}

.goal-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-green));
  border-radius: 3px;
}

/* Buttons */
.btn {
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
}

.btn:hover {
  background: var(--border-color);
}

.btn-primary {
  background: var(--accent-blue);
  color: #fff;
  border: none;
}

.btn-primary:hover {
  background: #2563eb;
}

.btn-success {
  background: var(--accent-green);
  color: #fff;
  border: none;
}

.btn-success:hover {
  background: #059669;
}

.btn-purple {
  background: var(--accent-purple);
  color: #fff;
  border: none;
}

.btn-purple:hover {
  background: #7c3aed;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
  color: #fff;
}

.btn-sm {
  padding: 0.3rem 0.7rem;
  font-size: 0.78rem;
}

/* Main Container */
.main-container {
  flex: 1;
  padding: 1.5rem;
  max-width: 1800px;
  margin: 0 auto;
  width: 100%;
}

.view-panel {
  display: none;
}

.view-panel.active {
  display: block;
}

/* Leak Alert Bar */
.leak-bar {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 0.75rem 1.25rem;
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  font-size: 0.85rem;
}

.leak-badge {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

/* Lead Temperature Badges */
.temp-badge-hot {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  font-weight: 800;
}

.temp-badge-warm {
  background: rgba(245, 158, 11, 0.2);
  color: #f59e0b;
  border: 1px solid rgba(245, 158, 11, 0.4);
  font-weight: 800;
}

.temp-badge-cold {
  background: rgba(6, 182, 212, 0.2);
  color: #06b6d4;
  border: 1px solid rgba(6, 182, 212, 0.4);
  font-weight: 800;
}

/* FLOATING SMART CALL NOTIFICATION BANNER */
.notification-banner-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 420px;
  width: 100%;
}

.notification-toast {
  background: #1e293b;
  border: 2px solid var(--accent-amber);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.6);
  animation: slideInRight 0.3s ease-out forwards;
}

.notification-toast.hot-alert {
  border-color: var(--leak-red);
}

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

/* LOGIN OVERLAY & MODALS */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(135deg, #090d16, #121826);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  padding: 2.25rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 15px 35px rgba(0,0,0,0.6);
}

.demo-btn-grid {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px dashed var(--border-color);
}

.kanban-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(240px, 1fr));
  gap: 1rem;
  overflow-x: auto;
  padding-bottom: 1rem;
  min-height: calc(100vh - 200px);
}

.kanban-col {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
}

.kanban-col-header {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.02);
}

.col-title {
  font-weight: 700;
  font-size: 0.88rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.col-count {
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
}

.col-sum {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent-green);
}

.cards-container {
  padding: 0.75rem;
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-height: 150px;
}

.cards-container.drag-over {
  background: rgba(59, 130, 246, 0.1);
  border: 2px dashed var(--accent-blue);
}

.lead-card {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem;
  cursor: grab;
  transition: all 0.2s ease;
}

.lead-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.lead-card.leak-card {
  border: 1.5px solid var(--leak-red);
}

.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 0.4rem;
}

.card-name {
  font-weight: 700;
  font-size: 0.92rem;
  color: #fff;
}

.card-company {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 0.4rem 0;
}

.tag-pill {
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--bg-card);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.tag-source { color: var(--accent-cyan); border-color: rgba(6,182,212,0.3); }

.card-meta-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.4rem;
  padding-top: 0.4rem;
  border-top: 1px dashed var(--border-color);
}

.card-value-row {
  margin-top: 0.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card);
  padding: 0.4rem 0.6rem;
  border-radius: var(--radius-sm);
}

.table-controls {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.search-input {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  min-width: 240px;
}

.filter-select {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.5rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
}

.table-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow-x: auto;
}

.clean-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  white-space: nowrap;
}

.clean-table th {
  background: rgba(255,255,255,0.02);
  color: var(--text-muted);
  padding: 0.8rem 1rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}

.clean-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  font-size: 0.85rem;
}

.clean-table tr:hover {
  background: var(--bg-card-hover);
}

.status-badge {
  padding: 3px 8px;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 700;
  display: inline-flex;
}

.dash-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 0.5rem;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.kpi-box {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.2rem;
}

.kpi-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 0.3rem;
}

.kpi-num {
  font-size: 1.6rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.1;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
}

.charts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.chart-box {
  position: relative;
  height: 250px;
  width: 100%;
}

.scenarios-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem;
  margin-bottom: 2rem;
}

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

.scenario-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  text-align: center;
}

.scenario-card.exp {
  border-color: var(--accent-blue);
}

.scenario-rev {
  font-size: 1.8rem;
  font-weight: 800;
  margin: 0.5rem 0 0.2rem 0;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0,0,0,0.85);
  backdrop-filter: blur(6px);
  z-index: 5000 !important;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-overlay.active {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.modal-card {
  position: relative;
  z-index: 5001 !important;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 750px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.modal-head {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-body {
  padding: 1.5rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

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

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

.form-group.full {
  grid-column: span 2;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
}

.form-input, .form-select, .form-textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.modal-foot {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

.text-green { color: var(--accent-green) !important; }
.text-red { color: var(--leak-red) !important; }
.text-cyan { color: var(--accent-cyan) !important; }
.text-amber { color: var(--accent-amber) !important; }

/* Notification Banner & Instant Toast Cut Styles */
.notification-banner-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 420px;
  width: calc(100vw - 3rem);
  pointer-events: none;
}

.notification-toast {
  pointer-events: auto;
  background: var(--bg-card);
  border: 1px solid var(--accent-amber);
  border-left: 5px solid var(--accent-amber);
  border-radius: var(--radius-md);
  padding: 1rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.notification-toast.hot-alert {
  border-color: var(--leak-red);
  border-left-color: var(--leak-red);
}

.notification-toast.toast-exit {
  opacity: 0 !important;
  transform: translateX(120%) scale(0.85) !important;
}

/* ==========================================================================
   AUTHENTICATION & LOGIN OVERLAY STYLING
   ========================================================================== */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(11, 15, 25, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 420px;
  padding: 2rem;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.demo-btn-grid {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ==========================================================================
   SMART AUTO DIALER STYLING
   ========================================================================== */
#dialerActivePanel {
  position: relative;
  transition: all 0.3s ease;
}

#dialerActivePanel:has(.status-badge[style*="var(--accent-green)"]) {
  box-shadow: 0 0 15px rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.4) !important;
}

#dialerActivePanel:has(.status-badge[style*="var(--accent-amber)"]) {
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.4) !important;
}

.progress-bar-bg {
  position: relative;
  height: 6px;
  background: var(--border-color);
  border-radius: var(--radius-full);
  overflow: hidden;
}

#dialerCountdownBar {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent-amber), var(--accent-purple));
  box-shadow: 0 0 8px var(--accent-amber);
}

.dialer-queue-item {
  transition: transform 0.2s ease, border-color 0.2s ease;
}

.dialer-queue-item:hover {
  transform: translateY(-1px);
  border-color: var(--border-light) !important;
}


