/**
 * TourSure User Account - Registration & Login System
 * Version: 1.0.0
 * Design: Modern, Clean, Professional with Purple Theme
 * Colors: Purple (#4c1d95), Gold (#d9b35c), White/Gradients
 */

/* ============================================
   USER ACCOUNT WRAPPER
   ============================================ */
.toursure-user-account-wrapper {
  position: relative;
  display: inline-block;
}

/* ============================================
   USER ICON
   ============================================ */
.toursure-user-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #4c1d95 0%, #581c87 50%, #6b21a8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(76, 29, 149, 0.2);
  border: 2px solid transparent;
  overflow: hidden;
}

.toursure-user-icon:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(76, 29, 149, 0.3);
  border-color: #d9b35c;
}

.toursure-user-icon svg {
  color: #ffffff;
  width: 22px;
  height: 22px;
}

/* Image */
#toursure-user-icon img {
  height: 35px;
  width: 35px;
  border-radius: 50% !important;
  object-fit: cover;
  display: block;
}

.toursure-user-avatar-icon {
  width: 35px;
  height: 35px;
  border-radius: 50% !important;
  object-fit: cover;
  display: block;
}

/* ============================================
   TOOLTIP POPUP
   ============================================ */
.toursure-user-tooltip {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 300px;
  max-height: 520px;
  background: #ffffff;
  border-radius: 12px;
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.12),
    0 2px 8px rgba(76, 29, 149, 0.08),
    0 0 0 1px rgba(0, 0, 0, 0.04);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 9999;
  overflow-y: auto;
  overflow-x: hidden;
}

.toursure-user-tooltip.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Triangle arrow */
.toursure-user-tooltip::before {
  content: '';
  position: absolute;
  top: -5px;
  right: 14px;
  width: 10px;
  height: 10px;
  background: #ffffff;
  transform: rotate(45deg);
  border-top: 1px solid rgba(0, 0, 0, 0.04);
  border-left: 1px solid rgba(0, 0, 0, 0.04);
  z-index: 10;
}

/* ============================================
   TOOLTIP POSITIONING VARIANTS
   ============================================ */
/* Position: Top (opens above the icon) */
.toursure-user-tooltip.position-top {
  top: auto;
  bottom: calc(100% + 10px);
  transform: translateY(10px);
}

.toursure-user-tooltip.position-top.active {
  transform: translateY(0);
}

