/* Global Search */
.global-search-wrap {
  margin-bottom: 16px;
  position: relative;
}

.global-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
  position: relative;
}

.global-search:focus-within {
  border-color: var(--brand-primary);
  box-shadow: var(--focus-ring), var(--shadow-md);
}

.global-search input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
  background: transparent;
}

.global-search input::placeholder {
  color: var(--text-muted);
}

.global-search-kbd {
  padding: 2px 6px;
  font-size: 10px;
  font-family: monospace;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.global-search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
  display: none;
}

.global-search-results.show {
  display: block;
  animation: fadeInUp 0.15s var(--ease-out);
}

.global-search-result-group {
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.global-search-result-group:last-child {
  border-bottom: none;
}

.global-search-result-label {
  padding: 4px 14px;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.global-search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.global-search-result-item:hover {
  background: var(--bg-soft);
}

.global-search-result-item .result-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.global-search-result-item .result-info {
  flex: 1;
  min-width: 0;
}

.global-search-result-item .result-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.global-search-result-item .result-meta {
  font-size: 11px;
  color: var(--text-muted);
}

/* Dashboard */
.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.dashboard-card {
  background: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.dashboard-card-wide {
  grid-column: 1 / -1;
}

.dashboard-card-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-soft);
}

.dashboard-card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.dashboard-card-body {
  padding: 16px;
}

/* Dashboard Charts */
.chart-bar-h {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.chart-bar-h:last-child {
  margin-bottom: 0;
}

.chart-bar-h-label {
  width: 120px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-bar-h-track {
  flex: 1;
  height: 20px;
  background: var(--bg-tertiary);
  border-radius: 999px;
  overflow: hidden;
}

.chart-bar-h-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-sky));
  transition: width 0.6s var(--ease-out);
  min-width: 2px;
}

.chart-bar-h-value {
  width: 70px;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  flex-shrink: 0;
}

/* Pipeline Overview Bars */
.pipeline-overview-bars {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  height: 120px;
  padding-top: 10px;
}

.pipeline-overview-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  justify-content: flex-end;
}

.pipeline-overview-bar {
  width: 100%;
  border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, var(--stage-color, var(--brand-primary)), rgba(12, 43, 94, 0.7));
  transition: height 0.5s var(--ease-out);
  min-height: 4px;
  position: relative;
}

.pipeline-overview-bar:hover {
  filter: brightness(1.1);
}

.pipeline-overview-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
}

.pipeline-overview-label {
  font-size: 9px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

/* Activity Feed */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
}

.activity-item:last-child {
  border-bottom: none;
}

.activity-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}

