/* ===== AUTH MODAL - FIXED VERSION ===== */
/* File: auth-modal-fixed.css */
/* Perbaikan untuk container overflow dan positioning */

.auth-modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  /* CRITICAL FIX: Allow scrolling */
  overflow-y: auto;
  overflow-x: hidden;
  padding: 30px 0;
  /* Smooth scroll */
  -webkit-overflow-scrolling: touch;
}

.auth-modal.show {
  display: flex !important;
  align-items: flex-start;
  justify-content: center;
}

/* ===== CRITICAL FIX: Container dengan min-height dan max-height ===== */
.auth-modal-content {
  position: relative;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  margin: auto;
  padding: 35px 30px;
  border: 2px solid rgba(0, 255, 255, 0.3);
  border-radius: 20px;
  width: 90%;
  max-width: 480px;
  box-shadow: 0 20px 60px rgba(0, 255, 255, 0.25);
  animation: slideDown 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  
  /* CRITICAL FIX: Set min-height dan max-height */
  min-height: auto;
  max-height: calc(100vh - 60px); /* Maksimal tinggi viewport minus padding */
  
  /* CRITICAL FIX: Container dapat scroll jika konten melebihi */
  overflow-y: auto;
  overflow-x: hidden;
  
  /* Add margin for scroll spacing */
  margin-top: 20px;
  margin-bottom: 30px;
  
  /* CRITICAL FIX: Pastikan content tidak overflow */
  box-sizing: border-box;
}

/* Custom Scrollbar untuk container */
.auth-modal-content::-webkit-scrollbar {
  width: 6px;
}

.auth-modal-content::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
}

.auth-modal-content::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, #00ffff, #00ccff);
  border-radius: 10px;
}

.auth-modal-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #00ccff, #00aacc);
}

@keyframes slideDown {
  from {
    transform: translateY(-30px) scale(0.95);
    opacity: 0;
  }
  to {
    transform: translateY(0) scale(1);
    opacity: 1;
  }
}

.auth-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #fff;
  font-size: 20px;
  z-index: 10;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.auth-modal-close:hover {
  background: rgba(255, 71, 87, 0.9);
  transform: rotate(90deg);
  border-color: transparent;
}

.auth-modal-header {
  text-align: center;
  margin-bottom: 25px;
  padding-top: 5px;
}

.auth-modal-header h2 {
  font-size: 26px;
  color: #fff;
  margin-bottom: 8px;
  font-weight: 700;
}

.auth-modal-header p {
  color: #aaa;
  font-size: 13px;
}

/* ===== AUTH TABS ===== */
.auth-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 25px;
  background: rgba(0, 0, 0, 0.3);
  padding: 4px;
  border-radius: 30px;
  flex-shrink: 0; /* Prevent shrinking */
}

.auth-tab {
  flex: 1;
  padding: 10px 18px;
  border: none;
  background: transparent;
  color: #aaa;
  font-weight: 600;
  cursor: pointer;
  border-radius: 25px;
  transition: all 0.3s ease;
  font-size: 14px;
}

.auth-tab.active {
  background: linear-gradient(135deg, #00ffff, #00ccff);
  color: #000;
  box-shadow: 0 4px 15px rgba(0, 255, 255, 0.4);
  transform: scale(1.02);
}

/* ===== AUTH FORMS ===== */
.auth-form {
  display: none;
  /* CRITICAL FIX: Pastikan form tidak overflow */
  max-width: 100%;
  overflow: visible;
}

.auth-form.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.form-group {
  margin-bottom: 16px;
  /* CRITICAL FIX: Prevent overflow */
  overflow: visible;
  position: relative;
}

.form-group label {
  display: block;
  color: #00ffff;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  color: #fff;
  font-size: 14px;
  transition: all 0.3s ease;
  box-sizing: border-box;
  /* CRITICAL FIX: Prevent text overflow */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #00ffff;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 3px rgba(0, 255, 255, 0.1);
  /* CRITICAL FIX: Allow text to be visible when focused */
  white-space: normal;
}

.form-group input::placeholder {
  color: rgba(255, 255, 255, 0.35);
}

/* ===== PASSWORD TOGGLE ===== */
.password-toggle {
  position: relative;
}

.password-toggle-icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(calc(-50% + 11px));
  color: rgba(0, 255, 255, 0.7);
  cursor: pointer;
  font-size: 16px;
  transition: 0.3s;
  padding: 5px;
  z-index: 2; /* Ensure icon is above input */
}

.password-toggle-icon:hover {
  color: #00ffff;
  transform: translateY(calc(-50% + 11px)) scale(1.1);
}

/* ===== FORM OPTIONS ===== */
.form-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 18px;
  font-size: 12px;
  gap: 10px;
  flex-wrap: wrap; /* Allow wrapping on small screens */
}

.remember-me {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #bbb;
  cursor: pointer;
  user-select: none;
}

.remember-me:hover {
  color: #fff;
}

.remember-me input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: #00ffff;
  flex-shrink: 0; /* Prevent shrinking */
}

.forgot-password {
  color: #00ffff;
  text-decoration: none;
  transition: 0.3s;
  font-weight: 500;
  white-space: nowrap; /* Prevent text wrapping */
}

.forgot-password:hover {
  color: #00ccff;
  text-decoration: underline;
}

/* ===== SUBMIT BUTTON ===== */
.auth-submit-btn {
  width: 100%;
  padding: 13px;
  background: linear-gradient(135deg, #00ffff, #00ccff);
  border: none;
  border-radius: 25px;
  color: #000;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 8px;
  flex-shrink: 0; /* Prevent shrinking */
}

.auth-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 255, 255, 0.5);
}

