/* Settings page styles — 3-tab layout */
.settings-main {
  padding: 2rem 1rem 4rem;
}

.settings-container {
  max-width: 800px;
  margin: 0 auto;
}

.settings-header {
  margin-bottom: 1.5rem;
}

.settings-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

/* ============================================
   Tab Buttons
   ============================================ */
.settings-tabs {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
  margin-bottom: 1.5rem;
  -webkit-overflow-scrolling: touch;
}

.settings-tab {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: all 200ms ease;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #6B7280;
}

.settings-tab:hover {
  background: #f9fafb;
}

.settings-tab.active {
  background: #1E40AF;
  color: #fff;
  border-color: #1E40AF;
}

.settings-tab-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ============================================
   Tab Content
   ============================================ */
.settings-tab-content {
  display: none;
}

.settings-tab-content.active {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  animation: settingsFadeIn 200ms ease;
}

@keyframes settingsFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================
   Shared Card Style
   ============================================ */
.settings-card {
  background: #fff;
  border-radius: 16px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

.settings-card-title {
  font-size: 1rem;
  font-weight: 700;
  color: #111827;
  margin: 0 0 0.75rem 0;
}

/* ============================================
   TAB 1: Data Sources
   ============================================ */
.ds-info-card {
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: 16px;
  padding: 1rem;
}

.ds-info-inner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.ds-info-icon {
  width: 20px;
  height: 20px;
  color: #1E40AF;
  flex-shrink: 0;
  margin-top: 2px;
}

.ds-info-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #1E40AF;
  margin: 0 0 0.25rem 0;
}

.ds-info-text {
  font-size: 0.75rem;
  color: #6B7280;
  margin: 0;
  line-height: 1.5;
}

.ds-info-note {
  font-size: 0.625rem;
  color: #9CA3AF;
  margin: 0.25rem 0 0 0;
}

.ds-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}

.ds-sync-all-btn {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #1E40AF;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}

.ds-sync-all-btn:hover {
  text-decoration: underline;
}

.ds-sync-icon {
  width: 12px;
  height: 12px;
}

.ds-accounts-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.ds-account-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  background: #f9fafb;
  border-radius: 12px;
}

.ds-account-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: #111827;
}

.ds-account-meta {
  font-size: 0.625rem;
  color: #9CA3AF;
  margin-top: 0.125rem;
}

.ds-account-status {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.ds-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #059669;
}

.ds-status-text {
  font-size: 0.625rem;
  font-weight: 500;
  color: #059669;
}

.ds-link-new-btn {
  width: 100%;
  padding: 0.625rem;
  border: 2px dashed #d1d5db;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6B7280;
  background: none;
  cursor: pointer;
  transition: background 200ms ease;
}

.ds-link-new-btn:hover {
  background: #f9fafb;
}

/* ============================================
   TAB 2: Subscription (single-tier)
   ============================================ */
.subscription-status-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  gap: 1rem;
}

.subscription-plan-name {
  font-size: 1.125rem;
  font-weight: 700;
  color: #111827;
  margin-bottom: 0.25rem;
}

.subscription-plan-detail {
  font-size: 0.8rem;
  color: #6B7280;
}

.subscription-status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
  background: rgba(107, 114, 128, 0.1);
  color: #6b7280;
}

.subscription-status-badge.active {
  background: rgba(5, 150, 105, 0.1);
  color: #059669;
}

.subscription-actions {
  margin-top: 1rem;
}

.subscription-cta {
  text-align: center;
  padding: 2rem 1rem;
}

.subscription-cta p {
  font-size: 0.9rem;
  color: #6B7280;
  margin: 0 0 1.25rem 0;
}

.subscription-help {
  font-size: 0.8rem;
  color: #9CA3AF;
  margin-top: 1rem;
}

.subscription-help a {
  color: #1E40AF;
  text-decoration: none;
}

.subscription-help a:hover {
  text-decoration: underline;
}

.settings-secondary-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 200ms ease;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
}

.settings-secondary-btn:hover {
  background: #f9fafb;
}

.settings-secondary-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   TAB 3: Security
   ============================================ */

/* Security Center Items */
.sec-items {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sec-item {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #f9fafb;
  border-radius: 12px;
}

.sec-item-icon-box {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #dcfce7;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sec-item-icon-box svg {
  width: 16px;
  height: 16px;
  color: #059669;
}

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

.sec-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.sec-item-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
}

.sec-item-status {
  font-size: 0.625rem;
  font-weight: 700;
  color: #059669;
  white-space: nowrap;
}

.sec-item-desc {
  font-size: 0.75rem;
  color: #6B7280;
  margin-top: 0.125rem;
  line-height: 1.4;
}

/* Privacy & Data */
.sec-privacy-info {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 0.75rem;
  font-size: 0.75rem;
  font-weight: 500;
  color: #059669;
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.sec-privacy-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sec-privacy-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.75rem;
  background: #f9fafb;
  border-radius: 12px;
  font-size: 0.875rem;
  color: #374151;
  border: none;
  cursor: pointer;
  transition: background 200ms ease;
  text-decoration: none;
}

