/* ==========================================================================
   DevPilot-AI - Workspace Settings CSS
   ========================================================================== */

.settings-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 1024px) {
  .settings-layout {
    display: grid;
    grid-template-columns: 210px 1fr;
    gap: 1.5rem;
    align-items: start;
  }
}

/* Settings Navigation Tabs */
.settings-nav {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  gap: 0.5rem;
}

@media (min-width: 1024px) {
  .settings-nav {
    flex-direction: column;
    flex-wrap: nowrap;
    position: sticky;
    top: 96px;
  }
}

.settings-tab-btn {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.875rem;
  min-height: 40px;
  border-radius: var(--radius-md, 8px);
  color: var(--color-on-surface-variant, #464554);
  font-weight: 500;
  font-size: 0.875rem;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast, 0.15s ease);
}

@media (max-width: 639px) {
  .settings-tab-btn {
    flex: 1 1 auto;
    justify-content: center;
    padding: 0.45rem 0.65rem;
    font-size: 0.8125rem;
  }
}

.settings-tab-btn:hover {
  background: var(--color-surface-container, #efecf8);
  color: var(--color-on-surface, #1b1b23);
}

.settings-tab-btn.active {
  background: #eef2ff;
  border-color: rgba(70, 72, 212, 0.18);
  color: var(--color-primary, #4648d4);
  font-weight: 600;
}

/* Settings Section Panels */
.settings-section {
  display: none;
}

.settings-section.active {
  display: block;
}

/* Compact Avatar Picker in Settings */
.settings-avatar-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.625rem;
  align-items: center;
}

.settings-avatar-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.625rem;
  border-radius: 12px;
  border: 2px solid var(--color-outline-variant, #c7c4d7);
  background: var(--color-surface-container-low, #f5f2fe);
  cursor: pointer;
  transition: all 0.15s ease;
  width: 72px;
  user-select: none;
}

.settings-avatar-btn:hover {
  border-color: rgba(70, 72, 212, 0.4);
  background: #ffffff;
  transform: translateY(-1px);
}

.settings-avatar-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(70, 72, 212, 0.25);
}

.settings-avatar-btn.selected {
  border-color: var(--color-primary, #4648d4);
  background: #ffffff;
  box-shadow: 0 0 0 2px rgba(70, 72, 212, 0.18);
}

.settings-avatar-wrapper {
  position: relative;
  width: 44px;
  height: 44px;
}

.settings-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  object-fit: cover;
}

.settings-avatar-check {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 16px;
  height: 16px;
  border-radius: 9999px;
  background: var(--color-primary, #4648d4);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.6);
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1.5px solid #ffffff;
}

.settings-avatar-btn.selected .settings-avatar-check {
  opacity: 1;
  transform: scale(1);
}

.settings-avatar-label {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-on-surface-variant, #464554);
  line-height: 1.2;
}

.settings-avatar-btn.selected .settings-avatar-label {
  color: var(--color-primary, #4648d4);
}

/* Switch Toggle */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--color-surface-container-highest, #e4e1ed);
  transition: .25s ease;
  border-radius: 24px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: .25s ease;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

input:checked + .toggle-slider {
  background-color: var(--color-primary, #4648d4);
}

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

/* Logout Button */
.btn-logout-devpilot {
  background-color: rgba(186, 26, 26, 0.08);
  color: #ba1a1a;
  border: 1.5px solid rgba(186, 26, 26, 0.25);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.btn-logout-devpilot::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(186, 26, 26, 0.12), rgba(186, 26, 26, 0.04));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.btn-logout-devpilot:hover {
  background-color: #ba1a1a;
  color: #ffffff;
  border-color: #ba1a1a;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(186, 26, 26, 0.25);
}

.btn-logout-devpilot:hover::before {
  opacity: 1;
}

.btn-logout-devpilot:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(186, 26, 26, 0.2);
}

.btn-logout-devpilot:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.btn-logout-devpilot .logout-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: logout-spin 0.6s linear infinite;
}

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

/* Logout Section Spacing */
.settings-logout-section {
  margin-top: 0.5rem;
}

/* ============================================
   Delete Account Button & Modals
   ============================================ */

/* Delete Account Section Spacing */
.settings-delete-account-section {
  margin-top: 0.25rem;
}

/* Delete Account Button — subtle danger, smaller than logout */
.btn-delete-account {
  background-color: rgba(186, 26, 26, 0.05);
  color: #ba1a1a;
  border: 1px solid rgba(186, 26, 26, 0.18);
  cursor: pointer;
  position: relative;
  overflow: hidden;
  font-size: 0.8125rem;
}

.btn-delete-account::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(186, 26, 26, 0.10), rgba(186, 26, 26, 0.03));
  opacity: 0;
  transition: opacity 0.2s ease;
}

.btn-delete-account:hover {
  background-color: rgba(186, 26, 26, 0.12);
  color: #93000a;
  border-color: rgba(186, 26, 26, 0.35);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(186, 26, 26, 0.15);
}

.btn-delete-account:hover::before {
  opacity: 1;
}

.btn-delete-account:active {
  transform: translateY(0);
  box-shadow: 0 1px 3px rgba(186, 26, 26, 0.12);
}

.btn-delete-account:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
  pointer-events: none;
}

