/* ==========================================================================
   ViewMix AR Studio — Gatekeeper & Access Control CSS
   ========================================================================== */

/* Hide everything when unauthenticated */
html:not(.studio-auth-ok) body > *:not(#viewmix-auth-gate):not(#auth-change-password-modal) {
  display: none !important;
}

html:not(.studio-auth-ok) body {
  background: #0b0f17 !important;
  overflow: hidden !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 100vh !important;
}

/* Auth Gate Fullscreen Overlay */
#viewmix-auth-gate {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 35%, rgba(212, 175, 55, 0.1) 0%, rgba(15, 20, 28, 0.98) 60%, #070a0f 100%);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  padding: 20px;
  box-sizing: border-box;
  opacity: 1;
  transition: opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  direction: rtl;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#viewmix-auth-gate.gate-closing {
  opacity: 0;
  transform: scale(1.04);
  pointer-events: none;
}

/* Card Container */
.auth-gate-card {
  background: rgba(18, 24, 38, 0.92);
  border: 1px solid rgba(212, 175, 55, 0.38);
  border-radius: 24px;
  max-width: 440px;
  width: 100%;
  padding: 40px 32px;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.8), 0 0 40px rgba(212, 175, 55, 0.12);
  text-align: center;
  position: relative;
  animation: auth-card-pop 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes auth-card-pop {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(18px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Glowing Top Badge */
.auth-gate-badge {
  width: 72px;
  height: 72px;
  margin: 0 auto 20px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(212, 175, 55, 0.25) 0%, rgba(212, 175, 55, 0.06) 100%);
  border: 1.5px solid rgba(212, 175, 55, 0.5);
  box-shadow: 0 0 28px rgba(212, 175, 55, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  position: relative;
  animation: badge-glow-pulse 3s infinite alternate ease-in-out;
}

@keyframes badge-glow-pulse {
  from {
    box-shadow: 0 0 20px rgba(212, 175, 55, 0.25);
    border-color: rgba(212, 175, 55, 0.4);
  }
  to {
    box-shadow: 0 0 35px rgba(212, 175, 55, 0.55);
    border-color: rgba(212, 175, 55, 0.8);
  }
}

.auth-gate-title {
  font-size: 23px;
  font-weight: 800;
  margin: 0 0 6px;
  background: linear-gradient(135deg, #ffffff 40%, #e2c262 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.3px;
}

.auth-gate-subtitle {
  font-size: 13px;
  color: #94a3b8;
  margin: 0 0 24px;
  line-height: 1.5;
}

/* Input Wrapper */
.auth-input-group {
  position: relative;
  margin-bottom: 14px;
  width: 100%;
}

.auth-passcode-input {
  width: 100%;
  padding: 15px 46px 15px 16px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.55);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 17px;
  box-sizing: border-box;
  direction: ltr;
  text-align: center;
  letter-spacing: 2px;
  transition: all 0.2s ease;
}

.auth-passcode-input:focus {
  border-color: #d4af37;
  outline: none;
  background: rgba(0, 0, 0, 0.7);
  box-shadow: 0 0 16px rgba(212, 175, 55, 0.35);
}

.auth-passcode-input::placeholder {
  color: #64748b;
  letter-spacing: normal;
  font-size: 14px;
}

.auth-toggle-pwd-btn {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 17px;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s;
}

.auth-toggle-pwd-btn:hover {
  color: #ffffff;
}

/* Remember me & Options */
.auth-gate-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  font-size: 13px;
  color: #cbd5e1;
  padding: 0 4px;
}

.auth-remember-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
}

.auth-remember-label input[type="checkbox"] {
  accent-color: #d4af37;
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Error Banner */
.auth-error-banner {
  display: none;
  background: rgba(239, 68, 68, 0.14);
  border: 1px solid rgba(239, 68, 68, 0.4);
  color: #fca5a5;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.4;
  text-align: center;
}

.auth-error-banner.show {
  display: block;
  animation: auth-shake 0.4s ease;
}

@keyframes auth-shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* Submit Button */
.auth-submit-btn {
  width: 100%;
  padding: 14px 20px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #d4af37 0%, #b89728 100%);
  color: #0b0f17;
  font-weight: 800;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(212, 175, 55, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.auth-submit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(212, 175, 55, 0.55);
  filter: brightness(1.06);
}

.auth-submit-btn:active {
  transform: translateY(0);
}

.auth-gate-footer {
  margin-top: 22px;
  font-size: 11px;
  color: #64748b;
}

/* ==========================================================================
   Header Lock & Security Menu
   ========================================================================== */
.btn-auth-lock-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border-radius: 9999px;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.3);
  color: #e2c262;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-auth-lock-pill:hover {
  background: rgba(212, 175, 55, 0.18);
  border-color: rgba(212, 175, 55, 0.55);
  color: #ffffff;
}

/* Security Dropdown Menu */
.auth-security-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  background: #141b27;
  border: 1px solid rgba(212, 175, 55, 0.35);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
  border-radius: 12px;
  padding: 6px;
  min-width: 180px;
  z-index: 1000;
  display: none;
  animation: auth-card-pop 0.2s ease;
  direction: rtl;
}

.auth-security-menu.open {
  display: block;
}

.auth-menu-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  color: #cbd5e1;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-align: right;
  transition: background 0.15s, color 0.15s;
}

.auth-menu-item:hover {
  background: rgba(212, 175, 55, 0.14);
  color: #ffffff;
}

.auth-menu-item.danger {
  color: #fca5a5;
}

.auth-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.16);
  color: #ffffff;
}

/* ==========================================================================
   Change Passcode Modal
   ========================================================================== */
#auth-change-password-modal {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 9999999;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(12px);
  padding: 20px;
  box-sizing: border-box;
  direction: rtl;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

#auth-change-password-modal.open {
  display: flex;
}

.auth-change-card {
  background: #121826;
  border: 1px solid rgba(212, 175, 55, 0.35);
  border-radius: 20px;
  max-width: 440px;
  width: 100%;
  padding: 32px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
  position: relative;
  animation: auth-card-pop 0.25s ease;
}

.auth-change-title {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-change-desc {
  font-size: 13px;
  color: #94a3b8;
  margin: 0 0 20px;
}

.auth-field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #cbd5e1;
  margin-bottom: 6px;
  text-align: right;
}

.auth-modal-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-size: 15px;
  margin-bottom: 14px;
  box-sizing: border-box;
  direction: ltr;
}

.auth-modal-input:focus {
  border-color: #d4af37;
  outline: none;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
}

.auth-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn-auth-cancel {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.05);
  color: #cbd5e1;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-auth-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.btn-auth-save {
  flex: 2;
  padding: 12px;
  border-radius: 10px;
  border: none;
  background: linear-gradient(135deg, #d4af37 0%, #b89728 100%);
  color: #0b0f17;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 4px 14px rgba(212, 175, 55, 0.3);
}

.btn-auth-save:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 18px rgba(212, 175, 55, 0.45);
}
