/*
 * Settings Pages - Warm Minimalism
 * Follows the established design system from custom.css
 */

/* Settings container override */
.settings-container {
  max-width: 1100px;
}

/* Loading state */
.settings-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 60vh;
  color: var(--text-muted);
  font-size: 1rem;
}

/* Two-column layout */
.settings-layout {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 2rem 0 4rem;
  min-height: 60vh;
}

@media (min-width: 768px) {
  .settings-layout {
    flex-direction: row;
    gap: 32px;
  }
}

/* Sidebar */
.settings-sidebar {
  flex-shrink: 0;
}

@media (min-width: 768px) {
  .settings-sidebar {
    width: 200px;
  }
}

/* Sidebar navigation */
.settings-nav-title {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin: 0 0 1rem 0;
  padding: 0 0.75rem;
  display: none;
}

@media (min-width: 768px) {
  .settings-nav-title {
    display: block;
  }
}

.settings-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

@media (min-width: 768px) {
  .settings-nav-list {
    flex-direction: column;
    overflow-x: visible;
  }
}

.settings-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  min-height: 44px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 500;
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  transition: all 0.2s ease;
}

@media (min-width: 768px) {
  .settings-nav-link {
    padding: 0.75rem;
    white-space: normal;
    border-bottom: none;
    border-left: 3px solid transparent;
    border-radius: 0 0.375rem 0.375rem 0;
  }
}

.settings-nav-link:hover {
  color: var(--text-primary);
  background: var(--surface-subtle);
}

.settings-nav-link.active {
  color: var(--text-primary);
  background: var(--accent-light);
  border-bottom-color: var(--accent);
}

@media (min-width: 768px) {
  .settings-nav-link.active {
    border-bottom-color: transparent;
    border-left-color: var(--accent);
  }
}

.settings-nav-link svg {
  flex-shrink: 0;
  opacity: 0.7;
  display: none;
}

@media (min-width: 768px) {
  .settings-nav-link svg {
    display: block;
  }
}

.settings-nav-link.active svg {
  opacity: 1;
}

/* Admin nav link */
.settings-nav-link.admin-link {
  color: var(--accent);
}

.settings-nav-link.admin-link:hover {
  color: var(--accent-hover);
  background: var(--accent-light);
}

.settings-nav-link.admin-link.active {
  color: var(--accent-hover);
  background: var(--accent-light);
}

.settings-nav-link.admin-link svg {
  opacity: 0.85;
}

/* Main content area */
.settings-main {
  flex-grow: 1;
  min-width: 0; /* Prevent flex overflow */
  max-width: 800px;
}

/* Settings page header */
.settings-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-subtle);
}

.settings-header h1 {
  font-size: 1.75rem;
  font-weight: 400;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
}

.settings-header p {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 0;
  font-weight: 300;
}

/* Settings section */
.settings-section {
  margin-bottom: 2.5rem;
}

.settings-section-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 1rem 0;
}

/* Form styles */
.settings-form {
  max-width: 400px;
}

.settings-field {
  margin-bottom: 1.25rem;
}

