/**
 * Admin Dashboard Styles
 * Extends main.css with admin-specific components
 */

/* ============================================
   CSS VARIABLES (fallbacks for admin module)
   ============================================ */

:root {
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --primary-50: #f0fdfa;
  --primary-100: #ccfbf1;
  --primary-200: #99f6e4;
  --primary-500: #14b8a6;
  --primary-600: #0d9488;
  --primary-700: #0f766e;
}

/* ============================================
   ADMIN TABS (Horizontal Navigation)
   ============================================ */

.admin-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: #f1f5f9;
  border-radius: 12px;
  margin-bottom: 24px;
  overflow-x: auto;
}

.admin-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  color: #64748b;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.admin-tab svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.5;
  fill: none;
  flex-shrink: 0;
}

.admin-tab:hover {
  color: #0f766e;
  background: rgba(15, 118, 110, 0.08);
}

.admin-tab.active {
  background: white;
  color: #0f766e;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ============================================
   ADMIN SECTIONS
   ============================================ */

.admin-section {
  display: none;
}

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

/* ============================================
   TENANT BADGE
   ============================================ */

.tenant-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--primary-50, #f0fdfa);
  border: 1px solid var(--primary-200, #99f6e4);
  border-radius: 20px;
  font-size: 13px;
  color: var(--primary-700, #0f766e);
  margin-right: 16px;
}

/* ============================================
   STATS GRID (Admin version)
   ============================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.stat-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon svg {
  width: 24px;
  height: 24px;
  stroke: white;
  stroke-width: 1.5;
}

.stat-icon-users { background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.stat-icon-tenants { background: linear-gradient(135deg, #0d9488, #14b8a6); }
.stat-icon-clients { background: linear-gradient(135deg, #f59e0b, #fbbf24); }
.stat-icon-protocols { background: linear-gradient(135deg, #3b82f6, #60a5fa); }

.stat-info h3 {
  font-size: 28px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

.stat-info p {
  font-size: 13px;
  color: var(--gray-500);
  margin: 0;
}

/* ============================================
   DASHBOARD GRID
   ============================================ */

.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
}

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

.admin-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.admin-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0 0 16px 0;
}

/* Activity List */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  background: var(--gray-50);
  border-radius: 8px;
}

.activity-icon {
  width: 32px;
  height: 32px;
  background: var(--primary-100);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.activity-icon svg {
  width: 16px;
  height: 16px;
  stroke: var(--primary-600);
  stroke-width: 2;
}

.activity-content {
  flex: 1;
  min-width: 0;
}

.activity-text {
  font-size: 14px;
  color: var(--gray-800);
  margin: 0;
}

.activity-meta {
  font-size: 12px;
  color: var(--gray-500);
  margin: 4px 0 0 0;
}

/* Quick Actions (Admin) */
.quick-actions-admin {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.quick-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  color: var(--gray-700);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.quick-action-btn:hover {
  background: var(--primary-50);
  border-color: var(--primary-300);
  color: var(--primary-700);
}

.quick-action-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 2;
}

/* ============================================
   SECTION HEADER
   ============================================ */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 16px;
}

.section-header h3 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

.section-actions {
  display: flex;
  gap: 12px;
}

/* Search & Filter Bar */
.search-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 200px;
  max-width: 320px;
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  stroke: var(--gray-400);
  stroke-width: 2;
}

.search-box input {
  width: 100%;
  padding: 10px 12px 10px 40px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.search-filter-bar select {
  padding: 10px 32px 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  background: white url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e") right 8px center no-repeat;
  background-size: 16px;
  cursor: pointer;
}

.search-filter-bar select:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px var(--primary-100);
}

/* ============================================
   DATA TABLE
   ============================================ */

.data-table-container {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
}

.data-table th {
  background: var(--gray-50);
  padding: 12px 16px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--gray-200);
}

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  font-size: 14px;
  color: var(--gray-800);
}

