/* Settings SPA styles — Claude-like layout */
.dc-settings-wrap {
  padding: 16px 32px;
  box-sizing: border-box;
  position: relative;
}

/* Close button in Settings page (top-right) */
.dc-settings-close {
  position: absolute;
  right: 14px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--color-text);
  text-decoration: none;
  border: 1px solid var(--color-border);
  background: var(--color-card-bg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: background-color .15s ease, color .15s ease, transform .06s ease, border-color .15s ease;
  font-size: 18px;
  line-height: 1;
  z-index: 2;
}
.dc-settings-close:hover {
  background: var(--color-theme-4);
  transform: translateY(-1px);
  border-color: rgba(0,0,0,0.06);
}
.dc-settings-close:focus-visible {
  outline: 2px solid var(--color-theme-1);
  outline-offset: 2px;
}
[data-theme="dark"] .dc-settings-close {
  border-color: rgba(255,255,255,0.14);
}
@media (max-width: 767px) {
  .dc-settings-close {
    top: 6px;
    right: 10px;
    width: 34px;
    height: 34px;
  }
}

.dc-settings-header {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 0; /* sit flush to the top */
}
.dc-settings-header-inner {
  width: 100%;
  max-width: 1120px;
  padding: 0 8px;
}
.dc-settings-title {
  margin: 0;
  font-size: 28px;
  line-height: 1.15;
  color: var(--color-text);
  font-family: "Bebas Neue", serif;
  letter-spacing: 1px;
}

.dc-settings-surface {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: 0; /* sit content at the very top under the header */
  padding: 16px 8px;
  background: var(--color-theme-4); /* soft off-white panel like Claude */
  border-radius: 16px;
  position: relative; /* anchor ::before to container to prevent horizontal overflow on mobile */
}
.dc-settings-surface::before {
  /* subtle off-white panel background like Claude */
  content: '';
  position: absolute;
  left: 0; right: 0;
  height: 100%;
  pointer-events: none;
}
.dc-settings-grid {
  position: relative;
  width: 100%;
  max-width: 1120px;
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 24px;
  padding: 8px;
  box-sizing: border-box;
  align-items: start; /* keep nav and main aligned to the top */
}

.settings-nav {
  position: sticky;
  top: 0px; /* under site header */
  align-self: start;
}
.settings-nav-inner {
  padding: 8px;
  border-radius: 12px;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
}
.settings-nav-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  position: relative;
  top: 0;
}
.settings-link {
  position: relative;
  display: block;
  padding: 12px 14px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--color-text);
  border: 1px solid transparent;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .06s ease;
  font-size: 1rem;
}
.settings-link.active::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 3px;
  background: var(--color-theme-1);
}
.settings-link:hover {
  background: var(--color-theme-4);
  transform: translateY(-1px);
  border-color: rgba(0,0,0,0.06);
}
.settings-link.active {
  background: var(--color-card-bg);
  border-color: rgba(0,0,0,0.06);
  box-shadow: 0 1px 2px rgba(0,0,0,0.03), inset 0 0 0 1px rgba(0,0,0,0.03);
  font-weight: 600;
}

.settings-main {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-self: start; /* anchor main column to the top of the grid */
  padding-top: 0 !important;
}

.settings-card {
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}
.settings-card.muted {
  background: var(--color-card-bg);
  border-color: rgba(0,0,0,0.06);
}

.settings-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.06);
  transform: translateY(-1px);
  transition: box-shadow .18s ease, transform .12s ease;
}
.settings-section-title {
  margin: 0 0 10px 0;
  font-size: 0.95rem;
  color: var(--color-text);
  letter-spacing: .08em;
  text-transform: uppercase;
  opacity: 0.9;
}

.settings-section-body {
  color: var(--color-text);
  min-height: 160px;
}

/* Form skeleton (non-interactive) */
.form-grid {
  display: grid;
  gap: 16px;
}
.form-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.one { grid-template-columns: 1fr; }

.field { display: grid; gap: 6px; }
.field-label {
  font-size: 12px;
  color: #6b7280;
  letter-spacing: .04em;
  text-transform: none;
}
.field-hint {
  margin: 0 0 6px 0;
  font-size: 12px;
  color: #9aa0a6;
}