.toursure-user-tooltip.position-top::before {
  top: auto;
  bottom: -5px;
  transform: rotate(225deg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  border-right: 1px solid rgba(0, 0, 0, 0.04);
  border-top: none;
  border-left: none;
}

/* Position: Left (aligned to left edge) */
.toursure-user-tooltip.position-left {
  right: auto;
  left: 0;
}

.toursure-user-tooltip.position-left::before {
  right: auto;
  left: 14px;
}

/* Position: Center (horizontally centered) */
.toursure-user-tooltip.position-center {
  left: 50%;
  right: auto;
  transform: translateX(-50%) translateY(-10px);
}

.toursure-user-tooltip.position-center.active {
  transform: translateX(-50%) translateY(0);
}

.toursure-user-tooltip.position-center::before {
  left: 50%;
  right: auto;
  transform: translateX(-50%) rotate(45deg);
}

/* Combined: Center + Top */
.toursure-user-tooltip.position-center.position-top {
  transform: translateX(-50%) translateY(10px);
}

.toursure-user-tooltip.position-center.position-top.active {
  transform: translateX(-50%) translateY(0);
}

.toursure-user-tooltip.position-center.position-top::before {
  bottom: -5px;
  top: auto;
  transform: translateX(-50%) rotate(225deg);
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  border-right: 1px solid rgba(0, 0, 0, 0.04);
  border-top: none;
  border-left: none;
}

/* Combined: Left + Top */
.toursure-user-tooltip.position-left.position-top::before {
  left: 14px;
  right: auto;
}

/* Constrain horizontal overflow */
.toursure-user-tooltip.constrain-horizontal {
  max-width: calc(100vw - 32px);
  left: 16px;
  right: 16px;
}

.toursure-user-tooltip.constrain-horizontal::before {
  right: 14px;
  left: auto;
}

/* ============================================
   LOGGED IN VIEW
   ============================================ */
.toursure-user-logged-in {
  padding: 16px;
}

.toursure-user-avatar {
  text-align: center;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Image */
#toursure-user-tooltip .toursure-user-avatar img {
  border-radius: 50% !important;
  border: 2px solid #4c1d95;
  box-shadow: 0 2px 8px rgba(76, 29, 149, 0.2);
  object-fit: cover;
  display: block;
  margin: 0 auto;
}

.toursure-user-avatar-img {
  border-radius: 50% !important;
  border: 2px solid #4c1d95;
  box-shadow: 0 2px 8px rgba(76, 29, 149, 0.2);
  object-fit: cover;
  display: block;
  margin: 0 auto;
}

.toursure-user-info {
  text-align: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e5e7eb;
}

.toursure-user-info h4 {
  margin: 0 0 6px 0;
  font-size: 15px;
  font-weight: 700;
  color: #1f2937;
  line-height: 1.2;
  word-wrap: break-word;
}

.toursure-user-email {
  margin: 0;
  font-size: 11px;
  color: #6b7280;
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.toursure-user-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toursure-btn-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  color: #1f2937;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s ease;
  cursor: pointer;
  width: 100%;
}

.toursure-btn-action:hover {
  background: #f3f4f6;
  border-color: #4c1d95;
  color: #4c1d95;
  transform: translateX(4px);
}

.toursure-btn-action svg {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: #6b7280;
  transition: color 0.2s ease;
}

.toursure-btn-action:hover svg {
  color: #4c1d95;
}

.toursure-btn-logout {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}

.toursure-btn-logout:hover {
  background: #fee2e2;
  border-color: #f87171;
  color: #7f1d1d;
}

.toursure-btn-logout svg {
  color: #991b1b;
}

/* ============================================
   NOT LOGGED IN VIEW
   ============================================ */
.toursure-user-not-logged-in {
  padding: 16px;
}

.toursure-user-not-logged-in h3 {
  margin: 0 0 12px 0;
  font-size: 16px;
  font-weight: 700;
  color: #1f2937;
  text-align: center;
}

/* ============================================
   AUTH BUTTONS
   ============================================ */
.toursure-auth-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toursure-btn-primary,
.toursure-btn-secondary {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
}

.toursure-btn-primary {
  background: linear-gradient(135deg, #4c1d95 0%, #581c87 50%, #6b21a8 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(76, 29, 149, 0.3);
}

.toursure-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(76, 29, 149, 0.4);
}

.toursure-btn-secondary {
  background: #ffffff;
  color: #4c1d95;
  border: 2px solid #4c1d95;
}

.toursure-btn-secondary:hover {
  background: #f9fafb;
  transform: translateY(-2px);
}

/* ============================================
   FORMS
   ============================================ */
.toursure-form {
  display: none;
}

.toursure-form h4 {
  margin: 0 0 12px 0;
  font-size: 15px;
  font-weight: 700;
  color: #1f2937;
  text-align: center;
}

.toursure-form-group {
  margin-bottom: 10px;
}

.toursure-form-group label {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}

.toursure-form-group .required {
  color: #dc2626;
}

.toursure-form-group input[type="text"],
.toursure-form-group input[type="email"],
.toursure-form-group input[type="tel"],
.toursure-form-group input[type="password"] {
  width: 100%;
  padding: 8px 12px;
  border: 2px solid #e5e7eb;
  border-radius: 8px;
  font-size: 13px;
  color: #1f2937;
  background: #f9fafb;
  transition: all 0.2s ease;
  box-sizing: border-box;
}

.toursure-form-group input:focus {
  outline: none;
  border-color: #4c1d95;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(76, 29, 149, 0.1);
}

.toursure-field-hint {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: #6b7280;
  line-height: 1.3;
}

/* Email group with OTP button */
.toursure-email-group {
  display: flex;
  gap: 6px;
}

.toursure-email-group input {
  flex: 1;
}

.toursure-btn-otp {
  padding: 8px 14px;
  background: #4c1d95;
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.toursure-btn-otp:hover {
  background: #581c87;
}

.toursure-btn-otp:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* OTP Input verified state */
#signup_otp.verified {
  border-color: #10b981;
  background: #d1fae5;
}

/* ============================================
   FORM ACTIONS
   ============================================ */
.toursure-form-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.toursure-btn-submit {
  padding: 10px 18px;
  background: linear-gradient(135deg, #4c1d95 0%, #581c87 50%, #6b21a8 100%);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(76, 29, 149, 0.3);
}

.toursure-btn-submit:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(76, 29, 149, 0.4);
}

.toursure-btn-submit:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.toursure-btn-back {
  padding: 8px 16px;
  background: #f3f4f6;
  color: #6b7280;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toursure-btn-back:hover {
  background: #e5e7eb;
  color: #374151;
}

/* ============================================
   FORM MESSAGE
   ============================================ */
.toursure-form-message {
  display: none;
  margin-top: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12px;
  line-height: 1.4;
  animation: messageSlideIn 0.3s ease-out;
}

@keyframes messageSlideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toursure-form-message.error {
  background: #fee2e2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.toursure-form-message.success {
  background: #d1fae5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
/* 481px and larger screen sizes */
@media (min-width: 481px) {

  /* Image */
  #toursure-user-tooltip .toursure-user-avatar img {
    height: 60px;
    width: 60px;
  }
}

@media (max-width: 480px) {
  .toursure-user-tooltip {
    /* Right-align to prevent overflow on mobile */
    right: 0 !important;
    left: auto !important;
    transform: translateY(-10px) !important;
    min-width: 280px;
    max-width: calc(100vw - 32px) !important;
    max-height: 480px;
    margin: 0 16px;
  }

  .toursure-user-tooltip.active {
    transform: translateY(0) !important;
  }

  .toursure-user-tooltip::before {
    right: 14px !important;
    left: auto !important;
    transform: rotate(45deg) !important;
  }

  /* Mobile + Top positioning */
  .toursure-user-tooltip.position-top {
    top: auto !important;
    bottom: calc(100% + 10px) !important;
    transform: translateY(10px) !important;
  }

  .toursure-user-tooltip.position-top.active {
    transform: translateY(0) !important;
  }

  .toursure-user-tooltip.position-top::before {
    top: auto !important;
    bottom: -5px !important;
    right: 14px !important;
    left: auto !important;
    transform: rotate(225deg) !important;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    border-right: 1px solid rgba(0, 0, 0, 0.04);
    border-top: none;
    border-left: none;
  }

  .toursure-user-logged-in,
  .toursure-user-not-logged-in {
    padding: 14px;
  }

  .toursure-email-group {
    flex-direction: column;
  }

  .toursure-btn-otp {
    width: 100%;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */
.toursure-user-icon:focus-visible,
.toursure-btn-action:focus-visible,
.toursure-btn-primary:focus-visible,
.toursure-btn-secondary:focus-visible,
.toursure-btn-submit:focus-visible,
.toursure-btn-back:focus-visible,
.toursure-btn-otp:focus-visible,
.toursure-forgot-link:focus-visible,
.toursure-reset-modal-close:focus-visible {
  outline: 3px solid #4c1d95;
  outline-offset: 2px;
}

.toursure-form-group input:focus-visible {
  outline: 3px solid #4c1d95;
  outline-offset: 2px;
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {

  .toursure-user-icon,
  .toursure-btn-action,
  .toursure-btn-primary,
  .toursure-btn-secondary,
  .toursure-form-group input {
    border-width: 3px;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {

  .toursure-user-icon,
  .toursure-user-tooltip,
  .toursure-btn-action,
  .toursure-btn-primary,
  .toursure-btn-secondary,
  .toursure-btn-submit,
  .toursure-form-group input,
  .toursure-form-message,
  .toursure-reset-modal,
  .toursure-reset-modal-dialog {
    animation: none !important;
    transition: none !important;
  }
}

/* Print Styles */
@media print {
  .toursure-user-account-wrapper {
    display: none !important;
  }
}

/* ============================================
   DARK MODE SUPPORT (Optional)
   ============================================ */
@media (prefers-color-scheme: dark) {
  .toursure-user-tooltip {
    background: #1f2937;
    box-shadow:
      0 8px 32px rgba(0, 0, 0, 0.5),
      0 2px 8px rgba(76, 29, 149, 0.3);
  }

  .toursure-user-tooltip::before {
    background: #1f2937;
  }

  .toursure-user-not-logged-in h3,
  .toursure-form h4,
  .toursure-user-info h4 {
    color: #f9fafb;
  }

  .toursure-user-email,
  .toursure-form-group label {
    color: #d1d5db;
  }

  .toursure-btn-action {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }

  .toursure-btn-action:hover {
    background: #4b5563;
  }

  .toursure-form-group input {
    background: #374151;
    border-color: #4b5563;
    color: #f9fafb;
  }

  .toursure-field-hint {
    color: #9ca3af;
  }

  .toursure-reset-modal-dialog {
    background: #1f2937;
  }

  .toursure-reset-modal-header h3,
  .toursure-reset-success h4 {
    color: #f9fafb;
  }

  .toursure-reset-modal-header p,
  .toursure-reset-success-text {
    color: #d1d5db;
  }
}

/* ============================================
   FORGOT PASSWORD LINK
   ============================================ */
.toursure-form-row {
  display: flex;
  margin: -2px 0 12px;
}

.toursure-form-row-end {
  justify-content: flex-end;
}

.toursure-forgot-link {
  background: transparent;
  border: none;
  padding: 4px 2px;
  font-size: 13px;
  font-weight: 600;
  color: #4c1d95;
  cursor: pointer;
  transition: color 0.2s ease;
  text-decoration: none;
}

.toursure-forgot-link:hover {
  color: #6b21a8;
  text-decoration: underline;
}

/* ============================================
   RESET PASSWORD MODAL
   ============================================ */
.toursure-reset-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}

.toursure-reset-modal.is-open {
  opacity: 1;
  visibility: visible;
}

.toursure-reset-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.toursure-reset-modal-dialog {
  position: relative;
  width: 100%;
  max-width: 440px;
  background: #ffffff;
  border-radius: 20px;
  padding: 32px 28px 28px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.25),
    0 8px 24px rgba(76, 29, 149, 0.18);
  transform: scale(0.94) translateY(8px);
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.25s ease;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}

.toursure-reset-modal.is-open .toursure-reset-modal-dialog {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.toursure-reset-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f3f4f6;
  border: none;
  border-radius: 50%;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.2s ease;
}

.toursure-reset-modal-close:hover {
  background: #4c1d95;
  color: #ffffff;
  transform: rotate(90deg);
}

.toursure-reset-modal-header {
  text-align: center;
  margin-bottom: 24px;
}

.toursure-reset-icon-circle {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #4c1d95 0%, #581c87 50%, #6b21a8 100%);
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(76, 29, 149, 0.35);
}

.toursure-reset-modal-header h3 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 800;
  color: #111827;
  letter-spacing: -0.3px;
}

.toursure-reset-modal-header p {
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
  color: #6b7280;
}

.toursure-reset-form .toursure-form-group {
  margin-bottom: 16px;
}

.toursure-reset-actions {
  margin-top: 4px;
}

.toursure-btn-reset-submit {
  width: 100%;
}

/* Success State */
.toursure-reset-success {
  text-align: center;
  padding: 8px 0 4px;
}

.toursure-reset-success-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #ffffff;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.35);
  animation: toursure-success-pop 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes toursure-success-pop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.1); opacity: 1; }
  100% { transform: scale(1); }
}

.toursure-reset-success h4 {
  margin: 0 0 12px;
  font-size: 20px;
  font-weight: 800;
  color: #111827;
}

.toursure-reset-success-text {
  margin: 0 0 8px;
  font-size: 14px;
  line-height: 1.6;
  color: #4b5563;
}

.toursure-reset-success-hint {
  margin: 0 0 20px;
  font-size: 12px;
  color: #9ca3af;
  font-style: italic;
}

.toursure-reset-close-btn {
  width: 100%;
}

/* Modal: Mobile Full-screen */
@media (max-width: 768px) {
  .toursure-reset-modal {
    padding: 0;
  }

  .toursure-reset-modal-dialog {
    max-width: 100%;
    width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    padding: 56px 24px 32px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
  }

  .toursure-reset-modal.is-open .toursure-reset-modal-dialog {
    transform: none;
  }

  .toursure-reset-modal-dialog {
    transform: translateY(20px);
  }

  .toursure-reset-modal-header {
    margin-top: 24px;
  }

  .toursure-reset-icon-circle {
    width: 80px;
    height: 80px;
  }

  .toursure-reset-modal-header h3 {
    font-size: 26px;
  }
}