.sec-privacy-action:hover {
  background: #f3f4f6;
}

.sec-privacy-action svg {
  color: #9CA3AF;
  flex-shrink: 0;
}

.sec-danger-action {
  background: #fef2f2;
  color: #dc2626;
}

.sec-danger-action:hover {
  background: #fee2e2;
}

.sec-danger-action svg {
  color: #dc2626;
}

/* ============================================
   Existing section styles (Profile, Password, etc.)
   Adapted to work inside settings-card
   ============================================ */
.section-subtitle {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text);
  margin: 0 0 1rem 0;
}

.section-description {
  font-size: 0.85rem;
  color: var(--color-muted);
  margin: -0.25rem 0 1rem 0;
  line-height: 1.5;
}

/* Settings form */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.settings-form .auth-submit-button {
  align-self: flex-start;
  width: auto;
  padding: 0.75rem 1.5rem;
}

.form-row {
  display: flex;
  gap: 1rem;
}

.form-row .form-group {
  flex: 1;
}

/* Banner */
.settings-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  line-height: 1.4;
}

.settings-banner.warning {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.25);
  color: #b45309;
}

.banner-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.banner-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: inherit;
  opacity: 0.6;
  padding: 0 0.25rem;
  line-height: 1;
}

.banner-dismiss:hover {
  opacity: 1;
}

/* Connected accounts */
.connected-accounts-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.connected-account {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--color-outline);
  border-radius: 8px;
  background: #fff;
}

.connected-account-icon {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.connected-account-info {
  flex: 1;
}

.connected-account-name {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
}

.connected-account-status {
  font-size: 0.8rem;
  color: var(--color-muted);
}

.connected-account-status.connected {
  color: var(--color-primary-dark);
}

.connected-account-action {
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease;
  border: none;
}

.connected-account-action.link-btn {
  background: linear-gradient(120deg, var(--color-primary), #1dd8a4);
  color: #fff;
}

.connected-account-action.link-btn:hover {
  transform: translateY(-1px);
}

.connected-account-action.unlink-btn {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.connected-account-action.unlink-btn:hover {
  background: rgba(239, 68, 68, 0.15);
}

.connected-account-action:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* MFA section */
.mfa-status {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 1px solid var(--color-outline);
  border-radius: 8px;
  background: #fff;
  margin-bottom: 1rem;
}

.mfa-status-badge {
  padding: 0.25rem 0.75rem;
  border-radius: 100px;
  font-size: 0.8rem;
  font-weight: 600;
}

.mfa-status-badge.enabled {
  background: rgba(15, 186, 129, 0.1);
  color: var(--color-primary-dark);
}

.mfa-status-badge.disabled {
  background: rgba(107, 114, 128, 0.1);
  color: #6b7280;
}

.mfa-qr-container {
  text-align: center;
  padding: 1.5rem;
  background: #f9fafb;
  border-radius: 8px;
  margin: 1rem 0;
}

.mfa-qr-container img {
  max-width: 200px;
  height: auto;
  border-radius: 8px;
}

.mfa-secret {
  font-family: monospace;
  font-size: 0.85rem;
  color: var(--color-muted);
  word-break: break-all;
  margin-top: 0.75rem;
  padding: 0.5rem;
  background: #fff;
  border: 1px solid var(--color-outline);
  border-radius: 8px;
}

.mfa-verify-form {
  display: flex;
  gap: 0.75rem;
  align-items: flex-end;
  margin-top: 1rem;
}

.mfa-verify-form .form-input {
  max-width: 200px;
  font-family: monospace;
  font-size: 1.1rem;
  letter-spacing: 0.15em;
  text-align: center;
}

.mfa-verify-form .auth-submit-button {
  width: auto;
  padding: 0.75rem 1.5rem;
  margin-top: 0;
}

.mfa-actions {
  margin-top: 1rem;
}

.mfa-actions .auth-submit-button {
  width: auto;
  padding: 0.75rem 1.5rem;
}

.mfa-disable-btn {
  background: rgba(239, 68, 68, 0.1) !important;
  color: #dc2626 !important;
  border: 1px solid rgba(239, 68, 68, 0.2) !important;
  box-shadow: none !important;
}

.mfa-disable-btn:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.15) !important;
  transform: translateY(-1px) !important;
  box-shadow: none !important;
}

/* Login activity table */
.activity-table-wrapper {
  overflow-x: auto;
  margin-top: 0.5rem;
}

.activity-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.activity-table th {
  text-align: left;
  font-weight: 600;
  color: var(--color-text);
  padding: 0.625rem 0.75rem;
  border-bottom: 2px solid var(--color-outline);
  white-space: nowrap;
}

.activity-table td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--color-outline);
  color: var(--color-text);
  vertical-align: middle;
}

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

.activity-method {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(15, 186, 129, 0.1);
  color: var(--color-primary-dark);
}

.activity-status-fail {
  color: #dc2626;
  font-weight: 600;
}

.activity-empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}

/* Language select */
.settings-select {
  max-width: 240px;
  cursor: pointer;
}

