/* ==========================================================================
   AUTH SCREENS & USER SYSTEM STYLES (COGNITIVE CALM REDESIGN)
   styles/auth.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   AUTH SCREEN (Login & Signup share these styles)
   -------------------------------------------------------------------------- */
.auth-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 32px 24px;
  overflow-y: auto;
  height: 100%;
}

.auth-box {
  background: var(--surface-lowest);
  border-radius: var(--radius-card);
  padding: 40px 32px;
  width: 100%;
  max-width: 380px;
  box-shadow: var(--shadow-1);
  margin-top: 20px;
  border: 1px solid rgba(0,0,0,0.02);
}

.auth-title {
  font-family: 'Manrope', sans-serif;
  font-size: 32px;
  font-weight: 800;
  color: var(--on-surface);
  margin-bottom: 8px;
  letter-spacing: -0.01em;
}

.auth-subtitle {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16px;
  color: var(--on-surface-variant);
  margin-bottom: 32px;
}

.auth-field {
  width: 100%;
  margin-bottom: 20px;
}

.auth-field label {
  display: block;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 14px;
  color: var(--on-surface-variant);
  margin-bottom: 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.auth-field input {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16px;
  color: var(--on-surface);
  background: var(--surface-low);
  outline: none;
  transition: background 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.auth-field input::placeholder {
  color: var(--outline);
}

.auth-field input:focus {
  background: var(--surface-lowest);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-1);
}

.auth-error {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 14px;
  color: var(--on-error);
  background: var(--error);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  margin-bottom: 20px;
  display: none;
}

.auth-error.visible {
  display: block;
}

.auth-btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
  box-shadow: var(--shadow-1);
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-btn-primary:active {
  transform: scale(0.97);
  box-shadow: none;
}

.auth-btn-primary:disabled {
  background: var(--surface-dim);
  box-shadow: none;
  cursor: not-allowed;
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 32px 0;
}

.auth-divider-line {
  flex: 1;
  height: 1px;
  background: var(--outline-variant);
}

.auth-divider-text {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 12px;
  color: var(--outline);
  font-weight: 500;
}

.auth-switch {
  text-align: center;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16px;
  color: var(--on-surface-variant);
  margin-top: 24px;
}

.auth-switch a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 700;
  cursor: pointer;
}

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

.auth-spinner {
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255,255,255,0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.auth-spinner.visible {
  display: inline-block;
}

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

/* --------------------------------------------------------------------------
   HEADER — User Avatar & Logout Button
   -------------------------------------------------------------------------- */
#auth-header-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: transform 0.2s;
}

#auth-header-btn:active {
  transform: scale(0.92);
}

#user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Manrope', sans-serif;
  font-size: 14px;
  font-weight: 800;
  color: var(--on-primary);
  flex-shrink: 0;
}

#login-header-icon {
  width: 24px;
  height: 24px;
  cursor: pointer;
  transition: transform 0.2s;
  color: var(--on-surface-variant);
}

#login-header-icon:active {
  transform: scale(0.9);
}

/* --------------------------------------------------------------------------
   STAR (IMPORTANT) BUTTON ON FLASHCARDS
   -------------------------------------------------------------------------- */
#important-btn-container {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 20;
}

#important-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  transition: transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

#important-btn:active {
  transform: scale(0.85);
}

#important-btn svg {
  width: 28px;
  height: 28px;
  transition: fill 0.25s ease, stroke 0.25s ease;
}

/* Default state */
#important-btn .star-icon {
  fill: transparent;
  stroke: var(--outline-variant);
  stroke-width: 2;
}

/* Saved state */
#important-btn.is-important .star-icon {
  fill: #f5a623;
  stroke: #e09010;
  stroke-width: 1.5;
}

@keyframes starPop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.5); }
  70%  { transform: scale(0.85); }
  100% { transform: scale(1); }
}

#important-btn.popping {
  animation: starPop 0.4s ease forwards;
}

/* --------------------------------------------------------------------------
   IMPORTANT DECK SCREEN
   -------------------------------------------------------------------------- */
.important-screen-wrapper {
  padding: 24px;
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.important-screen-title {
  font-family: 'Manrope', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--on-surface);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.important-screen-subtitle {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16px;
  color: var(--on-surface-variant);
  margin-bottom: 24px;
}

.important-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 8px;
}

/* --------------------------------------------------------------------------
   LOGIN PROMPT TOAST (shown when guest tries to star a card)
   -------------------------------------------------------------------------- */
#login-toast {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--inverse-surface, #2e3132);
  color: var(--inverse-on-surface, #f0f1f2);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 14px;
  padding: 12px 24px;
  border-radius: 24px;
  white-space: nowrap;
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

#login-toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --------------------------------------------------------------------------
   FULL-SCREEN LOADING OVERLAY
   -------------------------------------------------------------------------- */
#auth-loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(248, 249, 250, 0.95);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.4s ease;
}

#auth-loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.auth-loading-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--surface-low);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

.auth-loading-text {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16px;
  color: var(--on-surface-variant);
}

/* --------------------------------------------------------------------------
   GOOGLE SIGN-IN BUTTON
   -------------------------------------------------------------------------- */
.auth-btn-google {
  width: 100%;
  padding: 16px;
  background: var(--surface-lowest);
  color: var(--on-surface);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-md);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, box-shadow 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}

.auth-btn-google:active {
  background-color: var(--surface-low);
}

.auth-btn-google svg {
  width: 24px;
  height: 24px;
}

/* --------------------------------------------------------------------------
   IMPORTANT DECK GRID (REPLACES OLD TEXT LIST)
   -------------------------------------------------------------------------- */
.imp-grid-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.imp-chapter-group {
  display: flex;
  flex-direction: column;
}