.activity-text {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.activity-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

.activity-time {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Pending Actions */
.pending-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.pending-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-soft);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pending-item:hover {
  background: #fff;
  border-color: var(--border-hover);
  box-shadow: var(--shadow-sm);
}

.pending-item-icon {
  font-size: 14px;
}

.pending-item-text {
  flex: 1;
  color: var(--text-primary);
  font-weight: 500;
}

.pending-item-badge {
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 14px;
  padding: 10px 0;
}

.pagination-btn {
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: #fff;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.pagination-btn:hover:not(:disabled) {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
  box-shadow: var(--shadow-sm);
}

.pagination-btn.active {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-info {
  font-size: 11px;
  color: var(--text-muted);
  padding: 0 8px;
}

/* WhatsApp Templates Modal */
.whatsapp-templates {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 300px;
  overflow-y: auto;
}

.wa-template {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: var(--bg-soft);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.wa-template:hover {
  background: #fff;
  border-color: #25D366;
  box-shadow: var(--shadow-sm);
}

.wa-template-text {
  flex: 1;
  font-size: 12px;
  color: var(--text-primary);
}

.wa-template-name {
  font-size: 11px;
  font-weight: 600;
  color: var(--brand-green);
  margin-bottom: 2px;
}

/* Animation for page elements */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Paid button animation */
@keyframes paidPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(22, 163, 74, 0); }
}

.btn-paid-anim {
  position: relative;
  font-weight: 700 !important;
  border: 2px solid #16a34a !important;
  background: linear-gradient(135deg, #dcfce7, #bbf7d0) !important;
  color: #15803d !important;
  animation: paidPulse 2s ease-in-out infinite;
}

.btn-paid-anim:hover {
  background: #16a34a !important;
  color: #fff !important;
  animation: none;
  transform: scale(1.05);
}

/* Dashboard date filters */
.dash-filter {
  padding: 5px 12px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.dash-filter:hover {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.dash-filter.active {
  background: var(--brand-primary);
  color: #fff;
  border-color: var(--brand-primary);
}

/* Client detail drawer */
.drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 900;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.drawer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.client-drawer {
  position: fixed;
  top: 0;
  right: -440px;
  width: 420px;
  max-width: 90vw;
  height: 100vh;
  background: #fff;
  border-left: 1px solid var(--border-color);
  box-shadow: -8px 0 30px rgba(15, 23, 42, 0.12);
  z-index: 901;
  display: flex;
  flex-direction: column;
  transition: right 0.35s var(--ease-out);
  overflow: hidden;
}

.client-drawer.open {
  right: 0;
}

.drawer-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-soft);
  flex-shrink: 0;
}

.drawer-header .avatar-lg {
  width: 42px;
  height: 42px;
}

.drawer-header-info {
  flex: 1;
  min-width: 0;
}

.drawer-header-info h3 {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-header-info p {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0 0;
}

.drawer-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 16px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.drawer-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.drawer-tabs {
  display: flex;
  border-bottom: 1px solid var(--border-color);
  padding: 0 16px;
  flex-shrink: 0;
}

.drawer-tab {
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.drawer-tab.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
}

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
}

.drawer-section {
  display: none;
}

.drawer-section.active {
  display: block;
}

.drawer-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 13px;
}

.drawer-row:last-child {
  border-bottom: none;
}

.drawer-row .lbl {
  color: var(--text-muted);
  font-weight: 500;
  min-width: 90px;
}

.drawer-row .val {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
}

.drawer-actions {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-soft);
  flex-shrink: 0;
}

.drawer-task-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--bg-soft);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  font-size: 12px;
}

.drawer-task-item.completed {
  background: #dcfce7;
  border-left: 3px solid #16a34a;
}

.drawer-empty {
  text-align: center;
  padding: 30px 10px;
  color: var(--text-muted);
  font-size: 13px;
}

/* Calendar view */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  background: var(--border-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.calendar-header-cell {
  padding: 8px 4px;
  background: var(--bg-soft);
  text-align: center;
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.calendar-cell {
  min-height: 70px;
  padding: 4px 6px;
  background: #fff;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.calendar-cell:hover {
  background: var(--bg-soft);
}

.calendar-cell.today {
  background: #eff6ff;
  border: 2px solid var(--brand-primary);
}

.calendar-cell.other-month {
  opacity: 0.35;
}

.calendar-day-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 3px;
}

.calendar-task-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-right: 2px;
}

.calendar-task-label {
  display: block;
  font-size: 9px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.calendar-nav-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  color: var(--text-secondary);
  transition: all var(--transition-fast);
}

.calendar-nav-btn:hover {
  background: var(--bg-soft);
  color: var(--text-primary);
}

.calendar-nav-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  min-width: 140px;
  text-align: center;
}

/* Floating version badge */
@keyframes versionFloat {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

.version-badge {
  position: fixed;
  bottom: 16px;
  left: 16px;
  right: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: linear-gradient(135deg, #fff, #f0f4ff);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  z-index: 1001;
  animation: versionFloat 3s ease-in-out infinite;
  cursor: default;
  user-select: none;
}

.version-badge:hover {
  box-shadow: var(--shadow-lg);
  border-color: var(--brand-primary);
}

.version-badge-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: var(--brand-primary);
  color: #fff;
  border-radius: 50%;
  animation: versionFloat 2s ease-in-out infinite;
}

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

  .dashboard-card-wide {
    grid-column: 1;
  }
}