.data-table tbody tr:hover {
  background: var(--gray-50);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

/* User Cell */
.user-cell {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
}

.user-name {
  font-weight: 500;
  color: var(--gray-900);
}

/* Action Buttons */
.action-buttons {
  display: flex;
  gap: 8px;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--gray-100);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.icon-btn svg {
  width: 16px;
  height: 16px;
  stroke: var(--gray-600);
  stroke-width: 2;
}

.icon-btn:hover {
  background: var(--primary-100);
}

.icon-btn:hover svg {
  stroke: var(--primary-600);
}

.icon-btn-danger:hover {
  background: #fee2e2;
}

.icon-btn-danger:hover svg {
  stroke: #dc2626;
}

/* Loading/Empty/Error States */
.loading-row,
.empty-row,
.error-row {
  text-align: center;
  padding: 40px 16px !important;
  color: var(--gray-500);
}

.error-row {
  color: #dc2626;
}

.empty-state,
.error-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--gray-500);
}

.error-state {
  color: #dc2626;
}

/* ============================================
   BADGES
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-gray { background: var(--gray-100); color: var(--gray-700); }
.badge-green { background: #d1fae5; color: #047857; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-teal { background: #ccfbf1; color: #0f766e; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-yellow { background: #fef3c7; color: #b45309; }

.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  text-transform: capitalize;
}

.status-enabled, .status-active { background: #d1fae5; color: #047857; }
.status-disabled, .status-suspended { background: #fee2e2; color: #dc2626; }
.status-cancelled { background: var(--gray-200); color: var(--gray-600); }

/* ============================================
   ROLES SECTION
   ============================================ */

.roles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.role-card {
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.role-card:hover {
  border-color: var(--primary-300);
}

.role-card.selected {
  border-color: var(--primary-500);
  background: var(--primary-50);
}

.role-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.role-header h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

.role-description {
  font-size: 13px;
  color: var(--gray-500);
  margin: 0 0 12px 0;
}

/* Permission Matrix */
.permission-matrix-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.permission-matrix-card h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0 0 4px 0;
}

.permission-matrix-card .subtitle {
  font-size: 13px;
  color: var(--gray-500);
  margin: 0 0 20px 0;
}

.permission-table {
  width: 100%;
  border-collapse: collapse;
}

.permission-table th,
.permission-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--gray-100);
}

.permission-table th {
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-600);
  text-transform: uppercase;
  background: var(--gray-50);
}

.permission-table th:not(:first-child),
.permission-table td:not(:first-child) {
  text-align: center;
  width: 80px;
}

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

/* ============================================
   TENANTS SECTION
   ============================================ */

.tenants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.tenant-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.tenant-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.tenant-logo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 600;
  color: white;
}

.tenant-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 10px;
}

.tenant-info {
  flex: 1;
}

.tenant-info h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

.tenant-slug {
  font-size: 12px;
  color: var(--gray-500);
}

.tenant-stats {
  display: flex;
  gap: 24px;
  padding: 16px 0;
  border-top: 1px solid var(--gray-100);
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 16px;
}

.tenant-stat {
  display: flex;
  flex-direction: column;
}

.tenant-stat .stat-value {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
}

.tenant-stat .stat-label {
  font-size: 12px;
  color: var(--gray-500);
  text-transform: capitalize;
}

.tenant-actions {
  display: flex;
  gap: 8px;
}

/* ============================================
   KB SHARING SECTION
   ============================================ */

.kb-sharing-info {
  margin-bottom: 24px;
}

.info-card {
  background: var(--primary-50);
  border: 1px solid var(--primary-200);
  border-radius: 12px;
  padding: 20px;
}

.info-card h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-800);
  margin: 0 0 12px 0;
}

.info-card ul {
  margin: 0;
  padding-left: 20px;
}

.info-card li {
  font-size: 13px;
  color: var(--primary-700);
  margin-bottom: 6px;
}

.kb-collections-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.kb-collection-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.collection-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.collection-header h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

.collection-description {
  font-size: 13px;
  color: var(--gray-500);
  margin: 0 0 12px 0;
}

.collection-stats {
  font-size: 13px;
  color: var(--gray-600);
}

/* ============================================
   MODALS
   ============================================ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal.active {
  display: flex;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-sm {
  max-width: 420px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--gray-100);
  border-radius: 8px;
  font-size: 20px;
  color: var(--gray-600);
  cursor: pointer;
}

.modal-close:hover {
  background: var(--gray-200);
}

.modal-content form {
  padding: 24px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding-top: 20px;
  border-top: 1px solid var(--gray-100);
  margin-top: 20px;
}

/* Form Elements */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--gray-700);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px var(--primary-100);
}

