/* ==========================================================================
   SMQ CRM & AGENCY OPERATING SYSTEM - COMPLETE STYLESHEET
   ========================================================================== */

:root {
  --bg-dark: #070A0F;
  --bg-sidebar: #0B1120;
  --bg-card: #0F172A;
  --bg-card-hover: #1E293B;
  --bg-input: #1E293B;
  --border-color: #1E293B;
  --border-light: #334155;
  --border-focus: #3B82F6;
  --text-main: #F8FAFC;
  --text-muted: #94A3B8;
  --text-dim: #64748B;
  --primary-start: #3B82F6;
  --primary-mid: #2563EB;
  --primary-end: #1D4ED8;
  --accent-navy: #1E3A5F;
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #06B6D4;
  --purple: #8B5CF6;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 14px rgba(0,0,0,0.5);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.6);
  --sidebar-width: 260px;
  --header-height: 64px;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-dark);
  color: var(--text-main);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

/* Layout */
.app-container, .crm-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Sidebar */
.sidebar, .crm-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 100;
}

.sidebar-brand, .crm-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.6);
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--primary-start), var(--primary-end));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 0 16px rgba(37,99,235,0.4);
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-name {
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

.brand-tag, .brand-sub {
  font-size: 11px;
  color: var(--primary-start);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.sidebar-nav, .crm-nav {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav::-webkit-scrollbar, .crm-nav::-webkit-scrollbar {
  width: 5px;
}
.sidebar-nav::-webkit-scrollbar-thumb, .crm-nav::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.nav-section-title, .nav-group-title {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--text-dim);
  padding: 14px 10px 6px;
  letter-spacing: 1px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  color: var(--text-muted);
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  font-size: 13px;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background-color: var(--bg-card-hover);
  color: var(--text-main);
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(37,99,235,0.2), rgba(37,99,235,0.05));
  color: #60A5FA;
  border-left: 3px solid var(--primary-start);
  font-weight: 600;
}

.nav-item i {
  width: 18px;
  text-align: center;
  font-size: 14px;
}

.nav-item.text-danger {
  color: #F87171;
  margin-top: 6px;
}
.nav-item.text-danger:hover {
  background-color: rgba(239,68,68,0.15);
  color: #EF4444;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  background: rgba(15, 23, 42, 0.4);
}

/* Main Content Area */
.main-content, .crm-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--bg-dark);
}

/* Topbar Header */
.topbar, .crm-header {
  height: var(--header-height);
  background-color: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 90;
}
/* Transition for sticky header */
.topbar {
  transition: all 0.3s ease;
}
.topbar.scrolled {
  background-color: rgba(15, 23, 42, 1);
  height: 48px;
}

.topbar-search, .header-search {
  position: relative;
  width: 380px;
}

.topbar-search i, .search-icon {
  position: absolute;
  left: 14px;
  top: 11px;
  color: var(--text-dim);
  font-size: 13px;
}

.topbar-search input, .search-input {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 8px 14px 8px 38px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: all 0.15s;
}

.topbar-search input:focus, .search-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.25);
  background-color: #172033;
}

.search-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #111827;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  margin-top: 6px;
  box-shadow: var(--shadow-lg);
  max-height: 380px;
  overflow-y: auto;
  z-index: 1000;
}

.topbar-actions, .header-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

.notif-btn, .header-btn {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}

.notif-btn:hover, .header-btn:hover {
  color: var(--text-main);
  border-color: var(--border-focus);
}

.badge-count, .notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: var(--primary-start);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 10px;
  border: 2px solid var(--bg-dark);
}

.dropdown-card {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 320px;
  background: #111827;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  overflow: hidden;
}

.dropdown-card-header {
  padding: 12px 16px;
  background: #1E293B;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.notif-item {
  display: block;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
  color: var(--text-main);
  transition: background 0.15s;
}
.notif-item:hover { background: #1E293B; }
.notif-title { font-weight: 600; font-size: 13px; }
.notif-body { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.notif-time { font-size: 10px; color: var(--text-dim); margin-top: 4px; }

.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-start), var(--primary-end));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  border: 1px solid var(--border-light);
  box-shadow: 0 0 10px rgba(37,99,235,0.3);
}

/* Page Body Container */
.page-body, .crm-body {
  padding: 28px;
  flex: 1;
}

/* Page Headings */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.5px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 2px;
}

.head-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  line-height: 1.4;
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary-start), var(--primary-end));
  color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,0.35);
}
.btn-primary:hover {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37,99,235,0.5);
}

.btn-secondary {
  background-color: var(--bg-input);
  border-color: var(--border-color);
  color: var(--text-main);
}
.btn-secondary:hover {
  background-color: var(--bg-card-hover);
  border-color: var(--border-light);
}

.btn-success { background-color: var(--success); color: #fff; }
.btn-success:hover { opacity: 0.95; }
.btn-danger { background-color: var(--danger); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* Cards & Containers */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 22px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  margin-bottom: 18px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* Metrics Grid */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}

.metric-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  position: relative;
  transition: transform 0.15s, border-color 0.15s;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-light);
}

.metric-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.metric-val, .metric-value {
  font-size: 24px;
  font-weight: 800;
  margin: 6px 0 4px;
  color: #fff;
}

.metric-sub {
  font-size: 12px;
  color: var(--text-muted);
}

