/* Mini Account Button Module Styles */

/* Wrapper and Button */
.mab-wrapper {
  position: relative;
  display: inline-block;
}

.mab-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background-color: transparent;
  color: #333;
  border: none;
  border-radius: 0;
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  box-sizing: border-box;
  min-width: 40px;
  min-height: 40px;
}

.mab-button:hover {
  background-color: rgba(0, 0, 0, 0.05);
  transform: none;
  box-shadow: none;
}

.mab-button:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
  border-radius: 4px;
}

.mab-button:active {
  transform: none;
  box-shadow: none;
  background-color: rgba(0, 0, 0, 0.1);
}

.mab-account-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mab-account-svg {
  width: 24px;
  height: 24px;
  color: inherit;
}

/* Popout Panel - Dropdown Card Style */
.mab-popout {
  position: absolute;
  top: 100%;
  z-index: 9999;
  display: none;
  opacity: 0;
  transform: translateY(-10px);
  transition: all 0.3s ease;
}

.mab-popout.mab-active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

.mab-popout-overlay {
  display: none;
}

.mab-popout-panel {
  position: relative;
  background-color: #ffffff;
  color: #333333;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  width: 300px;
  max-height: 400px;
}

.mab-popout.mab-position-left {
  right: 0;
}

.mab-popout.mab-position-right {
  left: 0;
}

/* Arrow pointing to button */
.mab-popout-panel::before {
  content: "";
  position: absolute;
  top: -8px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #e0e0e0;
}

.mab-popout-panel::after {
  content: "";
  position: absolute;
  top: -7px;
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid #ffffff;
}

.mab-popout-panel.mab-position-left::before,
.mab-popout-panel.mab-position-left::after {
  right: 20px;
}

.mab-popout-panel.mab-position-right::before,
.mab-popout-panel.mab-position-right::after {
  left: 20px;
}

/* Header */
.mab-popout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid #eee;
  background-color: #f8f9fa;
}

.mab-popout-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: inherit;
}

.mab-close-button {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.mab-close-button:hover {
  background-color: #e9ecef;
  color: #333;
}

.mab-close-button:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(52, 152, 219, 0.3);
}

/* Content */
.mab-popout-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.mab-account-menu {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

/* Menu Items */
.mab-menu-items {
  padding: 0;
  margin: 0;
}

.mab-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid #eee;
  transition: all 0.2s ease;
  text-decoration: none;
  color: #333333;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.4;
}

.mab-menu-item:hover {
  background-color: #f8f9fa;
  color: #2c3e50;
  text-decoration: none;
}

.mab-menu-item:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(52, 152, 219, 0.3);
}

.mab-item-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
}

.mab-item-icon svg {
  width: 16px;
  height: 16px;
  color: #666666;
}

.mab-item-text {
  flex: 1;
}

.mab-logout-item {
  border-bottom: none;
}

/* Login Section (for logged out users) */
.mab-login-section {
  padding: 20px;
}

.mab-login-form {
  margin-bottom: 16px;
  text-align: center;
}

.mab-login-form p {
  margin: 0;
  color: #666;
  font-style: italic;
  font-size: 14px;
}

.mab-auth-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.mab-login-btn,
.mab-register-btn {
  display: block;
  padding: 12px 16px;
  text-align: center;
  text-decoration: none;
  border-radius: 4px;
  font-weight: 500;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
}

.mab-login-btn {
  background-color: #007cba;
  color: #ffffff;
}

.mab-login-btn:hover {
  background-color: #005a87;
  text-decoration: none;
  color: #ffffff;
}

.mab-register-btn {
  background-color: #50575e;
  color: #ffffff;
}

.mab-register-btn:hover {
  background-color: #3c434a;
  text-decoration: none;
  color: #ffffff;
}

.mab-login-btn:focus,
.mab-register-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.25);
}