.form-group small {
  font-size: 12px;
  color: var(--gray-500);
  margin-top: 4px;
  display: block;
}

.form-group input[type="color"] {
  width: 60px;
  height: 40px;
  padding: 4px;
  cursor: pointer;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--gray-700);
  cursor: pointer;
}

.checkbox-label input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary-600);
}

.permission-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.permission-row {
  display: grid;
  grid-template-columns: 1fr repeat(4, auto);
  align-items: center;
  gap: 16px;
  padding: 10px;
  background: var(--gray-50);
  border-radius: 8px;
}

.permission-row .module-name {
  font-weight: 500;
  color: var(--gray-700);
}

.permission-row label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--gray-600);
  cursor: pointer;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
}

.btn-primary {
  background: var(--primary-600);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-700);
}

.btn-secondary {
  background: white;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

.btn-danger {
  background: #dc2626;
  color: white;
}

.btn-danger:hover {
  background: #b91c1c;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-sm svg {
  width: 14px;
  height: 14px;
}

/* Utility */
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: slideIn 0.3s ease;
}

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

.toast span {
  flex: 1;
  font-size: 14px;
}

.toast button {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  font-size: 18px;
  color: var(--gray-400);
  cursor: pointer;
}

.toast button:hover {
  color: var(--gray-600);
}

.toast-success {
  border-left: 4px solid #10b981;
}

.toast-error {
  border-left: 4px solid #dc2626;
}

.toast-info {
  border-left: 4px solid #3b82f6;
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .search-filter-bar {
    width: 100%;
  }

  .search-box {
    max-width: none;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .permission-row {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .permission-row label {
    justify-content: flex-start;
  }

  .data-table-container {
    overflow-x: auto;
  }

  .data-table {
    min-width: 700px;
  }
}

/* ============================================
   INTEGRATIONS SECTION
   ============================================ */

.section-subtitle {
  font-size: 14px;
  color: var(--gray-500);
  margin: 4px 0 0 0;
}

.integrations-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

.integration-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: box-shadow 0.2s;
}

.integration-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.integration-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border-bottom: 1px solid var(--gray-100);
}

.integration-logo {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--gray-100);
  border-radius: 10px;
  color: var(--gray-600);
}

.integration-logo svg {
  width: 24px;
  height: 24px;
}

.integration-info {
  flex: 1;
}

.integration-info h4 {
  font-size: 16px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0 0 2px 0;
}

.integration-desc {
  font-size: 12px;
  color: var(--gray-500);
  margin: 0;
}

.integration-status {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.integration-status.disconnected {
  background: var(--gray-100);
  color: var(--gray-600);
}

.integration-status.connected {
  background: #dcfce7;
  color: #166534;
}

.integration-status.connecting {
  background: #fef3c7;
  color: #92400e;
}

.integration-status.error {
  background: #fee2e2;
  color: #991b1b;
}

.integration-body {
  padding: 16px;
}

.integration-features {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.feature-tag {
  padding: 4px 10px;
  background: var(--primary-50);
  color: var(--primary-700);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
}

.integration-actions {
  display: flex;
  gap: 8px;
}

/* Integration Details Card */
.integration-details-card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  padding: 24px;
  margin-top: 24px;
}

.integration-details-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-100);
}

.integration-details-header h4 {
  font-size: 18px;
  font-weight: 600;
  color: var(--gray-900);
  margin: 0;
}

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

.integration-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.integration-stats .stat-item {
  text-align: center;
  padding: 16px;
  background: var(--gray-50);
  border-radius: 10px;
}

.integration-stats .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary-600);
  display: block;
}

.integration-stats .stat-label {
  font-size: 13px;
  color: var(--gray-600);
  margin-top: 4px;
}

/* Sync Progress Bar */
.sync-progress-container {
  background: var(--gray-50);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid var(--gray-200);
}

.sync-progress-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.sync-progress-status {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-700);
}

.sync-progress-percent {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary-600);
}

