/**
 * Modal Styles
 * Styling for modal components across the application
 */


/* Modal backdrop */
.modal-backdrop {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: var(--overlay-dark);
  z-index: 1040;
  opacity: 1; /* Set to 1 by default to ensure visibility */
  transition: opacity 0.3s ease;
}

.modal-backdrop-open {
  opacity: 1;
}

/* Base modal */
.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background-color: var(--brand-surface); /* Use surface for modal bg */
  border-radius: 8px;
  box-shadow: 0 10px 25px var(--overlay-dark);
  z-index: 1050;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
  max-width: 95%;
  max-height: 95vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 1rem;
  text-align: center;
  box-sizing: border-box;
}

.lobby-settings-section {
  margin-top: 1rem;
  padding-top: 0.1rem;
  padding-bottom: 0.8rem;
  border-top: 1px solid var(--color-border);
  background-color: #7890a624;
}

.modal-open {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
  line-height: 2;
}

/* Modal sizes */
.modal-small {
  width: 300px;
}

.modal-medium {
  width: 500px;
}

.modal-large {
  width: 800px;
}

.modal-fullscreen {
  width: 95vw;
  height: 95vh;
}

/* Modal content structure */
.modal-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border-strong);
}

.modal-title {
  margin: 0;
  font-size: 2rem;
  font-weight: 600;
  padding: 1rem;
  text-align: center;
}

.modal-title-small {
  font-size: 1.1rem;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  padding: 0;
  margin-left: 1rem;
}

.modal-close:hover {
  opacity: 1;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem;
  box-sizing: border-box;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  padding: 1rem;
  border-top: 1px solid var(--border-strong);
  gap: 0.5rem;
}

/* Create a right-aligned group for the other buttons */
.modal-footer .btn-group-right {
  display: flex;
  gap: 0.5rem;
  margin-left: auto; /* Ensures the group is pushed to the right */
}

/* Delete/Danger button positioning */
.modal-footer [data-action="deleteGuestAccount"] {
  margin-right: auto; /* Pushes it to the left */
}

/* Form elements in modals */
.modal .form-group {
  margin-bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 1.8rem;
}
.btn-edit-name {
  background: transparent;
  border: none;
  cursor: pointer;
  /* font-size: 1.5rem; Removed */
  /* color: var(--text-primary); Removed */
  /* transition: color 0.2s ease; Removed */
  margin-left: 1em; /* Keep spacing */
  position: absolute; /* Position relative to parent */
  left: 100%; /* Position to the right edge of the parent */
  top: 50%; /* Center vertically */
  transform: translateY(-50%); /* Adjust vertical centering */
  padding: 0; /* Remove default button padding */
  line-height: 0; /* Prevent extra space */
}

.btn-edit-name img {
  width: 2em; /* Adjust size as needed */
  height: 2em; /* Adjust size as needed */
  vertical-align: middle; /* Align image nicely */
  transition: filter 0.2s ease;
}

.btn-edit-name:hover img {
  filter: brightness(1.3); /* Add hover effect */
}

/* Center the name and keep the button to the right */
.guest-name-display-container {
  /* display: flex; justify-content: center; Replaced with text-align */
  text-align: center; /* Center inline-block children */
  width: 100%;
  margin-bottom: 0.5rem; /* Add some space below */
}

.guest-name-display {
  /* display: inline-flex; align-items: center; Replaced */
  display: inline-block; /* Allow centering via text-align */
  position: relative; /* Positioning context for the button */
}

#guest-name-display {
  text-align: center;
  font-size: 2.2rem;
  min-width: 4em;
}

.modal .form-control {
  width: 80%;
  padding: 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  background-color: var(--brand-surface-alt);
  transition: border-color 0.2s;
  color: var(--text-primary);
  text-align: center;
  font-size: 1em;
  margin: 0.5rem 0;
}

.modal .form-control:focus {
  border-color: var(--brand-blue);
  outline: none;
  color: var(--text-primary);
}

.modal .form-text {
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  display: block;
  width: 100%;
  text-align: center;
}

.modal .form-error {
  color: var(--accent-danger);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

/* Avatar grid in guest modal */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-top: 0.5rem;
  width: 100%;
  box-sizing: border-box;
}

.avatar-item {
  cursor: pointer;
  border: 2px solid var(--border-strong);
  border-radius: 8px;
  padding: 0.5rem;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: all 0.2s;
  box-sizing: border-box;
}