.auth-submit-btn:active {
  transform: translateY(0);
}

/* ===== DIVIDER ===== */
.auth-divider {
  text-align: center;
  margin: 20px 0;
  position: relative;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 38%;
  height: 1px;
  background: rgba(255, 255, 255, 0.15);
}

.auth-divider::before {
  left: 0;
}

.auth-divider::after {
  right: 0;
}

.auth-divider span {
  background: #1a1a2e;
  padding: 0 12px;
  color: #999;
  font-size: 12px;
}

/* ===== SOCIAL LOGIN ===== */
.social-login {
  display: flex;
  gap: 12px;
  flex-shrink: 0; /* Prevent shrinking */
}

.social-btn {
  flex: 1;
  padding: 11px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  background: transparent;
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-size: 13px;
  white-space: nowrap;
  min-height: 44px; /* Ensure minimum touch target size */
}

.social-btn:hover {
  border-color: #00ffff;
  background: rgba(0, 255, 255, 0.08);
  color: #00ffff;
  transform: translateY(-2px);
}

.social-btn i {
  font-size: 16px;
  flex-shrink: 0;
}

/* ===== ERROR & SUCCESS MESSAGES ===== */
.error-message,
.success-message {
  padding: 11px 14px;
  border-radius: 10px;
  margin-bottom: 16px;
  display: none;
  font-size: 13px;
  font-weight: 500;
  animation: slideIn 0.3s ease;
  /* CRITICAL FIX: Ensure messages don't overflow */
  word-wrap: break-word;
  overflow-wrap: break-word;
  max-width: 100%;
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.error-message {
  background: rgba(255, 71, 87, 0.15);
  border: 2px solid rgba(255, 71, 87, 0.4);
  color: #ff6b7a;
}

.success-message {
  background: rgba(46, 213, 115, 0.15);
  border: 2px solid rgba(46, 213, 115, 0.4);
  color: #5efc82;
}

/* ===== RESPONSIVE TABLET ===== */
@media (max-width: 768px) {
  .auth-modal {
    padding: 15px 0;
  }

  .auth-modal-content {
    width: 92%;
    padding: 30px 22px;
    margin-top: 15px;
    margin-bottom: 20px;
    max-height: calc(100vh - 30px);
  }

  .auth-modal-header h2 {
    font-size: 24px;
  }

  .social-login {
    flex-direction: column;
    gap: 10px;
  }

  .form-options {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }
}

/* ===== RESPONSIVE MOBILE ===== */
@media (max-width: 480px) {
  .auth-modal {
    padding: 10px 0;
  }

  .auth-modal-content {
    width: 95%;
    padding: 25px 18px;
    margin-top: 10px;
    margin-bottom: 15px;
    border-radius: 15px;
    max-height: calc(100vh - 20px);
  }

  .auth-modal-header {
    margin-bottom: 20px;
  }

  .auth-modal-header h2 {
    font-size: 22px;
  }

  .form-group {
    margin-bottom: 14px;
  }

  .form-group input,
  .form-group select {
    padding: 10px 12px;
    font-size: 13px;
  }

  .auth-submit-btn {
    padding: 12px;
    font-size: 14px;
  }

  .social-btn {
    padding: 10px;
    font-size: 12px;
  }

  /* CRITICAL FIX: Ensure visibility on small screens */
  .user-info {
    display: none;
  }

  .dropdown-arrow {
    display: none;
  }
}

/* ===== LANDSCAPE MODE UNTUK MOBILE ===== */
@media (max-width: 768px) and (orientation: landscape) {
  .auth-modal {
    padding: 5px 0;
  }

  .auth-modal-content {
    max-height: calc(100vh - 10px);
    margin-top: 5px;
    margin-bottom: 5px;
    padding: 20px 22px;
  }

  .auth-modal-header {
    margin-bottom: 15px;
  }

  .auth-modal-header h2 {
    font-size: 20px;
    margin-bottom: 5px;
  }

  .form-group {
    margin-bottom: 12px;
  }

  .auth-tabs {
    margin-bottom: 15px;
  }

  .auth-divider {
    margin: 15px 0;
  }
}

/* ===== ACCESSIBILITY ===== */
.auth-tab:focus,
.auth-submit-btn:focus,
.social-btn:focus,
.form-group input:focus,
.form-group select:focus {
  outline: 2px solid #00ffff;
  outline-offset: 2px;
}

/* ===== HIGH CONTRAST MODE ===== */
@media (prefers-contrast: high) {
  .auth-modal-content {
    border-width: 3px;
  }

  .form-group input,
  .form-group select {
    border-width: 3px;
  }

  .auth-submit-btn,
  .social-btn {
    border-width: 3px;
  }
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ===== PRINT STYLES ===== */
@media print {
  .auth-modal {
    display: none !important;
  }
}

/* ===== CRITICAL FIX: Prevent Body Scroll when Modal Open ===== */
body.modal-open {
  overflow: hidden;
  height: 100vh;
}

/* ===== Z-INDEX MANAGEMENT ===== */
.auth-modal {
  z-index: 1000;
}

.auth-modal-close {
  z-index: 1001;
}

.password-toggle-icon {
  z-index: 1002;
}

/* ===== SAFARI FIX ===== */
@supports (-webkit-appearance: none) {
  .auth-modal-content {
    -webkit-overflow-scrolling: touch;
  }
}

/* ===== FIREFOX FIX ===== */
@-moz-document url-prefix() {
  .auth-modal-content {
    scrollbar-width: thin;
    scrollbar-color: #00ffff rgba(255, 255, 255, 0.05);
  }
}