.sync-progress-bar {
  height: 8px;
  background: var(--gray-200);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}

.sync-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary-500), var(--primary-600));
  border-radius: 4px;
  transition: width 0.3s ease;
}

.sync-progress-details {
  font-size: 12px;
  color: var(--gray-500);
  display: flex;
  gap: 16px;
}

.sync-progress-details span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sync-progress-details .created { color: var(--success-600); }
.sync-progress-details .updated { color: var(--primary-600); }
.sync-progress-details .failed { color: var(--error-600); }

.sync-logs h5 {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-700);
  margin: 0 0 12px 0;
}

.sync-log-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.sync-log-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: 8px;
  font-size: 13px;
}

.sync-log-item .log-type {
  font-weight: 500;
  color: var(--gray-700);
}

.sync-log-item .log-stats {
  color: var(--gray-500);
}

.sync-log-item .log-time {
  margin-left: auto;
  color: var(--gray-400);
  font-size: 12px;
}

.sync-log-item.success {
  border-left: 3px solid #10b981;
}

.sync-log-item.error {
  border-left: 3px solid #dc2626;
}

.sync-log-item.partial {
  border-left: 3px solid #f59e0b;
}

/* Info Box (for modal instructions) */
.info-box {
  display: flex;
  gap: 12px;
  padding: 16px;
  background: var(--primary-50);
  border: 1px solid var(--primary-200);
  border-radius: 10px;
  margin-bottom: 20px;
}

.info-box svg {
  flex-shrink: 0;
  color: var(--primary-600);
}

.info-box strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--primary-800);
  margin-bottom: 8px;
}

.info-box ol {
  margin: 0;
  padding-left: 20px;
}

.info-box li {
  font-size: 13px;
  color: var(--primary-700);
  margin-bottom: 4px;
}

/* Responsive adjustments for integrations */
@media (max-width: 768px) {
  .integrations-grid {
    grid-template-columns: 1fr;
  }

  .integration-details-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .details-header-actions {
    flex-wrap: wrap;
  }

  .integration-stats {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ============================================
   ACCESS REVIEW WIDGET (HIPAA COMPLIANCE)
   ============================================ */

.access-review-card {
  border-left: 4px solid var(--primary-500);
}

.access-review-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.access-review-header h3 {
  display: flex;
  align-items: center;
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.hipaa-badge {
  background: linear-gradient(135deg, #0891b2 0%, #0e7490 100%);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.access-review-loading {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
}

.access-review-error {
  text-align: center;
  padding: 20px;
  color: var(--danger-600);
}

.access-review-error button {
  margin-top: 12px;
}

/* Status indicator */
.access-review-status {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-radius: 8px;
  margin-bottom: 16px;
}

.access-review-status .status-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
}

.access-review-status.status-ok {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
}

.access-review-status.status-due-soon {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #b45309;
}

.access-review-status.status-overdue {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
}

.access-review-status.status-attention {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #c2410c;
}

/* Review details */
.access-review-details {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
  padding: 12px;
  background: #f9fafb;
  border-radius: 6px;
}

.review-info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
}

.review-info-row .label {
  color: var(--text-muted);
}

.review-info-row .value {
  font-weight: 500;
  color: var(--text-primary);
}

/* Flagged items */
.access-review-flags {
  margin-bottom: 16px;
}

.access-review-flags h4 {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin: 0 0 12px 0;
}

.flag-counts {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.flag-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px;
  border-radius: 8px;
  min-width: 80px;
}

.flag-item.flag-users {
  background: #fef2f2;
  border: 1px solid #fecaca;
}

.flag-item.flag-integrations {
  background: #fffbeb;
  border: 1px solid #fde68a;
}

.flag-item.flag-sessions {
  background: #fff7ed;
  border: 1px solid #fed7aa;
}

.flag-count {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

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

/* Action buttons */
.access-review-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.access-review-actions .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.access-review-actions .btn svg {
  flex-shrink: 0;
}

/* Responsive */
@media (max-width: 640px) {
  .access-review-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .flag-counts {
    justify-content: center;
  }

  .access-review-actions {
    flex-direction: column;
  }

  .access-review-actions .btn {
    width: 100%;
    justify-content: center;
  }
}

/* ============================================
   LOGO PREVIEW CONTAINERS
   ============================================ */

/* Clinic Branding logo preview (80x80) */
#brandingLogoPreview img {
  max-width: 80px;
  max-height: 80px;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* Multi-tenant modal logo preview (64x64) */
#tenantLogoPreview img {
  max-width: 64px;
  max-height: 64px;
  width: auto;
  height: auto;
  object-fit: contain;
}

/* ============================================
   CONSENT FIELD BUILDER
   ============================================ */
.consent-field-builder {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px;
  background: var(--gray-50);
}

.consent-fields-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.consent-field-empty {
  text-align: center;
  color: var(--gray-400);
  font-size: 13px;
  padding: 20px 0;
}

.consent-field-block {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 12px;
}

.consent-field-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.consent-field-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--gray-500);
  letter-spacing: 0.05em;
}