.avatar-item img {
  max-width: 100%;
  height: auto;
}

.avatar-item:hover {
  border-color: var(--brand-blue); /* Using primary accent for hover border */
  background-color: var(--brand-surface);
}

.avatar-item.selected {
  border-color: var(--brand-blue);
  background-color: var(--brand-blue); /* Using primary accent for selected bg */
}

.avatar-image {
  width: 100%;
  height: auto;
  max-width: 64px;
  max-height: 64px;
}

.avatar-loading,
.avatar-error {
  grid-column: span 4;
  text-align: center;
  padding: 2rem 0;
}

/* Confirmation modal */
.confirm-modal-text {
  text-align: center;
  padding: 1rem 0;
}

/* Victory modal */
.victory-container {
  text-align: center;
  padding: 1rem;
}

.victory-title {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 1rem;
  color: var(--accent-success);
}

.victory-message {
  font-size: 1.25rem;
  margin-bottom: 2rem;
}

.victory-stats {
  display: flex;
  justify-content: space-around;
  margin-bottom: 2rem;
}

.victory-stat {
  text-align: center;
}

.victory-stat-value {
  font-size: 1.5rem;
  font-weight: bold;
}

.victory-stat-label {
  font-size: 0.9rem;
  color: var(--text-secondary);
}


/* User Info Styles */
.user-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: var(--overlay-dark);
  border-radius: 2rem;
  margin-right: 1rem;
  transition: all 0.2s ease;
}

.user-info:hover {
  background-color: var(--overlay-light);
  transform: translateY(-2px);
}

.user-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  object-fit: cover;
}

.user-name {
  font-weight: 500;
  color: var(--text-primary);
  transition: color 0.2s ease;
}

.user-name:hover {
  color: var(--brand-blue);
  text-decoration: underline;
}

/* Game lobby modal */
.lobby-container {
  padding: 1rem 0;
}

.lobby-code {
  background-color: var(--brand-surface-alt);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 1rem;
  text-align: center;
  margin-bottom: 1rem;
  position: relative;
}

.lobby-code-value {
  font-size: 2rem;
  font-weight: bold;
  letter-spacing: 0.5rem;
}

.lobby-code-copy {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.lobby-code-copy:hover {
  opacity: 1;
}

.lobby-players {
  margin-top: 1.5rem;
}

.lobby-player {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border-bottom: 1px solid var(--border-strong);
}

.lobby-player:last-child {
  border-bottom: none;
}

.lobby-player-avatar {
  width: 40px;
  height: 40px;
  margin-right: 1rem;
}

.lobby-player-name {
  flex: 1;
}

.lobby-player-status {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.lobby-player-host .lobby-player-status {
  color: var(--brand-blue);
  font-weight: bold;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .modal-medium {
    width: 90%;
  }

  .modal-large {
    width: 95%;
  }

  .avatar-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 480px) {
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 0.75rem;
  }

  .modal-title {
    font-size: 1.1rem;
  }

  .modal-title-small {
    font-size: 1rem;
  }

  .avatar-grid {
    gap: 0.3rem;
  }
}

/* Guest Modal Styles */
.guest-modal-content {
  padding: 1rem;
}

.existing-guest-section {
  border: 3px solid var(--brand-blue);
  border-radius: 8px;
  padding: 15px;
  background-color: var(--brand-surface-alt);
  margin-bottom: 1rem;
}

.existing-guest-section .alert-info {
  background-color: var(--brand-surface-alt);
  border-color: var(--brand-blue);
  color: var(--text-primary);
}

.existing-guest-section .d-flex {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}

.existing-guest-section .avatar-preview {
  width: 48px;
  height: 48px;
  border: 2px solid var(--brand-blue);
  border-radius: 50%;
  margin-right: 0.5rem;
}

.existing-guest-section .fw-bold {
  font-weight: bold;
}

.existing-guest-section .fs-5 {
  font-size: 1.25rem;
}

.existing-guest-section .w-100 {
  width: 100%;
}

.existing-guest-section .mt-2 {
  margin-top: 0.5rem;
}

.existing-guest-section .text-center {
  text-align: center;
}

.existing-guest-section .my-3 {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.existing-guest-section .fw-bold {
  font-weight: bold;
}


/* Confirmation modal styles */
.confirm-modal-content {
  text-align: center;
  padding: 1rem 0;
}

.confirm-modal-content .alert-danger {
  background-color: rgba(216, 71, 71, 0.15); /* Derived from --accent-danger */
  border: 1px solid var(--accent-danger);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.confirm-modal-content .alert-danger p {
  margin: 0.5rem 0;
}

.confirm-modal-content .alert-danger strong {
  color: var(--accent-danger);
}

#guest-delete-confirm-modal .modal-footer {
  justify-content: flex-end; /* Align buttons to the right in the delete confirmation modal */
}

#guest-delete-confirm-modal .modal-footer button {
  margin-left: 0.5rem; /* Add spacing between buttons */
}


/* Remove styles for the now non-existent icon element */
/* .edit-guest-name-icon { ... } */
/* .edit-guest-name-icon:hover { ... } */


/* Adjustments for the name span to support the pseudo-element icon */



/* Game Lobby Specific Styles */
.lobby-section {
  margin-bottom: 1.5rem;
}

.lobby-initial-choice p {
  margin-bottom: 0.5rem;
  font-weight: 500;
}

.lobby-initial-actions {
  display: flex;
  flex-direction: column;
  align-items: center; /* Keep items centered within this container */
  gap: 1rem;
  margin-top: 1rem;
  width: 80%;
  max-width: 300px;
  margin-left: auto; /* Center the container itself */
  margin-right: auto; /* Center the container itself */
}

/* Style for the HR divider */
.lobby-initial-actions hr {
  width: 100%;
  border: none;
  border-top: 1px solid var(--border-strong);
  margin: 0.5rem 0;
}

/* Make both buttons take full width of the container and increase size */
.lobby-initial-actions .btn {
    width: 100%;
    padding: 1.5rem 1rem;
    font-size: 1.5rem;
    box-sizing: border-box;
}

.join-game-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  width: 100%;
  max-width: none;
  align-items: center;
}