.settings-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.settings-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: 0.375rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.settings-input:focus {
  outline: none;
  border-color: var(--accent-hover);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.settings-input::placeholder {
  color: var(--border-input);
}

/* Field error state */
.settings-field.has-error .settings-input {
  border-color: var(--status-error-text);
}

.settings-field-error {
  font-size: 0.8125rem;
  color: var(--status-error-text);
  margin-top: 0.375rem;
  min-height: 1.25rem;
}

/* Field help text */
.settings-field-help {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.375rem;
}

/* Submit button */
.settings-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 0.9375rem;
  font-weight: 500;
  font-family: inherit;
  color: white;
  background: var(--accent);
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.settings-button:hover {
  opacity: 0.85;
}

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

.settings-button.is-loading {
  opacity: 0.7;
  pointer-events: none;
}

/* Secondary button */
.settings-button-secondary {
  color: var(--text-primary);
  background: transparent;
  border: 1px solid var(--border-default);
}

.settings-button-secondary:hover {
  background: var(--surface-subtle);
  opacity: 1;
}

/* Danger button (for delete) */
.settings-button-danger {
  color: var(--status-error-text);
  background: transparent;
  border: 1px solid rgba(220, 38, 38, 0.3);
}

.settings-button-danger:hover {
  background: rgba(220, 38, 38, 0.05);
  opacity: 1;
}

/* Alert messages */
.settings-alert {
  padding: 0.875rem 1rem;
  border-radius: 0.375rem;
  font-size: 0.9375rem;
  margin-bottom: 1.5rem;
  display: none;
}

.settings-alert.is-visible {
  display: block;
}

.settings-alert-success {
  background: rgba(22, 163, 74, 0.1);
  color: var(--status-success-text);
  border: 1px solid rgba(22, 163, 74, 0.2);
}

.settings-alert-error {
  background: rgba(220, 38, 38, 0.1);
  color: var(--status-error-text);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

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

/* Empty state */
.items-empty {
  text-align: center;
  padding: 3rem 1.5rem;
  background: var(--surface-subtle);
  border-radius: 0.5rem;
}

.items-empty-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 1rem;
  color: var(--border-input);
}

.items-empty h3 {
  font-size: 1.125rem;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 0.5rem 0;
}

.items-empty p {
  font-size: 0.9375rem;
  color: var(--text-secondary);
  margin: 0;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

/* Onboarding variant */
.items-empty-onboarding h3 {
  font-size: 1.25rem;
}

.items-empty-onboarding p {
  margin-bottom: 1.5rem;
}

/* Item card */
.item-card {
  display: flex;
  align-items: flex-start;
  gap: 0.875rem;
  padding: 1rem;
  background: var(--card-bg);
  border: 1px solid var(--border-subtle);
  border-radius: 0.5rem;
  transition: border-color 0.2s ease;
}

.item-card:hover {
  border-color: var(--border-default);
}

.item-favicon {
  width: 32px;
  height: 32px;
  border-radius: 0.25rem;
  background: var(--surface-subtle);
  flex-shrink: 0;
}

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

.item-title {
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--text-primary);
  margin: 0 0 0.25rem 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.item-url {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-decoration: none;
}

.item-url:hover {
  color: var(--text-primary);
  text-decoration: underline;
}

.item-meta {
  font-size: 0.75rem;
  color: var(--border-input);
  margin-top: 0.375rem;
}

.item-actions {
  flex-shrink: 0;
}

.item-delete-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--border-input);
  border-radius: 0.25rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.item-delete-btn:hover {
  background: rgba(220, 38, 38, 0.1);
  color: var(--status-error-text);
}

/* Outlined section (dashed border) */
.settings-section-outlined {
  padding: 1.25rem;
  border-radius: 0.5rem;
  border: 1px dashed var(--border-input);
}

.settings-section-outlined .settings-section-title {
  margin: 0;
}

.admin-action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.admin-action-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin: 0.25rem 0 0 0;
}

.admin-action-controls {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.75rem;
}

.admin-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--text-primary);
  user-select: none;
}

.admin-checkbox-label input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
  cursor: pointer;
  accent-color: var(--accent, #3a3632);
}

.regenerate-icon {
  font-size: 0.875rem;
}

/* Add item form */
.add-item-form {
  padding: 1.25rem;
  background: var(--surface-subtle);
  border: 1px dashed var(--border-input);
  border-radius: 0.5rem;
  margin-bottom: 1.5rem;
}

.add-item-fields {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 640px) {
  .add-item-fields {
    flex-direction: row;
    align-items: flex-end;
  }

  .add-item-field-url {
    flex-grow: 1;
  }

  .add-item-field-title {
    flex-grow: 1;
  }
}

.add-item-field {
  margin-bottom: 0;
}

.add-item-field .settings-input {
  background: var(--card-bg);
}

/* Items limit indicator */
.items-limit {
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: right;
  margin-top: 0.75rem;
}

.items-limit-warning {
  color: var(--status-warning);
}

.items-limit-reached {
  color: var(--status-error-text);
}

/* Password requirements list */
.password-requirements {
  margin-top: 0.75rem;
  padding: 0;
  list-style: none;
}

.password-requirements li {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-bottom: 0.375rem;
}

.password-requirements li::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-default);
  flex-shrink: 0;
}

