/* ============================================
   CLIENTS & SHARED UI COMPONENTS CSS
   ============================================ */

/* --- SHARED LAYOUT COMPONENTS --- */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
}
.section-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--fc-primary, #1e3c3c);
}
.section-subtitle {
  color: #6b7280;
  font-size: 14px;
  margin-top: 4px;
}
.section-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  align-items: center;
}
.search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 400px;
}
.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: #9ca3af;
  font-size: 14px;
}
.search-input {
  width: 100%;
  padding: 10px 16px 10px 40px;
  border: 1px solid #e5e7eb;
  font-size: 14px;
  background: white;
  transition: border-color 0.2s;
}
.search-input:focus {
  outline: none;
  border-color: var(--fc-primary, #1e3c3c);
}
.filter-select {
  padding: 10px 16px;
  border: 1px solid #e5e7eb;
  font-size: 13px;
  background: white;
  min-width: 140px;
}

/* KPI Grid */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* Responsive table container */
.responsive-table {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Empty & Loading states */
.empty-state {
  padding: 60px 20px;
  text-align: center;
  color: #6b7280;
}
.empty-state i {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.3;
  display: block;
}
.empty-title { font-size: 16px; margin-bottom: 8px; }
.empty-subtitle { font-size: 13px; }
.loading-state {
  padding: 40px;
  text-align: center;
  color: #6b7280;
}
.loading-state i { font-size: 24px; }
.loading-state p { margin-top: 12px; }
.error-state {
  padding: 40px;
  text-align: center;
  color: #dc2626;
}

/* Clickable rows */
.clickable-row { cursor: pointer; }
.clickable-row:hover { background: #f9fafb; }
.cell-main { font-weight: 500; font-size: 14px; }
.cell-sub { font-size: 12px; color: #6b7280; margin-top: 2px; word-break: break-all; }
.cell-secondary { font-size: 13px; color: #6b7280; }
.cell-center { text-align: center; font-weight: 500; }
.cell-action { text-align: right; }
.icon-btn {
  background: none;
  border: none;
  color: var(--fc-primary, #1e3c3c);
  cursor: pointer;
  padding: 8px;
  transition: color 0.2s;
}
.icon-btn:hover { color: var(--fc-accent, #ff6101); }

.mandate-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 13px;
  background: #f3f4f6;
  color: #6b7280;
}
.mandate-count.has-mandates {
  background: #d1fae5;
  color: #065f46;
  font-weight: 600;
}

/* --- VIEW TOGGLE --- */
.client-view-toggle {
  display: flex;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
  flex-shrink: 0;
}
.view-toggle-btn {
  padding: 8px 14px;
  border: none;
  background: white;
  color: #9ca3af;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.view-toggle-btn:not(:last-child) {
  border-right: 1px solid #e5e7eb;
}
.view-toggle-btn:hover {
  color: var(--fc-primary, #1e3c3c);
  background: #f9fafb;
}
.view-toggle-btn.active {
  background: var(--fc-primary, #1e3c3c);
  color: white;
}

/* --- TABLE VIEW MINI AVATAR --- */
.client-avatar-sm {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--fc-primary, #1e3c3c);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

/* --- CARDS VIEW --- */
.client-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.client-card {
  padding: 0 !important;
  cursor: pointer;
  transition: all 0.2s ease;
  border: 1px solid #e5e7eb;
  overflow: hidden;
}
.client-card:hover {
  border-color: var(--fc-primary, #1e3c3c);
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  transform: translateY(-2px);
}
.client-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #f3f4f6;
}
.client-card-avatar {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--fc-primary, #1e3c3c);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
}
.client-card-title-area {
  flex: 1;
  min-width: 0;
}
.client-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--fc-primary, #1e3c3c);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.client-card-industry {
  font-size: 12px;
  color: #6b7280;
  margin-top: 2px;
}
.client-card-industry i {
  margin-right: 4px;
  font-size: 10px;
}
.client-card-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 48px;
}
.client-card-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #6b7280;
}
.client-card-meta i {
  width: 14px;
  text-align: center;
  font-size: 11px;
  color: #9ca3af;
}
.client-card-meta span {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.client-card-footer {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px 16px;
  background: #f9fafb;
  border-top: 1px solid #f3f4f6;
}
.client-card-stat {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #6b7280;
}
.client-card-stat i {
  font-size: 11px;
}
.client-card-stat.has-mandates {
  color: #065f46;
  font-weight: 600;
}
.client-card-action {
  margin-left: auto;
  background: none;
  border: 1px solid #e5e7eb;
  color: var(--fc-primary, #1e3c3c);
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  transition: all 0.2s;
}
.client-card-action:hover {
  background: var(--fc-primary, #1e3c3c);
  color: white;
  border-color: var(--fc-primary, #1e3c3c);
}

/* --- CLIENT DETAIL --- */
.back-btn {
  background: none;
  border: none;
  color: var(--fc-primary, #1e3c3c);
  cursor: pointer;
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
}
.back-btn:hover { opacity: 0.7; }

.client-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.client-header-info {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 0;
}
.client-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--fc-primary, #1e3c3c);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  flex-shrink: 0;
}
.client-name {
  font-size: 22px;
  font-weight: 600;
  color: var(--fc-primary, #1e3c3c);
  word-break: break-word;
}
.client-meta {
  display: flex;
  gap: 10px;
  margin-top: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.meta-tag {
  font-size: 13px;
  color: #6b7280;
}
.meta-link {
  font-size: 13px;
  color: var(--fc-accent, #ff6101);
  text-decoration: none;
}
.meta-link:hover { text-decoration: underline; }

.client-header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* Quick Stats */
.client-quick-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.quick-stat-item {
  background: white;
  border: 1px solid #e5e7eb;
  padding: 16px;
  text-align: center;
}
.quick-stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--fc-primary, #1e3c3c);
}
.quick-stat-label {
  font-size: 12px;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-top: 4px;
}

/* Detail Grid */
.client-detail-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}
.detail-section {
  padding: 24px;
  margin-bottom: 16px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.section-head h3 {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
}
.section-head h3 i { margin-right: 6px; color: var(--fc-accent, #ff6101); }
.section-head-simple {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
  margin-bottom: 16px;
}
.section-head-simple i { margin-right: 6px; color: var(--fc-accent, #ff6101); }

.mini-btn {
  background: none;
  border: 1px solid #e5e7eb;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--fc-primary, #1e3c3c);
  transition: all 0.2s;
}
.mini-btn:hover { border-color: var(--fc-accent, #ff6101); color: var(--fc-accent, #ff6101); }

/* Contact Cards */
.contacts-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.contact-card {
  border: 1px solid #e5e7eb;
  padding: 14px;
  transition: border-color 0.2s;
}
.contact-card.primary { border-left: 3px solid var(--fc-accent, #ff6101); }
.contact-card:hover { border-color: var(--fc-primary, #1e3c3c); }
.contact-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.contact-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  color: #6b7280;
  flex-shrink: 0;
}
.contact-info { flex: 1; min-width: 0; }
.contact-name { font-weight: 500; font-size: 14px; }
.contact-position { font-size: 12px; color: #6b7280; }
.primary-badge {
  font-size: 10px;
  background: var(--fc-accent, #ff6101);
  color: white;
  padding: 1px 6px;
  margin-left: 6px;
  text-transform: uppercase;
}
.contact-details { display: flex; flex-direction: column; gap: 4px; }
.contact-link {
  font-size: 13px;
  color: #6b7280;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 6px;
  word-break: break-all;
}
.contact-link:hover { color: var(--fc-primary, #1e3c3c); }
.contact-link i { width: 14px; color: var(--fc-accent, #ff6101); }

.delete-mini-btn {
  background: none;
  border: none;
  color: #d1d5db;
  cursor: pointer;
  padding: 4px;
  font-size: 12px;
  transition: color 0.2s;
}
.delete-mini-btn:hover { color: #dc2626; }

/* Mandate Rows */
.mandates-list { display: flex; flex-direction: column; }
.mandate-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  gap: 12px;
}
.mandate-row:hover { background: #f9fafb; margin: 0 -24px; padding-left: 24px; padding-right: 24px; }
.mandate-row:last-child { border-bottom: none; }
.mandate-info { flex: 1; min-width: 0; }
.mandate-title { font-weight: 500; font-size: 14px; margin-bottom: 6px; }
.mandate-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.meta-small { font-size: 12px; color: #6b7280; }
.mandate-stats { display: flex; align-items: center; gap: 16px; flex-shrink: 0; }
.mandate-stat { text-align: center; }
.mandate-stat .stat-num { font-weight: 600; font-size: 16px; color: var(--fc-primary, #1e3c3c); display: block; }
.mandate-stat .stat-label { font-size: 10px; color: #6b7280; text-transform: uppercase; }
.mandate-stat.match .stat-num { color: #16a34a; }
.mandate-arrow { color: #d1d5db; font-size: 12px; }

/* Info List */
.info-list { display: flex; flex-direction: column; gap: 12px; }
.info-row { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.info-label { color: #6b7280; }
.text-link { color: var(--fc-accent, #ff6101); text-decoration: none; font-size: 13px; word-break: break-all; }
.text-link:hover { text-decoration: underline; }

/* Stage Select */
.stage-select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  font-size: 13px;
  background: white;
}

/* Activity Items */
.activity-item {
  display: flex;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid #f9fafb;
}
.activity-icon { color: var(--fc-accent, #ff6101); margin-top: 3px; font-size: 12px; width: 16px; }
.activity-content { flex: 1; min-width: 0; }
.activity-title { font-size: 13px; font-weight: 500; }
.activity-time { font-size: 11px; color: #9ca3af; }

/* Danger Zone */
.danger-zone { border: 1px solid #fecaca; }
.btn-danger {
  width: 100%;
  padding: 10px;
  border: 1px solid #dc2626;
  background: white;
  color: #dc2626;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}
.btn-danger:hover { background: #fef2f2; }

.no-data {
  color: #9ca3af;
  font-size: 13px;
  padding: 12px 0;
}

/* --- MODAL SYSTEM --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-container {
  background: white;
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  border-radius: 12px;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
  animation: modal-slide-up 0.3s ease-out;
}
.modal-lg { max-width: 700px; }
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid #f3f4f6;
}
.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}
.modal-header h2 i { margin-right: 8px; color: var(--fc-accent, #ff6101); }
.modal-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #6b7280;
  padding: 4px;
}
.modal-body { padding: 24px; }
.modal-footer {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid #f3f4f6;
}

/* Form components */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full-width { grid-column: 1 / -1; }
.form-group label {
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6b7280;
}
.form-input {
  padding: 10px 12px;
  border: 1px solid #e5e7eb;
  font-size: 14px;
  transition: border-color 0.2s;
  width: 100%;
  box-sizing: border-box;
}
.form-input:focus {
  outline: none;
  border-color: var(--fc-primary, #1e3c3c);
}
.form-section-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--fc-primary, #1e3c3c);
  margin: 20px 0 12px;
  padding-top: 16px;
  border-top: 1px solid #f3f4f6;
}
.form-section-title i { margin-right: 6px; color: var(--fc-accent, #ff6101); }

/* Buttons */
.btn-outline {
  padding: 8px 16px;
  border: 1px solid #e5e7eb;
  background: white;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s;
  color: var(--fc-primary, #1e3c3c);
  white-space: nowrap;
}
.btn-outline:hover { border-color: var(--fc-primary, #1e3c3c); }

.btn-secondary {
  padding: 10px 20px;
  border: 1px solid #e5e7eb;
  background: white;
  font-size: 13px;
  cursor: pointer;
}

/* --- RESPONSIVE --- */
@media (max-width: 1024px) {
  .client-detail-grid { grid-template-columns: 1fr; }
  .client-quick-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .section-header { flex-direction: column; align-items: flex-start; }
  .section-actions { width: 100%; }
  .section-actions .btn-primary { flex: 1; justify-content: center; }
  
  .filter-bar { flex-direction: column; }
  .search-input-wrap { max-width: 100% !important; }
  .filter-select { width: 100%; }
  .client-view-toggle { align-self: flex-start; }
  
  .client-cards-grid { grid-template-columns: 1fr; }
  
  .client-detail-header { flex-direction: column; align-items: flex-start; }
  .client-header-actions { width: 100%; }
  .client-header-actions button { flex: 1; justify-content: center; font-size: 12px; padding: 8px 10px; }
  .client-header-actions .btn-label { display: none; }
  
  .client-quick-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .quick-stat-value { font-size: 22px; }
  .quick-stat-item { padding: 12px; }
  
  .contacts-grid { grid-template-columns: 1fr; }
  
  .form-grid { grid-template-columns: 1fr; }
  .form-group.full-width { grid-column: 1; }
  
  .modal-container { max-width: 100%; margin: 8px; }
  .modal-header h2 { font-size: 16px; }
  .modal-body { padding: 16px; }
  .modal-footer { padding: 12px 16px; }
  
  /* Mandate list responsive */
  .mandate-row { flex-direction: column; align-items: flex-start; }
  .mandate-stats { width: 100%; justify-content: flex-start; padding-top: 8px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .kpi-card { padding: 12px !important; }
  .kpi-value { font-size: 22px !important; }
  .kpi-label { font-size: 11px !important; }
  
  .section-title { font-size: 20px; }
  
  .client-name { font-size: 18px; }
  .client-avatar { width: 44px; height: 44px; font-size: 18px; }
}

/* ============================================
   GLOBAL MOBILE FIXES
   ============================================ */

/* Prevent horizontal scroll everywhere */
html, body {
  overflow-x: hidden;
}

/* Global text overflow protection */
.content-area * {
  max-width: 100%;
}
.content-area table {
  max-width: none;
}

/* Global button fixes for mobile */
@media (max-width: 768px) {
  /* Mandate detail responsive */
  .fade-in > div[style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
  }
  
  /* Mandate header responsive */
  .fade-in > div[style*="justify-content: space-between"][style*="align-items: flex-start"] {
    flex-direction: column !important;
    gap: 12px !important;
  }
  .fade-in > div[style*="justify-content: space-between"] > div[style*="display: flex; gap: 8px"] {
    width: 100% !important;
  }
  .fade-in > div[style*="justify-content: space-between"] > div[style*="display: flex; gap: 8px"] .btn-primary {
    flex: 1 !important;
    font-size: 12px !important;
    padding: 8px 10px !important;
    justify-content: center !important;
    text-align: center !important;
  }
  
  /* Data table mobile optimization */
  .data-table { font-size: 13px; }
  .data-table th { font-size: 11px; white-space: nowrap; }
  
  /* Mandate filter selects */
  .fade-in > div[style*="display: flex; gap: 12px; margin-bottom: 24px"] {
    flex-direction: column !important;
  }
  .fade-in > div[style*="display: flex; gap: 12px; margin-bottom: 24px"] select {
    width: 100% !important;
  }
  
  /* Mandate detail cards */
  .fade-in .card[style*="padding: 24px"] {
    padding: 16px !important;
  }
  
  /* Skills section overflow */
  .fade-in div[style*="display: flex; flex-wrap: wrap; gap: 6px"] {
    max-width: 100%;
  }
  .fade-in div[style*="display: flex; flex-wrap: wrap; gap: 6px"] span {
    word-break: break-word;
    max-width: 100%;
  }
  
  /* All inline-style grids to single column */
  .fade-in div[style*="display: grid; grid-template-columns: 1fr 1fr; gap: 12px"] {
    grid-template-columns: 1fr !important;
  }
}

@media (max-width: 480px) {
  /* Ultra compact buttons */
  .btn-primary {
    font-size: 13px !important;
    padding: 10px 14px !important;
  }
  
  /* Candidate list header */
  .candidates-header {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .candidates-header h1 {
    font-size: 20px !important;
  }
  .candidates-header .flex.gap-3 {
    flex-direction: column !important;
  }
  .candidates-header .btn-primary {
    width: 100% !important;
    justify-content: center !important;
  }
  
  /* Search bar compact */
  .card.p-4 {
    padding: 12px !important;
  }
  
  /* Quick filter row wrap */
  .flex.flex-wrap.gap-3.items-center {
    gap: 6px !important;
  }
  .flex.flex-wrap.gap-3.items-center select {
    font-size: 12px !important;
    padding: 6px 8px !important;
    min-width: 0 !important;
  }
}