/* Export button */
.settings-export-btn {
  width: auto !important;
  padding: 0.75rem 1.5rem !important;
}

/* Notification toggles */
.notification-toggles {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.875rem 0;
  border-bottom: 1px solid var(--color-outline);
  cursor: pointer;
}

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

.toggle-label {
  font-size: 0.9rem;
  color: var(--color-text);
  font-weight: 500;
}

.toggle-input {
  display: none;
}

.toggle-switch {
  position: relative;
  width: 44px;
  height: 24px;
  background: #d1d5db;
  border-radius: 12px;
  transition: background 200ms ease;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 200ms ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-input:checked + .toggle-switch {
  background: var(--color-primary);
}

.toggle-input:checked + .toggle-switch::after {
  transform: translateX(20px);
}

/* Disabled input styling */
.form-input:disabled {
  background: #f3f4f6;
  color: var(--color-muted);
  cursor: not-allowed;
}

/* ============================================
   Danger Zone
   ============================================ */
.danger-zone {
  border: 1px solid rgba(220, 38, 38, 0.3);
  background: rgba(254, 242, 242, 0.5);
  margin-top: 2rem;
}

.danger-zone .settings-card-title {
  color: #dc2626;
}

.danger-delete-list {
  font-size: 0.85rem;
  color: #6B7280;
  margin: 0.5rem 0 1rem 1.25rem;
  padding: 0;
  line-height: 1.8;
}

.danger-hint {
  font-size: 0.8rem;
  color: #9CA3AF;
  margin: 0 0 1rem 0;
}

.danger-button {
  padding: 0.625rem 1.25rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 200ms ease;
  border: none;
  background: #dc2626;
  color: #fff;
}

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

.danger-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   Modal Overlay (Delete + Data)
   ============================================ */
.modal-overlay,
.data-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-overlay.hidden,
.data-modal-overlay.hidden {
  display: none;
}

.modal-card,
.data-modal {
  background: #fff;
  border-radius: 16px;
  padding: 1.5rem;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.modal-header,
.data-modal-header {
  margin-bottom: 1rem;
}

.modal-header h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.delete-modal p {
  font-size: 0.875rem;
  color: #6B7280;
  margin: 0 0 1rem 0;
  line-height: 1.5;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.25rem;
}

.modal-cancel-btn {
  padding: 0.625rem 1.25rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  transition: background 200ms ease;
}

.modal-cancel-btn:hover {
  background: #f9fafb;
}

.modal-confirm-btn {
  padding: 0.625rem 1.25rem;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
}

/* Data Modal */
.data-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.data-modal-header h3 {
  font-size: 1.125rem;
  font-weight: 700;
  color: #111827;
  margin: 0;
}

.data-modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #9CA3AF;
  cursor: pointer;
  padding: 0 0.25rem;
  line-height: 1;
}

.data-modal-close:hover {
  color: #374151;
}

.data-category-list {
  margin: 0;
}

.data-category-list dt {
  font-weight: 600;
  font-size: 0.875rem;
  color: #111827;
  margin-top: 0.75rem;
}

.data-category-list dt:first-child {
  margin-top: 0;
}

.data-category-list dd {
  font-size: 0.8rem;
  color: #6B7280;
  margin: 0.125rem 0 0 0;
}

/* ============================================
   TAB 4: Privacy
   ============================================ */
.privacy-data-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.privacy-last-export {
  font-size: 0.8rem;
  color: #9CA3AF;
  margin: 0;
}

.privacy-retention {
  font-size: 0.75rem;
  color: #9CA3AF;
  margin: 0.25rem 0 0 0;
}

.privacy-links {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.5rem 0;
}

.privacy-links a {
  font-size: 0.8rem;
  color: #1E40AF;
  text-decoration: none;
}

.privacy-links a:hover {
  text-decoration: underline;
}

.privacy-links-sep {
  color: #d1d5db;
}

/* Connected Services */
.connected-services-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.connected-service {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  background: #f9fafb;
  border-radius: 12px;
}

.connected-service-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.connected-service-info {
  flex: 1;
  min-width: 0;
}

.connected-service-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #111827;
}

.connected-service-status {
  font-size: 0.75rem;
  color: #9CA3AF;
  margin-top: 0.125rem;
}

.connected-service-status.active {
  color: #059669;
}

.connected-service-action {
  padding: 0.375rem 0.875rem;
  border-radius: 8px;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid #e5e7eb;
  background: #fff;
  color: #374151;
  transition: background 200ms ease;
  white-space: nowrap;
}

.connected-service-action:hover {
  background: #f3f4f6;
}

/* Responsive */

@media (max-width: 640px) {
  .settings-container {
    max-width: 100%;
  }

  .settings-card {
    padding: 1rem;
  }

  .form-row {
    flex-direction: column;
    gap: 1.25rem;
  }

  .mfa-verify-form {
    flex-direction: column;
    align-items: stretch;
  }

  .mfa-verify-form .form-input {
    max-width: 100%;
  }

  .activity-table {
    font-size: 0.8rem;
  }

  .activity-table th,
  .activity-table td {
    padding: 0.5rem;
  }
}