.metric-icon {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 24px;
  height: 24px;
  color: #60A5FA;
  opacity: 0.8;
}

/* Pipeline Widget */
.pipeline-widget {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
  background: var(--bg-input);
  padding: 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.pipe-step {
  text-align: center;
  padding: 12px 8px;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
}

.pipe-step-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
}

.pipe-step-count {
  font-size: 18px;
  font-weight: 800;
  color: #fff;
  margin-top: 4px;
}

/* Tables */
.table-container {
  overflow-x: auto;
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13px;
}

.table th {
  background-color: rgba(30, 41, 59, 0.6);
  color: var(--text-dim);
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  vertical-align: middle;
}

.table tr:hover td {
  background-color: rgba(30, 41, 59, 0.4);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  text-transform: capitalize;
}

.badge-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: currentColor;
}

.badge-new { background: rgba(59,130,246,0.15); color: #60A5FA; }
.badge-contacted { background: rgba(6,182,212,0.15); color: #22D3EE; }
.badge-qualified { background: rgba(139,92,246,0.15); color: #A78BFA; }
.badge-proposal { background: rgba(245,158,11,0.15); color: #FBBF24; }
.badge-negotiation { background: rgba(249,115,22,0.15); color: #FB923C; }
.badge-won, .badge-paid, .badge-active, .badge-completed { background: rgba(16,185,129,0.15); color: #34D399; }
.badge-lost, .badge-cancelled, .badge-failed { background: rgba(239,68,68,0.15); color: #F87171; }
.badge-pending, .badge-processing { background: rgba(234,179,8,0.15); color: #FACC15; }

/* Forms */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  color: var(--text-main);
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.25);
}

textarea.form-control {
  min-height: 90px;
  resize: vertical;
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-box {
  width: 100%;
  max-width: 540px;
  background: #111827;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.modal-header {
  padding: 16px 20px;
  background: #1E293B;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.modal-title { font-size: 16px; font-weight: 700; color: #fff; }
.modal-close { background: none; border: none; font-size: 20px; color: var(--text-muted); cursor: pointer; }
.modal-close:hover { color: #fff; }
.modal-body { padding: 20px; max-height: 75vh; overflow-y: auto; }
.modal-footer { padding: 14px 20px; background: #1E293B; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 10px; }

/* Tabs */
.tabs-header {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.tab-btn {
  background: none;
  border: none;
  padding: 10px 18px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.tab-btn:hover { color: #fff; }
.tab-btn.active { color: #60A5FA; border-bottom-color: var(--primary-start); }

.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* Kanban Board Pipeline */
.kanban-board, .pipeline-board {
  display: flex;
  gap: 16px;
  overflow-x: auto;
  padding-bottom: 24px;
  align-items: flex-start;
  min-height: calc(100vh - 200px);
}

.kanban-board::-webkit-scrollbar, .pipeline-board::-webkit-scrollbar {
  height: 8px;
}
.kanban-board::-webkit-scrollbar-thumb, .pipeline-board::-webkit-scrollbar-thumb {
  background: var(--border-light);
  border-radius: 4px;
}

.kanban-column, .pipeline-col {
  flex: 0 0 300px;
  width: 300px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 200px);
  box-shadow: var(--shadow-sm);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.kanban-header, .pipeline-header {
  padding: 14px 16px;
  background: rgba(30, 41, 59, 0.5);
  border-bottom: 1px solid var(--border-color);
  border-top-left-radius: var(--radius-md);
  border-top-right-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 13px;
}

.kanban-column-body, .pipeline-cards {
  padding: 12px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 200px;
  transition: background-color 0.2s, border-color 0.2s;
}

.kanban-column-body::-webkit-scrollbar, .pipeline-cards::-webkit-scrollbar {
  width: 5px;
}
.kanban-column-body::-webkit-scrollbar-thumb, .pipeline-cards::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

.kanban-column-body.drag-over, .pipeline-cards.drag-over {
  background: rgba(59, 130, 246, 0.08);
  border: 2px dashed var(--primary-start);
  border-radius: var(--radius-sm);
}

.kanban-card, .lead-card {
  background: #111827;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
  cursor: grab;
  user-select: none;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

.kanban-card:hover, .lead-card:hover {
  border-color: var(--primary-start);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

.kanban-card:active, .lead-card:active {
  cursor: grabbing;
}

.kanban-card.dragging, .lead-card.dragging {
  opacity: 0.4;
  transform: scale(0.96);
  border: 2px dashed var(--primary-start);
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
  animation: modalFadeIn 0.2s ease;
}

.modal-overlay.active, .modal-overlay.show {
  display: flex;
}

.modal-box {
  background: #111827;
  border: 1px solid #2D3748;
  border-radius: var(--radius-md);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalSlideUp 0.2s ease;
}

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(15, 23, 42, 0.6);
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all 0.15s;
}

.modal-close:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.modal-body {
  padding: 20px;
  max-height: calc(85vh - 120px);
  overflow-y: auto;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background: rgba(15, 23, 42, 0.4);
}

@keyframes modalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modalSlideUp {
  from { transform: translateY(20px) scale(0.98); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

/* Responsive */
@media (max-width: 991px) {
  .sidebar, .crm-sidebar {
    display: none;
  }
  .topbar-search, .header-search {
    width: 220px;
  }
}