.consent-field-actions {
  display: flex;
  gap: 4px;
}

.consent-field-actions button {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: var(--gray-100);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--gray-500);
}

.consent-field-actions button:hover {
  background: var(--gray-200);
  color: var(--gray-700);
}

.consent-field-block .field-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
}

.consent-field-add-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.consent-preview-frame {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 24px;
  background: white;
  max-height: 400px;
  overflow-y: auto;
}

.consent-preview-frame .preview-legal {
  font-size: 14px;
  color: var(--gray-700);
  line-height: 1.6;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--gray-50);
  border-radius: 6px;
}

.consent-preview-frame .preview-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: 6px;
  font-size: 14px;
}

.consent-preview-frame .preview-signature {
  border: 2px dashed var(--gray-300);
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  color: var(--gray-400);
  margin-top: 16px;
}

/* Service Requirements Panel */
.requirements-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.requirement-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--gray-50);
  border-radius: 6px;
}

.requirement-service {
  font-size: 14px;
  font-weight: 500;
  color: var(--gray-800);
}

.requirement-add-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  align-items: center;
}

.requirement-add-row select {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  font-size: 14px;
}

/* ============================================
   CONSENT PDF IMPORT
   ============================================ */
.consent-pdf-import-section {
  margin-bottom: 20px;
  padding: 14px 16px;
  background: var(--blue-50, #eff6ff);
  border: 1px dashed var(--blue-200, #bfdbfe);
  border-radius: 8px;
}

.consent-pdf-import-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.consent-pdf-import-hint {
  font-size: 13px;
  color: var(--gray-500, #6b7280);
}

.consent-pdf-import-status {
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
}

.consent-pdf-import-status.status-loading {
  background: var(--blue-50, #eff6ff);
  color: var(--blue-700, #1d4ed8);
}

.consent-pdf-import-status.status-success {
  background: var(--green-50, #f0fdf4);
  color: var(--green-700, #15803d);
}

.consent-pdf-import-status.status-error {
  background: var(--red-50, #fef2f2);
  color: var(--red-700, #b91c1c);
}

.spinner-inline {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid var(--gray-300, #d1d5db);
  border-top-color: var(--primary, #0f766e);
  border-radius: 50%;
  animation: consent-spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}

@keyframes consent-spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   VOICE INTAKES SECTION
   ============================================ */
.intake-row { cursor: pointer; }
.intake-row:hover { background: var(--gray-50); }
.intake-row.has-red-flags { border-left: 3px solid #dc2626; }

.intake-pagination {
  display: flex; justify-content: center; align-items: center;
  gap: 16px; padding: 16px 0;
}
.intake-page-info { font-size: 13px; color: var(--gray-500); }

/* Detail Panel */
.intake-detail-panel {
  background: white; border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  padding: 24px; margin-top: 24px;
}
.intake-detail-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  margin-bottom: 20px; padding-bottom: 16px;
  border-bottom: 1px solid var(--gray-100);
  flex-wrap: wrap; gap: 12px;
}
.intake-detail-title h3 { font-size: 18px; font-weight: 600; color: var(--gray-900); margin: 0 0 8px; }
.intake-detail-meta {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; font-size: 13px; color: var(--gray-500);
}
.intake-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Detail sub-tabs */
.intake-detail-tabs {
  display: flex; gap: 4px; padding: 4px;
  background: var(--gray-50); border-radius: 8px; margin-bottom: 20px;
}
.intake-detail-tab {
  padding: 8px 16px; border: none; background: transparent;
  border-radius: 6px; font-size: 13px; font-weight: 500;
  color: var(--gray-500); cursor: pointer; transition: all 0.2s;
}
.intake-detail-tab:hover { color: var(--primary-700); background: rgba(15,118,110,0.08); }
.intake-detail-tab.active {
  background: white; color: var(--primary-700);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.intake-tab-content { min-height: 200px; }

/* Summary */
.intake-summary-section { margin-bottom: 24px; }
.intake-summary-section h4 {
  font-size: 14px; font-weight: 600; color: var(--gray-700);
  margin: 0 0 12px; text-transform: uppercase; letter-spacing: 0.05em;
}
.intake-summary-text {
  font-size: 14px; line-height: 1.6; color: var(--gray-700);
  padding: 16px; background: var(--gray-50); border-radius: 8px;
}
.intake-stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px;
}
.intake-stat { text-align: center; padding: 16px; background: var(--gray-50); border-radius: 8px; }
.intake-stat-value { font-size: 20px; font-weight: 600; color: var(--gray-900); display: block; }
.intake-stat-label { font-size: 12px; color: var(--gray-500); margin-top: 4px; }

/* Topic coverage */
.topic-coverage-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.topic-item { display: flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 6px; font-size: 13px; }
.topic-item.covered { background: #d1fae5; color: #047857; }
.topic-item.not-covered { background: #fee2e2; color: #dc2626; }
.topic-name { text-transform: capitalize; }

/* Review info */
.intake-review-info { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--gray-600); }
.review-notes { width: 100%; padding: 12px; background: var(--gray-50); border-radius: 8px; margin-top: 8px; font-size: 14px; }

/* Chat transcript */
.intake-chat-transcript {
  display: flex; flex-direction: column; gap: 12px;
  max-height: 500px; overflow-y: auto; padding: 16px;
  background: var(--gray-50); border-radius: 8px;
}
.chat-bubble { max-width: 80%; padding: 12px 16px; border-radius: 12px; font-size: 14px; line-height: 1.5; }
.chat-bubble.chat-ai { align-self: flex-start; background: white; border: 1px solid var(--gray-200); border-bottom-left-radius: 4px; }
.chat-bubble.chat-user { align-self: flex-end; background: var(--primary-600, #0f766e); color: white; border-bottom-right-radius: 4px; }
.chat-bubble-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.chat-role { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; opacity: 0.7; }
.chat-time { font-size: 11px; opacity: 0.6; }
.chat-bubble-text { white-space: pre-wrap; word-break: break-word; }
.intake-plain-transcript pre {
  background: var(--gray-50); padding: 16px; border-radius: 8px;
  font-size: 13px; line-height: 1.6; max-height: 500px;
  overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}

/* Extracted data */
.extracted-data-sections { display: flex; flex-direction: column; gap: 16px; }
.extracted-section { background: var(--gray-50); border-radius: 8px; padding: 16px; }
.extracted-section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.extracted-section-header h5 { font-size: 14px; font-weight: 600; color: var(--gray-800); margin: 0; }
.extracted-section-body { font-size: 14px; color: var(--gray-700); line-height: 1.6; }
.extracted-section-body ul { margin: 0; padding-left: 20px; }
.extracted-section-body li { margin-bottom: 4px; }
.extracted-dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 16px; margin: 0; }
.extracted-dl dt { font-weight: 500; color: var(--gray-600); text-transform: capitalize; }
.extracted-dl dd { margin: 0; color: var(--gray-800); }

/* Red flags */
.red-flags-list { display: flex; flex-direction: column; gap: 10px; }
.red-flag-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px;
}
.red-flag-icon { flex-shrink: 0; color: #dc2626; margin-top: 2px; }
.red-flag-text { font-size: 14px; color: #991b1b; line-height: 1.5; }

@media (max-width: 768px) {
  .intake-detail-header { flex-direction: column; }
  .chat-bubble { max-width: 95%; }
  .intake-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