.lobby-code-input {
   width: 100%;
   text-transform: uppercase;
   text-align: center;
   box-sizing: border-box;
}

/* Ensure the join button also takes full width (already covered by .lobby-initial-actions .btn) */
/* .join-game-section .join-game-btn { ... } */

.lobby-code-display {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.lobby-code {
    cursor: pointer; /* Indicate it's clickable */
    user-select: all; /* Make it easy to select the text */
}

.lobby-code-display .lobby-code {
    font-size: 1.8rem;
    font-weight: bold;
    letter-spacing: 3px;
    padding: 0.5rem 2rem;
    background-color: var(--brand-surface-alt);
    border: 1px solid var(--border-strong);
    border-radius: 266px;
    min-width: 120px;
    text-align: center;
}

.players-section h4 {
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-strong);
    padding-bottom: 0.5rem;
}

.players-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 150px; /* Limit height if list gets long */
    overflow-y: auto;
}

.player-item {
    display: flex;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border-strong);
}

.player-item:last-child {
    border-bottom: none;
}

.player-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    margin-right: 0.75rem;
    object-fit: cover;
}

.player-name {
    flex-grow: 1;
    text-align: left;
}

.host-badge {
    font-size: 0.8em;
    margin-left: 0.5rem;
    color: var(--brand-blue);
    font-weight: 500;
}

.player-item.current-player .player-name {
    font-weight: bold;
}

/* Floating 'Copied!' message for Game Lobby Modal */
.copy-success-float {
  position: absolute;
  top: 50%;
  left: calc(100% + 10px);
  color: var(--accent-info); /* Using moonstone as info color */
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 1.2em;
  font-weight: bold;
  z-index: 1060;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  transition: all 2s ease-out;
}

.copy-success-float.show {
  opacity: 1;
  transform: translateY(-50%);
}

.copy-success-float.fade-out {
  opacity: 0;
  transform: translateY(-80%); /* Float upward while fading */
}

/* Make sure the lobby code display has proper positioning for the float */
.lobby-code-display {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.lobby-code {
  cursor: pointer; /* Indicate it's clickable */
  user-select: all; /* Make it easy to select the text */
}

/* End of file */

/* Styles for disabled Start Game button in lobby */
.modal-footer .start-game-btn:disabled {
  background-color: var(--button-bg);
  color: var(--button-text);
  opacity: 0.6; /* Make it slightly transparent */
  border-color: var(--border-strong); /* Match border color */
}

/* Optional: Remove hover effect when disabled */
.modal-footer .start-game-btn:disabled:hover {
  background-color: var(--button-bg); /* Keep the disabled background */
  border-color: var(--border-strong); /* Keep the disabled border */
  transform: none; /* Prevent any hover transform */
}