.password-requirements li.is-valid {
  color: var(--status-success-text);
}

.password-requirements li.is-valid::before {
  background: var(--status-success-text);
}

/* ============================================================
   Filter pills
   ============================================================ */

.filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.filter-pill {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-secondary);
  background: transparent;
  border: 1px solid var(--border-default);
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.filter-pill:hover {
  color: var(--text-primary);
  border-color: var(--accent);
}

.filter-pill.active {
  color: white;
  background: var(--accent);
  border-color: var(--accent);
}

/* ============================================================
   Source badges for item cards
   ============================================================ */

.item-content .source-badge {
  margin-top: 0.375rem;
}

.source-badge-rss {
  background: rgba(249, 115, 22, 0.1);
  color: var(--badge-rss-text);
}

.source-badge-youtube {
  background: rgba(239, 68, 68, 0.1);
  color: var(--badge-youtube-text);
}

.source-badge-github {
  background: rgba(34, 197, 94, 0.1);
  color: var(--badge-github-text);
}

.source-badge-x {
  background: rgba(0, 0, 0, 0.08);
  color: var(--badge-x-text);
}

.source-badge-website {
  background: rgba(59, 130, 246, 0.1);
  color: var(--badge-website-text);
}

/* ============================================================
   Status dots
   ============================================================ */

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--border-default);
  margin-left: 0.5rem;
  vertical-align: middle;
}

.status-dot-active {
  background: var(--status-success);
}

.status-dot-stale {
  background: var(--border-default);
}

/* ============================================================
   Preference segmented controls
   ============================================================ */

.preference-group {
  margin-bottom: 1.5rem;
}

.preference-group-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.preference-segments {
  display: inline-flex;
  border: 1px solid var(--border-default);
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--surface-subtle);
}

.preference-segment {
  position: relative;
}

.preference-segment input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

.preference-segment-label {
  display: block;
  padding: 0.5rem 1rem;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s ease;
  border-right: 1px solid var(--border-default);
  white-space: nowrap;
}

.preference-segment:last-child .preference-segment-label {
  border-right: none;
}

.preference-segment-label:hover {
  color: var(--text-primary);
  background: var(--card-bg);
}

.preference-segment input[type="radio"]:checked + .preference-segment-label {
  color: white;
  background: var(--accent);
}

.preference-segment input[type="radio"]:focus-visible + .preference-segment-label {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ============================================================
   Account info
   ============================================================ */

.account-info-email {
  font-size: 0.9375rem;
  color: var(--text-secondary);
}

.account-info-email strong {
  color: var(--text-primary);
}

/* ============================================================
   Data & Privacy
   ============================================================ */

.data-privacy-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-width: 400px;
}

/* ============================================================
   Regenerate Feed — redesigned controls (BRE-220)
   ============================================================ */

.regen-feed-controls {
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  margin-top: 1rem;
}

/* Row 1: segmented control + email input + button */
.regen-feed-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Segmented control pill group */
.regen-segmented-control {
  display: inline-flex;
  background: var(--surface-subtle);
  border-radius: 0.5rem;
  padding: 0.25rem;
  flex-shrink: 0;
}

.regen-segment-btn {
  padding: 0.375rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  font-family: inherit;
  color: var(--text-muted);
  background: transparent;
  border: none;
  border-radius: 0.375rem;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.regen-segment-btn:hover {
  color: var(--text-primary);
}

.regen-segment-btn[aria-pressed="true"] {
  background: var(--card-bg);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Email input (inline variant — narrower than standard settings-input) */
.regen-email-input {
  width: auto;
  min-width: 180px;
  padding: 0.375rem 0.75rem;
  font-size: 0.8125rem;
}

/* Regenerate button — pushed to far right */
#regenerate-feed-btn {
  margin-left: auto;
  padding: 0.5rem 1.25rem;
  font-size: 0.875rem;
  white-space: nowrap;
}

/* Row 2: time range slider */
.regen-time-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.regen-time-label-prefix {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
}

#regen-time-slider {
  flex: 1;
  height: 0.375rem;
  accent-color: var(--accent);
  cursor: pointer;
}

.regen-time-display {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  min-width: 4.5rem;
  text-align: right;
  flex-shrink: 0;
}
