/**
 * RADEXEL Design System — Service Integrations Page
 *
 * Centralized service connection management.
 * Grid layout with responsive cards, brand colors, dark mode.
 */

/* ==========================================================================
   Page Container
   ========================================================================== */

.integrations-page {
  max-width: 800px;
  margin: 0 auto;
  padding: var(--space-6) var(--space-4);
  min-height: 100%;
}

/* ==========================================================================
   Header
   ========================================================================== */

.integrations-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.integrations-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-secondary);
  flex-shrink: 0;
  transition: all var(--duration-fast) var(--ease-default);
}

.integrations-back:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text);
  border-color: var(--color-border-hover, var(--color-border));
}

.integrations-back svg {
  width: 18px;
  height: 18px;
}

.integrations-header-text {
  flex: 1;
  min-width: 0;
}

.integrations-title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text);
  margin: 0;
  line-height: 1.3;
}

.integrations-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin: var(--space-1) 0 0;
}

.integrations-refresh {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  color: var(--color-text-secondary);
  flex-shrink: 0;
  transition: all var(--duration-fast) var(--ease-default);
}

.integrations-refresh:hover {
  background: var(--color-bg-secondary);
  color: var(--color-text);
}

.integrations-refresh svg {
  width: 16px;
  height: 16px;
}

/* ==========================================================================
   Grid
   ========================================================================== */

.integrations-grid {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ==========================================================================
   Service Card
   ========================================================================== */

.intg-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow var(--duration-fast) var(--ease-default),
              border-color var(--duration-fast) var(--ease-default);
}

.intg-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

.intg-card--connected {
  border-color: var(--rdx-green, #20B685);
  border-left: 3px solid var(--rdx-green, #20B685);
}

/* Skeleton variant */
.intg-card--skeleton {
  pointer-events: none;
}

/* Card Header */
.intg-card__header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
}

.intg-card__icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.intg-card__icon svg {
  width: 28px;
  height: 28px;
}

.intg-card__title-group {
  flex: 1;
  min-width: 0;
}

.intg-card__name {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text);
  margin: 0;
  line-height: 1.3;
}

.intg-card__desc {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin: 2px 0 0;
}

/* Status badge */
.intg-card__status {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-full);
  flex-shrink: 0;
  white-space: nowrap;
}

.intg-card__status svg {
  width: 14px;
  height: 14px;
}

.intg-card__status--on {
  background: rgba(32, 182, 133, 0.08);
  color: var(--rdx-green, #20B685);
}

.intg-card__status--off {
  background: var(--color-bg-tertiary, rgba(0, 0, 0, 0.04));
  color: var(--color-text-muted);
}

/* Card Body */
.intg-card__body {
  padding: 0 var(--space-4) var(--space-3);
}

.intg-card__account {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-bg-secondary, rgba(0, 0, 0, 0.02));
  border-radius: var(--radius-md);
  margin-bottom: var(--space-3);
}

.intg-card__account-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  white-space: nowrap;
}

.intg-card__account-value {
  font-size: var(--font-size-sm);
  color: var(--color-text);
  font-weight: var(--font-weight-medium);
  word-break: break-all;
}

.intg-card__connect-hint {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin: 0 0 var(--space-3);
  line-height: 1.5;
}

/* Scope tags */
.intg-card__scopes {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.intg-scope-tag {
  font-size: 11px;
  padding: 2px 8px;
  background: var(--rdx-blue-alpha, rgba(44, 92, 163, 0.08));
  color: var(--rdx-blue, #2C5CA3);
  border-radius: var(--radius-full);
  white-space: nowrap;
  font-weight: var(--font-weight-medium);
}

.intg-scope-tag--dim {
  background: var(--color-bg-tertiary, rgba(0, 0, 0, 0.04));
  color: var(--color-text-muted);
}

/* Card Footer */
.intg-card__footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--color-border-light, var(--color-border));
  display: flex;
  justify-content: flex-end;
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.intg-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  border-radius: var(--radius-md);
  cursor: pointer;
  border: none;
  transition: all var(--duration-fast) var(--ease-default);
  white-space: nowrap;
}

.intg-btn svg {
  width: 16px;
  height: 16px;
}

.intg-btn--connect {
  background: var(--rdx-blue, #2C5CA3);
  color: white;
}

.intg-btn--connect:hover:not(:disabled) {
  background: #244e8f;
  box-shadow: 0 2px 8px rgba(44, 92, 163, 0.25);
}

.intg-btn--connect:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.intg-btn--disconnect {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.intg-btn--disconnect:hover {
  background: rgba(234, 67, 53, 0.06);
  color: #EA4335;
  border-color: rgba(234, 67, 53, 0.3);
}

/* Spinner */
.intg-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: intg-spin 0.7s linear infinite;
}

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

/* ==========================================================================
   Error / Empty states
   ========================================================================== */

.integrations-error {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--color-text-secondary);
}

.integrations-error p {
  margin-bottom: var(--space-4);
}

.integrations-empty {
  text-align: center;
  padding: var(--space-10) var(--space-4);
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
}

/* ==========================================================================
   Dark Mode
   ========================================================================== */

[data-theme="dark"] .intg-card {
  background: var(--color-surface);
}

[data-theme="dark"] .intg-card:hover {
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}

[data-theme="dark"] .intg-card--connected {
  border-color: var(--rdx-green, #20B685);
}

[data-theme="dark"] .intg-card__icon {
  background: rgba(255, 255, 255, 0.06) !important;
}

[data-theme="dark"] .intg-scope-tag {
  background: rgba(44, 92, 163, 0.15);
}

[data-theme="dark"] .intg-scope-tag--dim {
  background: rgba(255, 255, 255, 0.06);
  color: var(--color-text-muted);
}

[data-theme="dark"] .intg-card__account {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .intg-btn--connect {
  background: var(--rdx-blue, #2C5CA3);
}

[data-theme="dark"] .intg-btn--disconnect:hover {
  background: rgba(234, 67, 53, 0.12);
}

[data-theme="dark"] .intg-spinner {
  border-color: rgba(255, 255, 255, 0.15);
  border-top-color: white;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 640px) {
  .integrations-page {
    padding: var(--space-4) var(--space-3);
  }

  .integrations-title {
    font-size: var(--font-size-lg);
  }

  .integrations-subtitle {
    display: none;
  }

  .intg-card__header {
    flex-wrap: wrap;
    gap: var(--space-2);
  }

  .intg-card__status {
    order: 3;
    width: 100%;
    justify-content: center;
    margin-top: var(--space-1);
  }

  .intg-card__icon {
    width: 40px;
    height: 40px;
  }

  .intg-card__icon svg {
    width: 22px;
    height: 22px;
  }

  .intg-card__footer {
    justify-content: stretch;
  }

  .intg-btn {
    width: 100%;
    justify-content: center;
    padding: var(--space-3) var(--space-4);
  }
}