.imp-chapter-title {
  font-family: 'Manrope', sans-serif;
  font-size: 16px;
  font-weight: 700;
  color: var(--on-surface-variant);
  border-bottom: 1px dashed var(--outline-variant);
  padding-bottom: 8px;
  margin-bottom: 16px;
}

.imp-decks-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.imp-deck-card {
  position: relative;
  background-color: var(--surface-lowest);
  border: 1px solid var(--outline-variant);
  border-radius: var(--radius-md);
  padding: 20px;
  text-align: left;
  font-size: 16px;
  font-weight: 600;
  color: var(--on-surface);
  cursor: pointer;
  box-shadow: var(--shadow-1);
  transition: transform 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.imp-deck-card:active {
  transform: scale(0.98);
}

.imp-reset-btn {
  background: none;
  border: none;
  color: var(--outline);
  font-size: 20px;
  cursor: pointer;
  padding: 4px;
  transition: color 0.2s;
}

.imp-reset-btn:active,
.imp-reset-btn:hover {
  color: var(--error);
}

/* --------------------------------------------------------------------------
   PREMIUM PROFILE MODAL
   -------------------------------------------------------------------------- */
.profile-modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(248, 249, 250, 0.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  z-index: 10000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 1;
  transition: opacity 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.profile-modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.profile-modal-card {
  background: var(--surface-lowest);
  width: 90%;
  max-width: 400px;
  border-radius: 32px;
  padding: 40px 30px;
  box-shadow: var(--shadow-2);
  text-align: center;
  position: relative;
  transform: translateY(0) scale(1);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid rgba(0,0,0,0.04);
}

.profile-modal-overlay.hidden .profile-modal-card {
  transform: translateY(30px) scale(0.95);
}

.profile-modal-close {
  position: absolute;
  top: 24px;
  right: 24px;
  background: var(--surface-low);
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 16px;
  color: var(--on-surface-variant);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.profile-modal-close:active {
  background: var(--outline-variant);
}

.profile-modal-avatar-container {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.profile-modal-pic,
.profile-modal-initial {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  box-shadow: var(--shadow-1);
  border: 4px solid var(--surface-lowest);
  object-fit: cover;
}

.profile-modal-initial {
  background: var(--primary);
  color: var(--on-primary);
  font-size: 40px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Manrope', sans-serif;
}

.profile-modal-name {
  font-family: 'Manrope', sans-serif;
  font-size: 28px;
  font-weight: 800;
  color: var(--on-surface);
  margin-bottom: 8px;
}

.profile-modal-email {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16px;
  color: var(--on-surface-variant);
  margin-bottom: 32px;
}

.profile-modal-quote {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16px;
  color: var(--on-surface-variant);
  font-style: italic;
  line-height: 1.6;
  margin-bottom: 40px;
  padding: 0 16px;
}

.profile-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.profile-modal-logout-btn {
  width: 100%;
  padding: 16px 24px;
  background-color: var(--surface-lowest);
  color: var(--error);
  border: 1px solid var(--error);
  border-radius: var(--radius-md);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.profile-modal-logout-btn:active {
  transform: scale(0.97);
  background-color: rgba(186, 26, 26, 0.05);
}

.profile-modal-update-btn {
  width: 100%;
  padding: 16px 24px;
  background-color: var(--primary);
  color: var(--on-primary);
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s, transform 0.1s;
}

.profile-modal-update-btn:active {
  transform: scale(0.97);
  background-color: var(--primary-dim);
}

.update-profile-title {
  font-family: 'Manrope', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--on-surface);
  margin-bottom: 32px;
  text-align: center;
}

.update-profile-form {
  width: 100%;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 14px;
  color: var(--on-surface-variant);
  margin-bottom: 8px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-md);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16px;
  color: var(--on-surface);
  background: var(--surface-low);
  outline: none;
  transition: background 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.form-group input::placeholder {
  color: var(--outline);
}

.form-group input:focus,
.form-group select:focus {
  background: var(--surface-lowest);
  box-shadow: 0 0 0 1px var(--primary), var(--shadow-1);
}

.update-profile-actions {
  margin-top: 24px;
}

/* --------------------------------------------------------------------------
   CUSTOM CONFIRM MODAL
   -------------------------------------------------------------------------- */
.custom-confirm-card {
  background: var(--surface-lowest);
  width: 90%;
  max-width: 380px;
  border-radius: 24px;
  padding: 32px;
  box-shadow: var(--shadow-2);
  text-align: center;
  position: relative;
  transform: translateY(0) scale(1);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border: 1px solid rgba(0,0,0,0.04);
}

.profile-modal-overlay.hidden .custom-confirm-card {
  transform: translateY(20px) scale(0.95);
}

.custom-confirm-title {
  font-family: 'Manrope', sans-serif;
  font-size: 24px;
  font-weight: 800;
  color: var(--on-surface);
  margin-bottom: 12px;
}

.custom-confirm-message {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-size: 16px;
  color: var(--on-surface-variant);
  line-height: 1.5;
  margin-bottom: 32px;
}

.custom-confirm-actions {
  display: flex;
  gap: 16px;
}

.custom-confirm-btn {
  flex: 1;
  padding: 14px 0;
  border-radius: var(--radius-md);
  font-family: 'Be Vietnam Pro', sans-serif;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  border: none;
  transition: transform 0.2s;
}

.custom-confirm-btn:active {
  transform: scale(0.96);
}

.custom-confirm-btn.cancel {
  background-color: var(--surface-low);
  color: var(--on-surface);
}

.custom-confirm-btn.action {
  background-color: var(--primary);
  color: var(--on-primary);
}

.custom-confirm-btn.action.destructive {
  background-color: var(--error);
}
