/*
===============================================================================
| REEBUX - Auth Modal (Bottom-Sheet) v3.0                                   |
===============================================================================
| Premium bottom-sheet card with slide-up animation, drag-to-dismiss,        |
| forgot-password isolation, social auth, password eye toggle, scroll lock.  |
===============================================================================
*/

/* ── Desktop background shapes (hidden on mobile) ── */
.auth-screen-bg { display: none; }

/* ── Scroll lock (body level) ── */
html.ame-modal-open, html.ame-modal-open body {
  overflow: hidden !important;
  touch-action: none !important;
  overscroll-behavior: none !important;
  height: 100% !important;
  position: relative;
}

/* ── Modal overlay ── */
#auth-modal {
  position: fixed; inset: 0; z-index: 99999;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  touch-action: none;
  visibility: hidden; pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease, visibility 0s 0.55s;
}
#auth-modal.open {
  visibility: visible; pointer-events: auto;
  opacity: 1;
  transition: opacity 0.35s ease, visibility 0s 0s;
}

/* ── Sheet / Card ── */
#auth-modal .auth-sheet {
  position: relative; width: 100%; max-width: 480px;
  max-height: 92vh;
  background: #0B1120;
  border: 1px solid rgba(0,191,255,0.15);
  border-radius: 24px 24px 0 0;
  box-shadow: 0 -8px 60px rgba(0,0,0,0.6), 0 -4px 30px rgba(0,191,255,0.06);
  transform: translateY(100%);
  transition: transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden; display: flex; flex-direction: column;
  will-change: transform;
}
#auth-modal.open .auth-sheet { transform: translateY(0); }

/* ── Drag handle ── */
.auth-handle {
  display: flex; justify-content: center; padding: 10px 0 2px;
  flex-shrink: 0; cursor: grab; touch-action: none;
}
.auth-handle:active { cursor: grabbing; }
.auth-handle::after {
  content: ''; width: 40px; height: 4px;
  border-radius: 999px; background: rgba(255,255,255,0.15);
  transition: background 0.2s;
}
.auth-handle:hover::after { background: rgba(255,255,255,0.25); }

/* ── Close button ── */
.auth-close {
  position: absolute; top: 14px; right: 14px;
  width: 32px; height: 32px; border-radius: 50%;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: #8899AA; font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; line-height: 1; flex-shrink: 0;
  z-index: 5;
}
.auth-close:hover {
  background: rgba(255,73,92,0.12);
  border-color: rgba(255,73,92,0.3); color: #FF495C;
}

/* ── Header area ── */
.auth-header {
  text-align: center; padding: 4px 24px 4px; flex-shrink: 0;
}
.auth-favicon {
  width: 48px; height: 48px; margin: 0 auto 8px;
  display: block; border-radius: 12px;
}
.auth-title {
  font-size: 1.3rem; font-weight: 700; color: #F1F5F9;
  letter-spacing: -0.02em; margin-bottom: 4px;
}
.auth-subtitle {
  font-size: 0.85rem; color: #8899AA; margin-bottom: 4px;
}

/* ── Scrollable body ── */
.auth-body {
  padding: 8px 24px 24px;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  flex: 1; position: relative;
}

