/* ═══════════════════════════════════════════════
   Auth Styles — Supabase Login Modal & Sidebar
   ChatPSLE
   ═══════════════════════════════════════════════ */

/* ── SIDEBAR AUTH SECTION ──────────────────────── */
.sidebar-auth {
  margin-bottom: 14px;
}
.auth-signin-btn {
  width: 100%;
  padding: 10px 0;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.2);
  background: rgba(255,255,255,.08);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 10.5pt;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.auth-signin-btn:hover {
  background: rgba(255,255,255,.15);
}
.auth-hint {
  text-align: center;
  font-size: 8.5pt;
  color: rgba(255,255,255,.35);
  margin-top: 6px;
}

/* Logged-in state */
.auth-user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.auth-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--gold);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.auth-user-details {
  flex: 1;
  min-width: 0;
}
.auth-user-name {
  color: #fff;
  font-weight: 600;
  font-size: 10pt;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auth-user-email {
  color: rgba(255,255,255,.4);
  font-size: 8pt;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.auth-signout-btn {
  width: 100%;
  padding: 6px 0;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,.12);
  background: transparent;
  color: rgba(255,255,255,.5);
  font-family: 'DM Sans', sans-serif;
  font-size: 9pt;
  cursor: pointer;
  transition: all .15s;
}
.auth-signout-btn:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.8);
}

/* ── LOGIN MODAL ───────────────────────────────── */
.auth-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,39,68,.55);
  backdrop-filter: blur(4px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.auth-modal {
  background: #fff;
  border-radius: 20px;
  width: 380px;
  max-width: calc(100vw - 32px);
  padding: 36px 32px 32px;
  position: relative;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  font-family: 'DM Sans', sans-serif;
}
.auth-modal-close {
  position: absolute;
  top: 14px;
  right: 18px;
  background: none;
  border: none;
  font-size: 22px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1;
}
.auth-modal-close:hover { color: var(--ink); }

.auth-modal-brand {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 26pt;
  font-weight: 700;
  color: var(--navy);
  text-align: center;
  margin-bottom: 4px;
}
.auth-modal-brand em {
  color: var(--gold);
  font-style: italic;
  font-weight: 300;
}
.auth-modal-sub {
  text-align: center;
  color: var(--muted);
  font-size: 10.5pt;
  margin-bottom: 24px;
}

/* Google button */
.auth-google-btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 10.5pt;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: all .15s;
}
.auth-google-btn:hover {
  background: #f8f8f8;
  border-color: #ccc;
}
.auth-google-btn svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Divider */
.auth-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  gap: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.auth-divider span {
  font-size: 9pt;
  color: var(--muted);
  white-space: nowrap;
}

/* Email form */
.auth-email-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  font-family: 'DM Sans', sans-serif;
  font-size: 10.5pt;
  color: var(--ink);
  outline: none;
  transition: border-color .15s;
  margin-bottom: 10px;
}
.auth-email-input:focus {
  border-color: var(--navy2);
}
.auth-email-btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: none;
  background: var(--navy);
  color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 10.5pt;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.auth-email-btn:hover {
  background: var(--navy2);
}
.auth-email-btn:disabled {
  background: #aaa;
  cursor: default;
}

/* Footer links (forgot password, toggle sign up/in) */
.auth-footer-links {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 9.5pt;
}
.auth-footer-links.single { justify-content: center; }
.auth-footer-links a {
  color: var(--navy2, #2b4f7e);
  text-decoration: none;
  cursor: pointer;
}
.auth-footer-links a:hover { text-decoration: underline; }

/* Hint text above sub-forms */
.auth-view-hint {
  text-align: center;
  color: var(--muted);
  font-size: 10pt;
  margin: 0 0 16px;
  line-height: 1.5;
}

/* Feedback message */
.auth-message {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 9.5pt;
  text-align: center;
}
.auth-message.auth-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}
.auth-message.auth-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

