/* ============================================================
   SkinnyProject — Auth Pages (Login, Register, Account)
   ============================================================ */

/* Auth layout */
.auth-page {
  min-height: calc(100vh - var(--navbar-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-10);
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow);
}

.auth-card__header {
  text-align: center;
  margin-bottom: var(--space-8);
}

.auth-card__title {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-main);
  margin-bottom: var(--space-2);
}

.auth-card__subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.auth-form .input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.auth-form .input-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-main);
}

.auth-form .input {
  width: 100%;
  padding: 0.75rem var(--space-4);
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: var(--text-base);
  transition: border-color var(--transition), box-shadow var(--transition);
}

.auth-form .input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.auth-form .input--error {
  border-color: #ef4444;
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.auth-form__error {
  display: none;
  font-size: var(--text-xs);
  color: #ef4444;
  margin-top: var(--space-1);
}

.auth-form__error.is-visible {
  display: block;
}

.auth-form__submit {
  margin-top: var(--space-2);
}

.auth-form__footer {
  text-align: center;
  margin-top: var(--space-6);
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.auth-form__footer a {
  color: var(--accent);
  font-weight: var(--font-medium);
  text-decoration: none;
}

.auth-form__footer a:hover {
  text-decoration: underline;
}

/* Forgot password link */
.auth-form__forgot {
  text-align: right;
  margin-top: calc(var(--space-2) * -1);
}

.auth-form__forgot a {
  font-size: var(--text-sm);
  color: var(--accent);
  text-decoration: none;
  font-weight: var(--font-medium);
  transition: opacity var(--transition);
}

.auth-form__forgot a:hover {
  text-decoration: underline;
  opacity: 0.85;
}

/* Global alert for auth messages */
.auth-alert {
  display: none;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  margin-bottom: var(--space-4);
  text-align: center;
}

.auth-alert--success {
  display: block;
  background: rgba(34, 211, 165, 0.1);
  border: 1px solid rgba(34, 211, 165, 0.3);
  color: var(--success);
}

.auth-alert--error {
  display: block;
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #ef4444;
}

/* ── Account page ─────────────────────────────────────────── */
.account-page {
  padding-top: calc(var(--navbar-height) + var(--space-10));
  min-height: 100vh;
  padding-bottom: var(--space-16);
}

/* Page header (avatar + name + email) */
.account-page__header {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  max-width: 960px;
  margin: 0 auto var(--space-8);
  padding: var(--space-6) var(--space-8);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.account-page__avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  color: var(--accent);
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  letter-spacing: -1px;
}

.account-page__header-info {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.account-page__name {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text-main);
  margin: 0;
}

.account-page__email {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0;
}

/* Grid */
.account-grid {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: var(--space-6);
  max-width: 960px;
  margin: 0 auto;
  align-items: start;
}

/* Sidebar */
.account-sidebar {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  position: sticky;
  top: calc(var(--navbar-height) + var(--space-4));
}

.account-sidebar__section {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-3);
  border-bottom: 1px solid var(--border);
}

.account-sidebar__section:last-child {
  padding-bottom: 0;
  margin-bottom: 0;
  border-bottom: none;
}

.account-sidebar__section-label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-secondary);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-1);
  opacity: 0.7;
}

.account-sidebar__link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
}

.account-sidebar__link svg {
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity var(--transition);
}

.account-sidebar__link:hover {
  color: var(--text-main);
  background: var(--accent-soft);
}
.account-sidebar__link:hover svg { opacity: 1; }

.account-sidebar__link.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  font-weight: var(--font-semibold);
}
.account-sidebar__link.is-active svg { opacity: 1; color: var(--accent); }

.account-sidebar__link--danger { color: #ef4444; }
.account-sidebar__link--danger svg { color: #ef4444; }
.account-sidebar__link--danger:hover {
  background: rgba(239, 68, 68, 0.08);
  color: #ef4444;
}

/* Content panel */
.account-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* Section inside content */
.account-section {
  padding: var(--space-8);
}

.account-section__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.account-section__title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text-main);
  margin: 0 0 var(--space-1);
}

.account-section__title--sm {
  font-size: var(--text-base);
}

.account-section__subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0;
  line-height: 1.5;
}

/* Divider between sub-sections */
.account-divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--space-8) 0;
}

/* Form */
.account-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  max-width: 480px;
}