/* Messages */
.mab-message {
  padding: 12px 20px;
  margin-bottom: 16px;
  border-radius: 4px;
  font-size: 14px;
  animation: mab-slide-down 0.3s ease;
}

.mab-message-success {
  background-color: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.mab-message-error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

@keyframes mab-slide-down {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Animation for menu updates */
.mab-account-menu.mab-updated {
  animation: mab-fade-in 0.3s ease;
}

@keyframes mab-fade-in {
  from {
    opacity: 0.7;
  }
  to {
    opacity: 1;
  }
}

/* Body scroll prevention */
body.mab-no-scroll {
  overflow: hidden;
  position: fixed;
  width: 100%;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  .mab-popout {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    margin-top: 0 !important;
    background-color: rgba(0, 0, 0, 0.5) !important;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 9999999 !important;
    box-sizing: border-box;
  }

  .mab-popout.mab-active {
    display: flex !important;
  }

  .mab-popout-panel {
    width: 100%;
    max-width: 400px;
    max-height: calc(100vh - 40px);
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s ease;
    margin: auto;
    overflow: hidden;
  }

  .mab-popout.mab-active .mab-popout-panel {
    transform: scale(1);
  }

  .mab-popout-panel::before,
  .mab-popout-panel::after {
    display: none;
  }

  .mab-auth-buttons {
    flex-direction: column;
  }

  .mab-menu-item {
    padding: 12px 16px;
  }

  .mab-popout-header {
    padding: 16px;
  }

  .mab-login-section {
    padding: 16px;
  }

  /* Ensure menu area is scrollable on mobile */
  .mab-account-menu {
    max-height: calc(100vh - 200px);
    overflow-y: auto;
  }
}

@media (max-width: 480px) {
  .mab-button {
    padding: 8px 12px;
    font-size: 13px;
  }

  .mab-menu-item {
    font-size: 13px;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .mab-button {
    border: 2px solid currentColor;
  }

  .mab-popout-panel {
    border: 2px solid #333;
  }

  .mab-menu-item {
    border-bottom: 2px solid #333;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .mab-button,
  .mab-popout,
  .mab-popout-panel,
  .mab-menu-item,
  .mab-close-button,
  .mab-login-btn,
  .mab-register-btn {
    transition: none;
  }

  .mab-message {
    animation: none;
  }

  .mab-account-menu.mab-updated {
    animation: none;
  }
}

/* Focus visible support for better accessibility */
.mab-button:focus-visible,
.mab-close-button:focus-visible,
.mab-menu-item:focus-visible,
.mab-login-btn:focus-visible,
.mab-register-btn:focus-visible {
  outline: 2px solid #0066cc;
  outline-offset: 2px;
}

/* Print styles */
@media print {
  .mab-wrapper {
    display: none;
  }
}

/* Theme compatibility - defensive CSS */
.mab-wrapper,
.mab-wrapper * {
  box-sizing: border-box;
}

.mab-wrapper button,
.mab-wrapper a {
  font-family: inherit;
}

.mab-popout-panel h3 {
  font-family: inherit;
  line-height: inherit;
  text-transform: none;
  letter-spacing: normal;
}

.mab-menu-item,
.mab-login-btn,
.mab-register-btn {
  color: inherit;
}

.mab-menu-item:visited {
  color: inherit;
}

/* Override common theme conflicts */
.mab-popout-panel .mab-menu-item {
  list-style: none;
  margin: 0;
  padding-left: 20px;
  padding-right: 20px;
}

.mab-popout-panel .mab-menu-item::before {
  display: none;
}

/* Ensure proper stacking */
.mab-popout {
  z-index: 999999;
}

/* Loading states */
.mab-account-menu.mab-loading {
  opacity: 0.7;
  pointer-events: none;
}

.mab-account-menu.mab-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid #3498db;
  border-radius: 50%;
  animation: mab-spin 1s linear infinite;
}

@keyframes mab-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