/* Inputs are disabled-looking to signal placeholders */
.input,
.select,
.textarea {
  border: 1px solid var(--color-border);
  background: var(--color-card-bg);
  color: var(--color-text);
  border-radius: 10px;
  padding: 10px 12px;
  box-shadow: inset 0 1px 0 rgba(0,0,0,0.02);
}
.input[disabled] { opacity: 0.85; cursor: default; }

.select {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.select-placeholder,
.textarea-placeholder {
  color: #9aa0a6;
}
.select-caret {
  color: #9aa0a6;
  margin-left: 8px;
}

.textarea {
  min-height: 88px;
  display: flex;
  align-items: flex-start;
  padding: 12px;
}

/* demo tiles to hint at Claude appearance cards */
.settings-section-body.grid-demo {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 16px;
}
.settings-section-body.grid-demo .tile {
  border: 1px solid var(--color-border);
  border-radius: 16px;
  aspect-ratio: 2 / 1;
  background: var(--color-card-bg);
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow .16s ease, transform .12s ease, border-color .12s ease;
}
.settings-section-body.grid-demo .tile:hover {
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
  transform: translateY(-1px);
  border-color: rgba(0,0,0,0.12);
}

/* Dark mode parity */
[data-theme="dark"] .settings-link:hover {
  background: rgba(255,255,255,0.06);
}
[data-theme="dark"] .settings-link.active {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.14);
}
[data-theme="dark"] .settings-card {
  border-color: rgba(255,255,255,0.14);
}
[data-theme="dark"] .settings-section-body.grid-demo .tile {
  border-color: rgba(255,255,255,0.14);
  background: #0b1220;
}
[data-theme="dark"] .dc-settings-surface {
  background: var(--color-bg);
}


/* Billing-specific refinements — 2025-10-09 */
.dc-settings-wrap .settings-card .settings-section-body { min-height: 0; }

/* Tighten billing blocks */
#billing-plan,
#billing-invoices {
  padding: 6px 0;
}

/* Readable summary lines */
#billing-plan > div {
  margin: 6px 0;
  font-size: 0.98rem;
}

/* Manage in Stripe: make it a prominent button */
.settings-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 10px;
}

#manage-in-stripe {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-theme-1);
  color: #fff !important;
  text-decoration: none;
  border: 0;
  border-radius: 9999px;
  padding: 10px 14px;
  font-weight: 700;
  letter-spacing: .02em;
  box-shadow: 0 6px 16px rgba(237,118,24,0.22);
  transition: background-color .15s ease, transform .08s ease, box-shadow .15s ease;
}
#manage-in-stripe:hover {
  background: #d66a15;
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(237,118,24,0.28);
}
#manage-in-stripe:focus-visible {
  outline: 3px solid rgba(237,118,24,0.35);
  outline-offset: 2px;
}

/* Invoice table polish */
#billing-invoices .dc-table-wrap {
  overflow: auto;
}

#billing-invoices table {
  width: 100%;
  border-collapse: collapse;
  background: var(--color-card-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
}

#billing-invoices thead th {
  text-align: left;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #666;
  background: var(--color-sidebar-bg);
  padding: 10px 12px;
}

#billing-invoices tbody td {
  padding: 10px 12px;
  border-top: 1px solid var(--color-border);
}

#billing-invoices tbody tr:hover {
  background: rgba(0,0,0,0.03);
}

/* Dark theme parity */
[data-theme="dark"] #billing-invoices table {
  border-color: rgba(255,255,255,0.14);
  background: #0b1220;
}
[data-theme="dark"] #billing-invoices thead th {
  background: rgba(255,255,255,0.06);
  color: #cbd5e0;
}
[data-theme="dark"] #billing-invoices tbody td {
  border-top-color: rgba(255,255,255,0.12);
}
[data-theme="dark"] #billing-invoices tbody tr:hover {
  background: rgba(255,255,255,0.04);
}

/* Slightly reduce inner card padding on billing pages for better density */
.dc-settings-wrap .settings-main .settings-card {
  padding: 18px;
}
/* Only hide AI sidebar when the settings overlay is visible (not for full settings pages) */
body:has(.settings-overlay.visible) .ai-sidebar { display: none !important; }
body:has(.settings-overlay.visible) .ai-main-content { margin-left: 0 !important; margin-top: 0 !important; }

/* Robust top snap for settings pages via JS-applied class (no :has dependency) */
.ai-main-content.dc-settings-mode { margin-top: 0 !important; }