.account-form .input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.account-form__actions {
  display: flex;
  gap: var(--space-3);
  padding-top: var(--space-2);
}

/* Input with inline action button */
.input-with-action {
  display: flex;
  gap: var(--space-3);
  align-items: center;
}

.input-with-action .input {
  flex: 1;
  background: var(--surface-2);
  color: var(--text-secondary);
  cursor: default;
}

.input-hint {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  line-height: 1.5;
  margin: 0;
}

/* Password input with show/hide toggle */
.input-password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.input-password-wrap .input {
  padding-right: 44px;
}

.input-password-toggle {
  position: absolute;
  right: 12px;
  background: none;
  border: none;
  padding: 0;
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: color var(--transition);
}
.input-password-toggle:hover { color: var(--text-main); }

/* Password requirements checklist */
.pw-reqs {
  list-style: none;
  padding: 0;
  margin: var(--space-2) 0 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.pw-reqs li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  padding: 3px 0;
  transition: color 0.2s ease;
}

.pw-reqs li.is-met {
  color: var(--success, #10b981);
}

.pw-reqs__icon {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  color: transparent;
  transition: border-color 0.2s ease, background 0.2s ease, color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1px;
}

.pw-reqs li.is-met .pw-reqs__icon {
  border-color: var(--success, #10b981);
  background: var(--success, #10b981);
  color: #fff;
}

/* Password strength bar */
.password-strength {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-1);
}

.password-strength__bar {
  flex: 1;
  height: 4px;
  background: var(--surface-2);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.password-strength__fill {
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  transition: width 0.3s ease, background 0.3s ease;
}

.password-strength__label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  white-space: nowrap;
}

/* Account info grid (read-only fields) */
.account-info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--space-4);
}

.account-info-item {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.account-info-item__label {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  opacity: 0.8;
}

.account-info-item__value {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-main);
}

/* Status badges */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  padding: 2px var(--space-2);
  border-radius: var(--radius-full);
}

.status-badge--verified {
  background: rgba(34, 211, 165, 0.15);
  color: var(--success);
}

.status-badge--unverified {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

/* Loading spinner */
.account-loading {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  padding: var(--space-4) 0;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.spin { animation: spin 1.2s linear infinite; }

/* Subscriptions */
.subs-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sub-card {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition);
}
.sub-card:hover { border-color: var(--accent); }

.sub-card__icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sub-card__info {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
}

.sub-card__name {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-main);
}

.sub-card__detail {
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.sub-card__status {
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.sub-card__status--active {
  background: rgba(34, 211, 165, 0.15);
  color: var(--success);
}

.sub-card__status--expired {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
}

.sub-card__status--no-access {
  background: var(--surface-2);
  color: var(--text-secondary);
}

.sub-card__status--cancelled {
  background: rgba(251, 146, 60, 0.12);
  color: #f97316;
}

.subs-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-10) var(--space-6);
  text-align: center;
  color: var(--text-secondary);
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}
.subs-empty p { margin: 0; font-size: var(--text-sm); }

/* ── Email change modal extras ───────────────────────────── */
.sp-modal--wide {
  max-width: 460px;
  text-align: left;
}

.sp-modal__icon--email,
.sp-modal__icon--code {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
  font-size: 0;
  margin-bottom: var(--space-5);
}

.sp-modal--wide .sp-modal__title {
  text-align: left;
  margin-bottom: var(--space-2);
}

.sp-modal--wide .sp-modal__desc {
  text-align: left;
  margin-bottom: var(--space-5);
}

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

.sp-modal__form .input-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Big centered code input */
.input--code {
  text-align: center;
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  letter-spacing: 0.3em;
  font-family: var(--font-mono, monospace);
  padding: var(--space-4);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.input--code:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Navbar user menu */
.navbar__user-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.navbar__user-btn {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid var(--border);
  background: var(--surface-2);
}

.navbar__user-btn:hover {
  color: var(--text-main);
  border-color: var(--accent);
}

.navbar__user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--font-bold);
}

.navbar__user-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + var(--space-2));
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-2);
  min-width: 180px;
  box-shadow: var(--shadow-lg);
  z-index: 200;
}

.navbar__user-dropdown.is-open {
  display: flex;
  flex-direction: column;
}

.navbar__user-dropdown a {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition);
}

.navbar__user-dropdown a:hover {
  background: var(--accent-soft);
  color: var(--text-main);
}