.btn-delete-account .delete-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: logout-spin 0.6s linear infinite;
}

/* ---------- Modal Overlay ---------- */
.devpilot-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: modalFadeIn 0.2s ease;
}

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

/* ---------- Modal Dialog ---------- */
.devpilot-modal {
  background: var(--color-surface-container, #1e1f25);
  border: 1px solid var(--color-outline-variant, rgba(255, 255, 255, 0.08));
  border-radius: 16px;
  padding: 28px 28px 24px;
  max-width: 440px;
  width: 92vw;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.45), 0 8px 24px rgba(0, 0, 0, 0.25);
  animation: modalSlideIn 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.devpilot-modal--final {
  border-color: rgba(186, 26, 26, 0.20);
}

.devpilot-modal--success {
  border-color: rgba(16, 185, 129, 0.25);
}

/* ---------- Modal Header ---------- */
.devpilot-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.devpilot-modal-icon {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  color: #fbbf24;
}

.devpilot-modal-icon--danger {
  color: #ef4444;
}

.devpilot-modal-icon--success {
  color: #10b981;
}

.devpilot-modal-title {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--color-on-surface, #e4e1e9);
  margin: 0;
  line-height: 1.3;
}

.devpilot-modal-title--danger {
  color: #fca5a5;
}

.devpilot-modal-title--success {
  color: #6ee7b7;
}

/* ---------- Modal Body ---------- */
.devpilot-modal-message {
  font-size: 0.875rem;
  color: var(--color-on-surface-variant, #c4c0cc);
  line-height: 1.6;
  margin: 0 0 20px 0;
}

.devpilot-modal-redirect-note {
  font-size: 0.8125rem;
  color: rgba(196, 192, 204, 0.6);
  font-style: italic;
  margin-bottom: 0;
}

/* ---------- Checkbox Row ---------- */
.devpilot-checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px 16px;
  margin: 0 0 20px 0;
  background: rgba(186, 26, 26, 0.06);
  border: 1px solid rgba(186, 26, 26, 0.15);
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease;
  user-select: none;
}

.devpilot-checkbox-row:hover {
  background: rgba(186, 26, 26, 0.10);
}

.devpilot-checkbox {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  accent-color: #ef4444;
  cursor: pointer;
}

.devpilot-checkbox-text {
  font-size: 0.8125rem;
  color: var(--color-on-surface, #e4e1e9);
  line-height: 1.45;
}

/* ---------- Modal Actions ---------- */
.devpilot-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-modal-cancel {
  padding: 8px 20px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-on-surface-variant, #c4c0cc);
  background: transparent;
  border: 1px solid var(--color-outline-variant, rgba(255, 255, 255, 0.10));
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-modal-cancel:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.16);
}

.btn-modal-continue {
  padding: 8px 20px;
  font-size: 0.8125rem;
  font-weight: 600;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.25);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-modal-continue:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.4);
}

.btn-modal-delete-final {
  padding: 8px 20px;
  font-size: 0.8125rem;
  font-weight: 700;
  color: #ffffff;
  background: #dc2626;
  border: 1px solid #dc2626;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-modal-delete-final:hover:not(:disabled) {
  background: #b91c1c;
  border-color: #b91c1c;
  box-shadow: 0 2px 10px rgba(220, 38, 38, 0.3);
}

.btn-modal-delete-final:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.btn-modal-delete-final .delete-spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: logout-spin 0.6s linear infinite;
  margin-right: 6px;
}
