/* ═══════════════════════════════════════════════════
   Companies Page — Pane + Card Grid Layout
   ═══════════════════════════════════════════════════ */

/* Page container */
.companies-page {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  width: 100%;
}

/* ── Pane container ── */
.companies-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  background: var(--bg-surface);
  border-radius: 12px;
  box-shadow: var(--header-shadow);
  overflow: hidden;
}

/* ── Pane header ── */
.pane-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.pane-header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.page-title {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  color: var(--text-primary);
}

.result-count {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.search-bar {
  position: relative;
  width: 280px;
}

.search-bar input {
  width: 100%;
  padding: 9px 34px 9px 38px;
  border: 1px solid var(--input-border);
  border-radius: 8px;
  font-size: 14px;
  outline: none;
  background: var(--input-bg);
  color: var(--input-text);
  transition:
    border-color 0.2s,
    box-shadow 0.2s;
}

.search-bar input::placeholder {
  color: var(--input-placeholder);
}

.search-bar input:focus {
  border-color: var(--input-focus-border);
  box-shadow: 0 0 0 3px var(--input-focus-ring);
  background: var(--input-focus-bg);
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-faint);
  pointer-events: none;
}

.search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-faint);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition:
    color 0.15s,
    background 0.15s;
}

.search-clear:hover {
  color: var(--input-text);
  background: var(--nav-hover-bg);
}

/* ── Pane body ── */
.pane-body {
  position: relative;
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 20px 24px;
}

/* Search loading overlay */
.search-loading-overlay {
  position: absolute;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(2px);
}

.search-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 4px solid var(--spinner-track);
  border-top-color: var(--spinner-accent);
  animation: search-spin 0.7s linear infinite;
}

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

/* ── Empty state ── */
.empty-state {
  display: flex;
  justify-content: center;
  align-items: center;
  flex: 1;
  padding: 48px 16px;
  min-height: 200px;
}

/* ═══════════════════════════════════════════════════
   Card Grid
   ═══════════════════════════════════════════════════ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ── Individual Card ── */
.company-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
  background: var(--card-bg);
  border-radius: 12px;
  border: 1px solid var(--card-border);
  box-shadow: none;
  cursor: pointer;
  transition:
    transform 0.18s,
    box-shadow 0.18s,
    border-color 0.18s,
    background 0.18s;
  text-align: left;
  font: inherit;
  color: var(--input-text);
  overflow: hidden;
  width: 100%;
}

.company-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--card-hover-shadow);
  border-color: var(--card-hover-border);
  background: var(--card-hover-bg);
}

.company-card:active {
  transform: translateY(-1px);
  box-shadow: var(--card-active-shadow);
}

.company-card:focus-visible {
  outline: 2px solid var(--card-focus-ring);
  outline-offset: 2px;
}

/* Card top: avatar + status dot */
.card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.card-avatar {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: linear-gradient(
    135deg,
    var(--avatar-gradient-from),
    var(--avatar-gradient-to)
  );
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-initials {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  line-height: 1;
}

/* Status dot */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.status-dot.active {
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.status-dot.inactive {
  background: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

.status-dot.pending {
  background: #f59e0b;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.status-dot.neutral {
  background: var(--status-neutral-dot);
  box-shadow: 0 0 0 3px var(--status-neutral-dot-ring);
}

/* Card body */
.card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.card-name {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}

.card-email {
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card meta */
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text-secondary);
}

.meta-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  color: var(--text-faint);
}

.meta-item .mono {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
  font-size: 11px;
  letter-spacing: -0.02em;
}

/* Card footer */
.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 10px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.status-label {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 20px;
  text-transform: capitalize;
  letter-spacing: 0.02em;
}

.status-label.active {
  background: var(--status-active-bg);
  color: var(--status-active-color);
}

.status-label.inactive {
  background: var(--status-inactive-bg);
  color: var(--status-inactive-color);
}

.status-label.pending {
  background: var(--status-pending-bg);
  color: var(--status-pending-color);
}

.status-label.neutral {
  background: var(--status-neutral-bg);
  color: var(--status-neutral-color);
}

.card-date {
  font-size: 12px;
  color: var(--text-faint);
  margin-left: auto;
}

/* Hover arrow */
.card-arrow {
  position: absolute;
  top: 20px;
  right: 16px;
  width: 18px;
  height: 18px;
  color: var(--card-arrow-color);
  opacity: 0;
  transform: translateX(-4px);
  transition:
    opacity 0.18s,
    transform 0.18s;
}

.company-card:hover .card-arrow {
  opacity: 1;
  transform: translateX(0);
}

/* ═══════════════════════════════════════════════════
   Pagination Footer
   ═══════════════════════════════════════════════════ */

.pane-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 24px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-alt);
  flex-shrink: 0;
}

.page-info {
  font-size: 13px;
  color: var(--text-secondary);
}

.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
}

.page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  border: 1px solid var(--page-btn-border);
  border-radius: 6px;
  background: var(--page-btn-bg);
  color: var(--page-btn-color);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.page-btn:hover:not(:disabled):not(.active) {
  background: var(--page-btn-hover-bg);
  border-color: var(--page-btn-hover-border);
}

.page-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.page-btn.active {
  background: var(--page-btn-active-bg);
  border-color: var(--page-btn-active-border);
  color: var(--page-btn-active-color);
  font-weight: 600;
}

.page-ellipsis {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  color: var(--text-faint);
  font-size: 13px;
  user-select: none;
}

/* ═══════════════════════════════════════════════════
   Responsive
   ═══════════════════════════════════════════════════ */

/* Tablets — 2 columns */
@media (max-width: 1024px) {
  .card-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }
}

/* Mobile — single column */
@media (max-width: 768px) {
  .companies-pane {
    border-radius: 10px;
  }

  .pane-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 16px 16px 12px;
  }

  .pane-header-left {
    justify-content: space-between;
    width: 100%;
  }

  .page-title {
    font-size: 18px;
  }

  .search-bar {
    width: 100%;
  }

  .search-bar input {
    font-size: 16px; /* prevents iOS zoom */
    padding: 11px 34px 11px 40px;
  }

  .pane-body {
    padding: 12px;
  }

  .card-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .company-card {
    padding: 14px;
    border-radius: 10px;
    gap: 12px;
  }

  .card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 10px;
  }

  .avatar-initials {
    font-size: 15px;
  }

  .card-name {
    font-size: 15px;
  }

  .card-arrow {
    display: none;
  }

  .pane-footer {
    flex-direction: column;
    gap: 8px;
    padding: 12px 16px;
  }

  .page-btn {
    min-width: 36px;
    height: 36px;
  }
}

/* Small phones */
@media (max-width: 480px) {
  .companies-pane {
    border-radius: 8px;
  }

  .pane-header {
    padding: 12px 12px 10px;
  }

  .page-title {
    font-size: 16px;
  }

  .pane-body {
    padding: 8px;
  }

  .company-card {
    padding: 12px;
    gap: 10px;
  }

  .card-avatar {
    width: 36px;
    height: 36px;
  }

  .avatar-initials {
    font-size: 14px;
  }

  .card-name {
    font-size: 14px;
  }

  .card-email {
    font-size: 12px;
  }

  .status-label {
    font-size: 10px;
    padding: 2px 8px;
  }

  .card-date {
    font-size: 11px;
  }

  .pane-footer {
    padding: 10px 12px;
  }

  .page-btn {
    min-width: 32px;
    height: 32px;
    font-size: 13px;
  }
}