/* ── PROFILE INFO (sidebar) ───────────────────── */
.auth-profile-info {
  margin: 8px 0;
  padding: 8px 10px;
  background: rgba(255,255,255,.06);
  border-radius: 8px;
  font-size: 9pt;
  color: rgba(255,255,255,.55);
  line-height: 1.6;
}
.auth-profile-info span {
  color: rgba(255,255,255,.85);
  font-weight: 600;
}
.auth-profile-actions {
  display: flex; gap: 6px; margin-top: 6px;
}
.auth-profile-edit-btn,
.auth-profile-sub-btn {
  flex: 1;
  padding: 5px 0;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,.12);
  background: transparent;
  color: rgba(255,255,255,.5);
  font-family: 'DM Sans', sans-serif;
  font-size: 8.5pt;
  cursor: pointer;
  transition: all .15s;
}
.auth-profile-edit-btn:hover,
.auth-profile-sub-btn:hover {
  background: rgba(255,255,255,.08);
  color: rgba(255,255,255,.8);
}
.auth-sub-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 8pt;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
}
.auth-sub-free { background: rgba(255,255,255,.1); color: rgba(255,255,255,.5); }
.auth-sub-premium { background: #f0c060; color: #4a3000; }

/* ── PROFILE MODAL ────────────────────────────── */
.profile-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,39,68,.55);
  backdrop-filter: blur(4px);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
}
.profile-modal {
  background: #fff;
  border-radius: 20px;
  width: 420px;
  max-width: calc(100vw - 32px);
  padding: 36px 32px 32px;
  position: relative;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  font-family: 'DM Sans', sans-serif;
}
.profile-modal-close {
  position: absolute; top: 14px; right: 18px;
  background: none; border: none; font-size: 22px; color: var(--muted); cursor: pointer; line-height: 1;
}
.profile-modal-close:hover { color: var(--ink); }
.profile-modal h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 18pt; font-weight: 700; color: var(--navy);
  margin: 0 0 4px; text-align: center;
}
.profile-modal p.profile-sub {
  text-align: center; color: var(--muted); font-size: 10pt; margin: 0 0 24px;
}
.profile-field { margin-bottom: 16px; }
.profile-field label {
  display: block; font-size: 9.5pt; font-weight: 600; color: var(--ink);
  margin-bottom: 6px; letter-spacing: .3px;
}
.profile-field select,
.profile-field input {
  width: 100%; padding: 11px 14px; border-radius: 12px;
  border: 1px solid var(--border); font-family: 'DM Sans', sans-serif;
  font-size: 10.5pt; color: var(--ink); outline: none; background: #fff;
  transition: border-color .15s; appearance: none;
  -webkit-appearance: none;
}
.profile-field select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='7'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%237a7570' fill='none' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.profile-field select:focus,
.profile-field input:focus { border-color: var(--navy2); }
.profile-save-btn {
  width: 100%; padding: 12px; border-radius: 12px; border: none;
  background: var(--navy); color: #fff; font-family: 'DM Sans', sans-serif;
  font-size: 10.5pt; font-weight: 600; cursor: pointer; transition: background .15s;
  margin-top: 8px;
}
.profile-save-btn:hover { background: var(--navy2); }
.profile-save-btn:disabled { background: #aaa; cursor: default; }
.profile-edit-note {
  text-align: center; font-size: 9pt; color: var(--muted); margin-top: 12px;
}
.profile-edit-note strong { color: var(--coral); }

/* Change Password button inside Edit Profile modal */
.profile-change-pw-btn {
  width: 100%; padding: 11px; border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff; color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-size: 10pt; font-weight: 600; cursor: pointer;
  margin-top: 10px;
  transition: background .15s, border-color .15s;
}
.profile-change-pw-btn:hover {
  background: #f8f8f8;
  border-color: #c0c0c0;
}

/* Change Password popup — stacks above profile modal */
.change-pw-overlay { z-index: 10001; }
.change-pw-modal { width: 400px; }

/* Inline message inside the Change Password popup */
.profile-password-message {
  margin-top: 10px; padding: 8px 12px; border-radius: 8px;
  font-size: 9.5pt; text-align: center;
}
.profile-password-message.success {
  background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0;
}
.profile-password-message.error {
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
}

/* Subscription premium card styles are inline in index.html */

/* ── BILLING MODAL ───────────────────────────── */
.profile-billing-btn {
  width: 100%; padding: 11px; border-radius: 12px;
  border: 1px solid var(--border);
  background: #fff; color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-size: 10pt; font-weight: 600; cursor: pointer;
  margin-top: 10px;
  transition: background .15s, border-color .15s;
}
.profile-billing-btn:hover {
  background: #f8f8f8;
  border-color: #c0c0c0;
}
.billing-modal {
  background: #fff;
  border-radius: 20px;
  width: 520px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  overflow-y: auto;
  padding: 36px 32px 32px;
  position: relative;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  font-family: 'DM Sans', sans-serif;
}
.billing-modal h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 18pt; font-weight: 700; color: var(--navy);
  margin: 0 0 20px; text-align: center;
}
.billing-plan-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px 18px;
  background: #fafafa;
}
.billing-plan-name {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 14pt; font-weight: 700; color: var(--navy);
  margin-bottom: 4px;
}
.billing-plan-meta {
  font-size: 10pt; color: var(--muted);
}
.billing-plan-meta strong { color: var(--ink); font-weight: 600; }
.billing-actions { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.billing-secondary-btn {
  width: 100%; padding: 11px; border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff; color: var(--ink);
  font-family: 'DM Sans', sans-serif;
  font-size: 10pt; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.billing-secondary-btn:hover { background: #f8fafc; border-color: #cbd5e1; }
.billing-secondary-btn:disabled { opacity: .6; cursor: not-allowed; }
.billing-primary-btn {
  width: 100%; padding: 12px; border-radius: 12px; border: none;
  background: var(--navy); color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 10.5pt; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.billing-primary-btn:hover { background: var(--navy2); }
.billing-danger-btn {
  width: 100%; padding: 11px; border-radius: 12px;
  border: 1px solid #fecaca;
  background: #fff; color: #991b1b;
  font-family: 'DM Sans', sans-serif;
  font-size: 10pt; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.billing-danger-btn:hover { background: #fef2f2; border-color: #fca5a5; }
.billing-cancel-notice {
  padding: 10px 12px; border-radius: 10px;
  background: #fffbeb; color: #92400e; border: 1px solid #fde68a;
  font-size: 9.5pt; text-align: center;
}
.billing-invoices-section { margin-top: 24px; }
.billing-section-label {
  font-size: 9.5pt; font-weight: 600; color: var(--ink);
  letter-spacing: .3px; margin-bottom: 8px; text-transform: uppercase;
}
.billing-invoices-list {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}
.billing-invoice-row {
  display: grid;
  grid-template-columns: 1.2fr 1fr .8fr .6fr;
  gap: 8px;
  align-items: center;
  padding: 10px 14px;
  font-size: 9.5pt;
  border-bottom: 1px solid var(--border);
}
.billing-invoice-row:last-child { border-bottom: none; }
.billing-invoice-date { color: var(--ink); }
.billing-invoice-amount { color: var(--ink); font-weight: 600; }
.billing-invoice-status {
  text-transform: capitalize; color: var(--muted); font-size: 9pt;
}
.billing-status-paid { color: #166534; }
.billing-status-open, .billing-status-uncollectible, .billing-status-void { color: #991b1b; }
.billing-invoice-link a {
  color: var(--navy); text-decoration: none; font-weight: 600;
}
.billing-invoice-link a:hover { text-decoration: underline; }
.billing-invoice-empty,
.billing-invoice-error {
  padding: 14px; text-align: center;
  font-size: 9.5pt; color: var(--muted);
}
.billing-invoice-error { color: #991b1b; }

/* ── CANCEL CONFIRM MODAL ─────────────────────── */
.cancel-confirm-card {
  background: #fff;
  border-radius: 20px;
  width: 400px;
  max-width: calc(100vw - 32px);
  padding: 36px 28px 24px;
  position: relative;
  box-shadow: 0 12px 40px rgba(0,0,0,.2);
  font-family: 'DM Sans', sans-serif;
  z-index: 10002;
}
.cancel-confirm-card h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-size: 14pt; font-weight: 700; color: var(--navy);
  margin: 0 0 8px; text-align: center;
}
.cancel-confirm-card p {
  font-size: 10pt; color: var(--ink);
  text-align: center; margin: 0 0 20px;
}
.cancel-confirm-actions {
  display: flex; flex-direction: column; gap: 8px;
}
.cancel-keep-btn {
  width: 100%; padding: 12px; border-radius: 12px; border: none;
  background: var(--navy); color: #fff;
  font-family: 'DM Sans', sans-serif;
  font-size: 10.5pt; font-weight: 600; cursor: pointer;
  transition: background .15s;
}
.cancel-keep-btn:hover { background: var(--navy2); }
.cancel-confirm-btn {
  width: 100%; padding: 11px; border-radius: 12px;
  border: 1px solid #fecaca;
  background: #fff; color: #991b1b;
  font-family: 'DM Sans', sans-serif;
  font-size: 10pt; font-weight: 600; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.cancel-confirm-btn:hover { background: #fef2f2; border-color: #fca5a5; }
.cancel-confirm-btn:disabled { opacity: .6; cursor: default; }
.cancel-confirm-error {
  margin-top: 10px; padding: 8px 12px; border-radius: 8px;
  background: #fef2f2; color: #991b1b; border: 1px solid #fecaca;
  font-size: 9.5pt; text-align: center;
}

/* Cancel confirm overlay stacks above billing modal */
#cancelConfirmModal { z-index: 10002; }

/* ── RESPONSIVE ────────────────────────────────── */
@media (max-width: 600px) {
  .auth-modal {
    padding: 28px 20px 24px;
    border-radius: 16px;
  }
  .profile-modal,
  .billing-modal,
  .cancel-confirm-card {
    padding: 28px 20px 24px;
    border-radius: 16px;
  }
  .billing-invoice-row {
    grid-template-columns: 1fr 1fr;
    row-gap: 4px;
  }
}