/* Force settings container to have no top margin inside AI shell */
.ai-main-content .dc-settings-wrap { margin-top: 0 !important; }

/* On full settings pages, keep sidebar but remove extra top gap so content sits at the top */
body:has(.dc-settings-wrap) .ai-main-content { margin-top: 0 !important; }

/* Profile layout refinements */
#profile-section .profile-photo-row {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
#profile-section .profile-photo {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}
#profile-section .profile-photo-actions .btn {
  padding: 8px 14px;
  font-weight: 700;
}
/* Stack upload button and its status vertically */
#profile-section .profile-photo-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
}
/* Photo-specific status under upload button */
#profile-section .profile-photo-msg {
  font-size: 0.9rem;
  margin-top: 2px;
}
/* Save button disabled state (grey) until changes are made) */
#profile-section #save-profile[disabled] {
  background: #9ca3af !important;
  color: #ffffff !important;
  border: 0;
  cursor: not-allowed;
  opacity: 0.85;
}
[data-theme="dark"] #profile-section #save-profile[disabled] {
  background: #4b5563 !important;
  color: #e5e7eb !important;
}
#profile-section .settings-actions {
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}
#profile-section #profile-msg {
  align-self: stretch;
  margin: 0 0 4px 0 !important;
  text-align: left;
}
#profile-section #save-profile {
  align-self: flex-end;
}
#profile-section .input#profile-bio {
  min-height: 120px;
  resize: vertical;
}
/* Profile: add larger gap between name/username and photo */
#profile-section .form-grid.one { margin-bottom: 20px; }

/* Settings row layout for action lines (Data/Account) */
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 0;
  border-top: 1px solid var(--color-border);
}
.settings-row:first-child { border-top: 0; }
.settings-row-text { flex: 1 1 auto; min-width: 0; }
.settings-row-action { flex: 0 0 auto; }
.settings-row .row-title {
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--color-text);
}
.settings-row .row-sub {
  font-size: 0.8rem;
  color: #6b7280;
}

/* Danger button styling */
.btn.btn-danger { background: #ef4444; color: #fff; border: 0; }
.btn.btn-danger:hover { background: #dc2626; }
[data-theme="dark"] .btn.btn-danger { background: #b91c1c; }
[data-theme="dark"] .btn.btn-danger:hover { background: #991b1b; }
/* Success/positive button styling — 2025-10-11 */
.btn.btn-success { background: #10b981; color: #fff; border: 0; }
.btn.btn-success:hover { background: #0ea371; }
[data-theme="dark"] .btn.btn-success { background: #059669; }
[data-theme="dark"] .btn.btn-success:hover { background: #047857; }

/* Ensure Upgrade CTA in Data settings is green even if class stays btn-primary */
.dc-settings-wrap .settings-actions a.btn.btn-primary[href="/pricing"] {
  background: #10b981 !important;
  border: 0 !important;
  color: #fff !important;
}
.dc-settings-wrap .settings-actions a.btn.btn-primary[href="/pricing"]:hover {
  background: #0ea371 !important;
}

/* Storage usage progress bar — 2025-10-12 */
.storage-progress {
  width: 100%;
  height: 8px;
  border-radius: 9999px;
  background: rgba(0,0,0,0.08);
  overflow: hidden;
  margin-top: 6px;
}
.storage-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--color-theme-1);
  border-radius: 9999px;
  transition: width .2s ease;
}
.storage-usage-text {
  margin-top: 6px;
  font-size: 0.9rem;
  color: #6b7280;
}
[data-theme="dark"] .storage-progress {
  background: rgba(255,255,255,0.12);
}

/* Memory list scrollable container */
#memory-list {
  max-height: 400px;
  overflow-y: auto;
  padding-right: 4px;
}
#memory-list::-webkit-scrollbar {
  width: 6px;
}
#memory-list::-webkit-scrollbar-track {
  background: rgba(0,0,0,0.04);
  border-radius: 3px;
}
#memory-list::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
}
#memory-list::-webkit-scrollbar-thumb:hover {
  background: rgba(0,0,0,0.25);
}
[data-theme="dark"] #memory-list::-webkit-scrollbar-track {
  background: rgba(255,255,255,0.04);
}
[data-theme="dark"] #memory-list::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
}
[data-theme="dark"] #memory-list::-webkit-scrollbar-thumb:hover {
  background: rgba(255,255,255,0.25);
}