.navbar__user-dropdown a.logout-link {
  color: #ef4444;
}

.navbar__user-dropdown a.logout-link:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
  .auth-card {
    padding: var(--space-6);
  }

  .account-page__header {
    padding: var(--space-4) var(--space-5);
    gap: var(--space-4);
  }

  .account-page__avatar {
    width: 48px;
    height: 48px;
    font-size: var(--text-xl);
  }

  .account-grid {
    grid-template-columns: 1fr;
  }

  .account-sidebar {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: var(--space-1);
    padding: var(--space-3);
  }

  .account-sidebar__section {
    display: contents;
  }

  .account-sidebar__section-label {
    display: none;
  }

  .account-sidebar__link {
    white-space: nowrap;
    padding: var(--space-2) var(--space-3);
    font-size: var(--text-xs);
  }

  .account-section {
    padding: var(--space-5);
  }

  .account-section__header {
    flex-direction: column;
    align-items: flex-start;
  }

  .account-form {
    max-width: 100%;
  }

  .input-with-action {
    flex-direction: column;
    align-items: stretch;
  }

  .account-info-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .account-info-grid {
    grid-template-columns: 1fr;
  }
}


/* ── SP Modal (shared with subscription modal) ───────────── */
.sp-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sp-modal-overlay.is-open {
  opacity: 1;
  visibility: visible;
}

.sp-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-10);
  text-align: center;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  position: relative;
}

.sp-modal-overlay.is-open .sp-modal {
  transform: scale(1) translateY(0);
}

.sp-modal__close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sp-modal__close:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.sp-modal__icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 2px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-5);
}

.sp-modal__title {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text-main);
  margin: 0 0 var(--space-2);
}

.sp-modal__desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: 1.65;
  margin: 0 0 var(--space-6);
}

.sp-modal__desc strong {
  color: var(--text-main);
}

.sp-modal__actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.sp-modal__footer {
  margin-top: var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-align: center;
}

.sp-modal__footer a {
  color: var(--accent);
  text-decoration: none;
  font-weight: var(--font-medium);
}

.sp-modal__footer a:hover { text-decoration: underline; }

@media (max-width: 480px) {
  .sp-modal { padding: var(--space-7) var(--space-5); }
  .sp-modal__icon { width: 56px; height: 56px; }
}

/* ── Toast notifications ─────────────────────────────────── */
#sp-toast-container {
  position: fixed;
  top: calc(var(--navbar-height, 64px) + 16px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 99999;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  width: max-content;
  max-width: calc(100vw - 32px);
}

.sp-toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border-radius: var(--radius-md, 8px);
  font-size: var(--text-sm, 0.875rem);
  font-weight: var(--font-medium, 500);
  font-family: var(--font-sans, system-ui, sans-serif);
  line-height: 1.45;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.22);
  pointer-events: all;
  cursor: default;
  min-width: 240px;
  max-width: 440px;
  border: 1px solid transparent;
  animation: sp-toast-in 0.28s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
  will-change: transform, opacity;
}

.sp-toast.sp-toast--leaving {
  animation: sp-toast-out 0.22s ease-in forwards;
}

@keyframes sp-toast-in {
  from { opacity: 0; transform: translateY(-14px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

@keyframes sp-toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(-10px) scale(0.95); }
}

/* Success */
.sp-toast--success {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #10b981;
}
[data-theme="light"] .sp-toast--success {
  background: rgba(16, 185, 129, 0.10);
  color: #047857;
}

/* Error */
.sp-toast--error {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.35);
  color: #ef4444;
}
[data-theme="light"] .sp-toast--error {
  background: rgba(239, 68, 68, 0.09);
  color: #dc2626;
}

/* Info */
.sp-toast--info {
  background: rgba(96, 165, 250, 0.12);
  border-color: rgba(96, 165, 250, 0.35);
  color: #60a5fa;
}
[data-theme="light"] .sp-toast--info {
  background: rgba(59, 130, 246, 0.09);
  color: #2563eb;
}

/* Icon inside toast */
.sp-toast__icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}

/* Text */
.sp-toast__text {
  flex: 1;
}

/* Close button */
.sp-toast__close {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  color: inherit;
  opacity: 0.55;
  display: flex;
  align-items: center;
  transition: opacity 0.15s;
  margin-left: 4px;
}
.sp-toast__close:hover { opacity: 1; }