/* ── Tab switcher ── */
.auth-tabs {
  display: grid; grid-template-columns: 1fr 1fr; gap: 4px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 12px; padding: 4px; margin-bottom: 20px;
}
.auth-tab {
  padding: 10px; border: none; border-radius: 10px;
  background: transparent; font-size: 0.88rem; font-weight: 600;
  color: #8899AA; cursor: pointer; transition: all 0.2s;
}
.auth-tab:hover { color: #B0C4DE; }
.auth-tab.active {
  background: rgba(0,191,255,0.1); color: #00BFFF;
  border: 1px solid rgba(0,191,255,0.25);
  box-shadow: 0 0 16px rgba(0,191,255,0.08);
}

/* ── Auth forms (instant show, smooth entrance via keyframes) ── */
.auth-form, .auth-forgot-section {
  display: none;
}
.auth-form.active, .auth-forgot-section.active {
  display: block;
  animation: ameFormIn 0.35s cubic-bezier(0.16,1,0.3,1) both;
}
@keyframes ameFormIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
.auth-form .form-group { margin-bottom: 16px; }
.auth-form .form-group label {
  display: block; font-size: 0.72rem; font-weight: 700;
  color: #8899AA; text-transform: uppercase;
  letter-spacing: 0.06em; margin-bottom: 6px;
}
.auth-form .input-wrap { position: relative; display: flex; align-items: center; }
.auth-form .input-wrap input {
  width: 100%; padding: 14px 16px;
  background: rgba(0,191,255,0.04);
  border: 1px solid rgba(0,191,255,0.18);
  border-radius: 12px; color: #F1F5F9;
  font-family: inherit; font-size: 0.92rem; font-weight: 500;
  outline: none;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}
.auth-form .input-wrap input:focus {
  border-color: #00BFFF;
  background: rgba(0,191,255,0.07);
  box-shadow: 0 0 0 3px rgba(0,191,255,0.18);
}
.auth-form .input-wrap input.is-invalid {
  border-color: #FF495C;
  box-shadow: 0 0 0 3px rgba(255,73,92,0.1);
}
.auth-form .input-wrap input::placeholder { color: rgba(255,255,255,0.2); }
.auth-form .form-error {
  font-size: 0.75rem; color: #FF495C; margin-top: 5px;
  min-height: 18px; line-height: 1.4;
}
.auth-form .form-success {
  font-size: 0.75rem; color: #39FF14; margin-top: 5px;
  min-height: 18px; line-height: 1.4;
}
/* Forgot section inherits same input styles */
.auth-forgot-section .input-wrap input {
  width: 100%; padding: 14px 16px;
  background: rgba(0,191,255,0.04);
  border: 1px solid rgba(0,191,255,0.18);
  border-radius: 12px; color: #F1F5F9;
  font-family: inherit; font-size: 0.92rem; font-weight: 500;
  outline: none;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}
.auth-forgot-section .input-wrap input:focus {
  border-color: #00BFFF;
  background: rgba(0,191,255,0.07);
  box-shadow: 0 0 0 3px rgba(0,191,255,0.18);
}
.auth-forgot-section .input-wrap input::placeholder { color: rgba(255,255,255,0.2); }

/* ── Password eye toggle ── */
.auth-eye-btn {
  position: absolute; top: 50%; right: 10px;
  transform: translateY(-50%);
  width: 34px; height: 34px;
  border: none; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: rgba(160,174,192,0.5);
  transition: color 0.15s ease;
  border-radius: 6px; padding: 0;
  touch-action: manipulation; z-index: 4;
  -webkit-tap-highlight-color: transparent;
}
.auth-eye-btn:hover { color: rgba(0,191,255,0.8); }
.auth-eye-btn.visible { color: rgba(0,191,255,0.65); }

/* ── Submit button ── */
.auth-submit {
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 14px 24px; border: none; border-radius: 12px;
  background: linear-gradient(135deg,#00BFFF,#0088cc);
  color: #000; font-size: 0.95rem; font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s, box-shadow 0.18s;
  margin-bottom: 20px; letter-spacing: 0.01em;
  position: relative; overflow: hidden; min-height: 48px;
}
.auth-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 28px rgba(0,191,255,0.35);
}
.auth-submit:active { transform: translateY(0); }
.auth-submit:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.auth-submit .btn-text { transition: opacity 0.15s; }
.auth-submit .btn-spinner {
  position: absolute; top: 50%; left: 50%;
  margin: -10px 0 0 -10px; width: 20px; height: 20px;
  border: 2px solid rgba(0,0,0,0.15); border-top-color: #000;
  border-radius: 50%; opacity: 0; transition: opacity 0.15s;
}
.auth-submit.loading .btn-text { opacity: 0; }
.auth-submit.loading .btn-spinner {
  opacity: 1; animation: authSpin 0.6s linear infinite;
}
@keyframes authSpin { to { transform: rotate(360deg); } }

/* ── Back link ── */
.auth-back-link {
  display: inline-flex; align-items: center; gap: 6px;
  color: #00BFFF; font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: color 0.15s; margin-bottom: 16px;
  background: none; border: none; padding: 4px 0;
}
.auth-back-link:hover { color: #B0C4DE; }

/* ── Divider ── */
.divider {
  position: relative; margin: 16px 0; text-align: center;
}
.divider::before {
  content: ''; position: absolute; left: 0; top: 50%;
  width: 100%; height: 1px; background: rgba(255,255,255,0.1);
}
.divider span {
  position: relative; background: #0B1120; padding: 0 12px;
  font-size: 0.75rem; color: #8899AA;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}

/* ── Social auth ── */
.social-auth {
  display: flex; justify-content: center;
  margin-bottom: 16px;
}
.social-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 8px; padding: 12px 24px; border: none; border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  color: #F1F5F9; font-family: inherit; font-size: 0.85rem;
  font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.social-btn:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(0,191,255,0.3); transform: translateY(-1px);
}
.social-btn img { width: 18px; height: 18px; object-fit: contain; }
.social-btn.google-btn:hover { border-color: #4285F4; background: rgba(66,133,244,0.1); }

/* ── Forgot password link ── */
.forgot-password { text-align: center; margin-top: 8px; }
.forgot-password button {
  background: none; border: none; color: #00BFFF;
  font-size: 0.8rem; font-weight: 600;
  cursor: pointer; transition: color 0.15s;
  font-family: inherit;
}
.forgot-password button:hover { color: #B0C4DE; text-decoration: underline; }

/* ── Forgot password full section (isolated) ── */
.auth-forgot-section { display: none; }
.auth-forgot-section.active { display: block; }
.auth-forgot-section .forgot-icon {
  text-align: center; font-size: 2.5rem; margin-bottom: 8px;
  display: flex; justify-content: center; align-items: center;
}
.auth-forgot-section .forgot-icon svg {
  display: block;
}
.auth-forgot-section .forgot-title {
  text-align: center; font-size: 1.1rem; font-weight: 700;
  color: #F1F5F9; margin-bottom: 4px;
}
.auth-forgot-section .forgot-desc {
  text-align: center; font-size: 0.82rem; color: #8899AA;
  margin-bottom: 20px; line-height: 1.5;
}
.auth-forgot-section .auth-submit {
  background: linear-gradient(135deg,#FFB020,#FF8C00);
}
.auth-forgot-section .auth-submit:hover {
  box-shadow: 0 8px 28px rgba(255,176,32,0.35);
}
.forgot-success-msg {
  display: none; text-align: center; padding: 20px 0;
}
.forgot-success-msg.visible { display: block; }
.forgot-success-icon {
  font-size: 3rem; margin-bottom: 12px;
}
.forgot-success-msg h3 {
  color: #39FF14; font-size: 1.1rem; font-weight: 700; margin-bottom: 8px;
}
.forgot-success-msg p {
  color: #8899AA; font-size: 0.85rem; margin-bottom: 16px;
}

/* ── Bottom anchor ── */
.auth-bottom-link {
  text-align: center; padding-top: 12px;
  border-top: 1px solid rgba(255,255,255,0.06); margin-top: 4px;
  transition: opacity 0.25s ease, margin 0.25s ease, padding 0.25s ease, border 0.25s ease;
  opacity: 1; max-height: 60px; overflow: hidden;
}
.auth-bottom-link.ame-hidden {
  opacity: 0; margin: 0; padding-top: 0; border-top: none;
  pointer-events: none;
}
.auth-bottom-link span { font-size: 0.8rem; color: #8899AA; }
.auth-bottom-link button {
  background: none; border: none; color: #00BFFF;
  font-size: 0.8rem; font-weight: 700; cursor: pointer;
  transition: color 0.15s; font-family: inherit;
}
.auth-bottom-link button:hover { color: #B0C4DE; }

/* ── Tabs fade ── */
.auth-tabs {
  transition: opacity 0.25s ease, margin 0.25s ease, padding 0.25s ease, border 0.25s ease;
  opacity: 1; max-height: 80px; overflow: hidden;
}
.auth-tabs.ame-hidden {
  opacity: 0; margin: 0; padding: 0; border: none;
  pointer-events: none;
}

/* ── Responsive ── */
@media(max-width:520px) {
  #auth-modal .auth-sheet {
    max-width: 100%; border-radius: 20px 20px 0 0;
  }
  .auth-body { padding: 8px 20px 20px; }
  .auth-header { padding: 2px 20px 0; }
  .auth-favicon { width: 40px; height: 40px; }
  .auth-title { font-size: 1.15rem; }
  .social-btn { padding: 10px 20px; font-size: 0.8rem; }
}
@media(max-width:380px) {
  .auth-body { padding: 6px 16px 16px; }
  .auth-header { padding: 0 16px; }
  .auth-favicon { width: 36px; height: 36px; }
  .auth-title { font-size: 1.05rem; }
  .social-btn { padding: 8px 16px; font-size: 0.75rem; }
  .social-btn img { width: 16px; height: 16px; }
}

/* ── Desktop: redesigned card with background shapes ── */
@media(min-width:769px) {
  #auth-modal {
    align-items: center; padding: 40px 16px;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  }
  #auth-modal .auth-sheet {
    position: relative; width: 400px;
    background: #0B1120;
    border: 1px solid rgba(0,191,255,0.1);
    border-radius: 0;
    box-shadow: 0 0 40px rgba(0,191,255,0.06), 0 0 80px rgba(0,0,0,0.5);
    overflow: hidden;
    transform: scale(0.95); opacity: 0;
    transition: transform 0.4s cubic-bezier(0.16,1,0.3,1), opacity 0.3s ease;
  }
  #auth-modal.open .auth-sheet {
    transform: scale(1); opacity: 1;
  }
  .auth-handle { display: none !important; }

  /* Close button */
  .auth-close { top: 12px; right: 12px; z-index: 10; width: 28px; height: 28px; }

  /* Header — compact */
  .auth-header { position: relative; z-index: 1; padding: 28px 32px 4px; }
  .auth-favicon { width: 44px; height: 44px; margin-bottom: 6px; }
  .auth-title { font-size: 1.25rem; }
  .auth-subtitle { font-size: 0.78rem; }

  /* Body — compact */
  .auth-body {
    position: relative; z-index: 1;
    padding: 4px 32px 20px;
  }

  /* Tabs */
  .auth-tabs { margin-bottom: 16px; }

  /* Underline-style inputs — same on both forms, compact */
  .auth-form .form-group { margin-bottom: 14px; }
  .auth-form .form-group label {
    font-size: 0.65rem; color: rgba(255,255,255,0.35);
    letter-spacing: 0.1em; margin-bottom: 3px;
  }
  .auth-form .input-wrap input {
    border: none; border-bottom: 2px solid rgba(255,255,255,0.1);
    background: transparent !important;
    padding: 8px 36px 8px 0;
    border-radius: 0;
    font-weight: 600; font-size: 0.85rem;
    transition: border-color 0.2s;
  }
  .auth-form .input-wrap input:focus {
    border-bottom-color: #00BFFF;
    background: transparent !important;
    box-shadow: none;
  }
  .auth-form .input-wrap input::placeholder { color: rgba(255,255,255,0.2); }
  .auth-form .input-wrap input.is-invalid {
    border-bottom-color: #FF495C;
    box-shadow: none;
  }

  /* Eye toggle reposition */
  .auth-eye-btn { right: 0; }

  /* Pill submit button — compact */
  .auth-submit {
    border-radius: 26px;
    padding: 12px 24px;
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 14px; margin-bottom: 12px;
    min-height: 40px;
  }

  /* Divider */
  .divider { margin: 8px 0; }

  /* Forgot section inherits same input styles */
  .auth-forgot-section .input-wrap input {
    border: none; border-bottom: 2px solid rgba(255,255,255,0.1);
    background: transparent !important;
    padding: 8px 0;
    border-radius: 0;
    font-weight: 600; font-size: 0.85rem;
    transition: border-color 0.2s;
  }
  .auth-forgot-section .input-wrap input:focus {
    border-bottom-color: #FFB020;
    background: transparent !important;
    box-shadow: none;
  }
  .auth-forgot-section .input-wrap input::placeholder { color: rgba(255,255,255,0.2); }

  /* Bottom link — compact */
  .auth-bottom-link { padding-top: 6px; margin-top: 0; }

  /* Background shapes */
  .auth-screen-bg {
    display: block; position: absolute; inset: 0;
    z-index: 0; clip-path: inset(0 0 0 0);
    pointer-events: none;
  }
  .auth-shape { transform: rotate(45deg); position: absolute; }

  .auth-shape-1 {
    height: 480px; width: 480px;
    background: rgba(0,191,255,0.025);
    top: -50px; right: 120px;
    border-radius: 0 72px 0 0;
  }
  .auth-shape-2 {
    height: 200px; width: 200px;
    background: rgba(0,191,255,0.04);
    top: -160px; right: 0;
    border-radius: 32px;
  }
  .auth-shape-3 {
    height: 500px; width: 170px;
    background: linear-gradient(270deg, rgba(0,191,255,0.045), rgba(0,136,204,0.02));
    top: -24px; right: 0;
    border-radius: 32px;
  }
  .auth-shape-4 {
    height: 380px; width: 180px;
    background: rgba(0,191,255,0.03);
    top: 380px; right: 50px;
    border-radius: 60px;
  }
}
