/* ================== */
/* Modal Styles       */
/* ================== */

/* --- Base Modal Overlay Styling (Common for different modals if needed) --- */
.modal-overlay {
  display: none; /* Hidden by default, activated by JS with a class like .active */
  position: fixed; 
  z-index: 9998; /* High z-index, but below specific modal content */
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0,0,0,0.65); /* Darker overlay for better focus */
  backdrop-filter: blur(3px); /* Subtle blur for modern feel */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-out, visibility 0s linear 0.3s;
  -webkit-tap-highlight-color: transparent; /* Prevent tap highlight on overlay */
}
.modal-overlay.active {
  display: flex; /* Use flex for centering content if this is the main wrapper */
  justify-content: center;
  align-items: center;
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}


/* --- Auth Modal --- */
.auth-modal { /* This is the direct wrapper for auth-modal-content */
  /* This class itself might not need to be display:flex if .modal-overlay handles centering */
  /* If .auth-modal IS the overlay: */
  display: none; 
  position: fixed; 
  z-index: 9999; 
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow-y: auto; /* Enable scroll if modal content is too tall */
  background-color: rgba(0,0,0,0.65); 
  backdrop-filter: blur(3px);
  justify-content: center;
  align-items: center; /* Vertically center, can be flex-start if content is long */
  padding: 1rem; /* Padding for small screens so modal doesn't touch edges */
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-out, visibility 0s linear 0.3s;
}

.auth-modal.active {
  display: flex; 
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.auth-modal-content {
  background: var(--card-background); 
  color: var(--text-color); 
  /* margin: auto; /* Centering handled by .auth-modal flex */
  padding: 2.5rem; /* Increased padding */
  border-radius: 16px; /* Softer radius */
  max-width: 420px; /* Slightly wider */
  width: 100%; /* Responsive width */
  position: relative; 
  box-shadow: 0 10px 40px rgba(0,0,0,0.15); /* More pronounced shadow */
  text-align: center;
  transform: scale(0.95) translateY(10px); /* Initial state for animation */
  opacity: 0; /* Initial state for animation */
  transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1.5), opacity 0.3s ease-out; /* Bouncy pop-up */
}

.auth-modal.active .auth-modal-content {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.close-button {
  position: absolute;
  top: 12px; /* Adjusted position */
  right: 12px;
  font-size: 1.2rem; /* Slightly smaller, more refined */
  color: var(--text-light);
  cursor: pointer;
  background: transparent; /* Ensure transparent background */
  border: none; 
  padding: 0.5rem; /* Larger click area */
  line-height: 1; 
  border-radius: 50%; /* Make it round for better hit area */
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.close-button:hover,
.close-button:focus {
  color: var(--primary-color);
  background-color: rgba(var(--primary-color-rgb), 0.1); /* Subtle hover background */
}


/* --- Theme Selector Panel --- */
.theme-selector-panel { /* This is the modal content itself */
  position: fixed; /* Fixed position for modal */
  top: 50%;
  left: 50%;
  /* transform: translate(-50%, -50%) scale(0.95) translateY(10px); Start slightly smaller and lower */
  /* Initial transform is handled by the parent .modal-overlay active state perhaps, or directly */
  background: var(--card-background);
  border-radius: 18px; /* Slightly more radius */
  padding: 2rem; /* Adjusted padding */
  box-shadow: 0 12px 45px rgba(0, 0, 0, 0.18); /* Enhanced shadow */
  z-index: 10000; 
  width: 90%;
  max-width: 380px; /* Slightly smaller max-width */
  /* opacity: 0; */ /* Handled by parent .modal-overlay */
  /* visibility: hidden; */
  /* transition: transform 0.3s cubic-bezier(0.25, 0.1, 0.25, 1.5), opacity 0.3s ease-out; */
  /* The .theme-selector-panel itself is the content, so its parent (.modal-overlay) would control visibility/opacity */
}

/* If .theme-selector-panel is wrapped by .modal-overlay.active */
.modal-overlay.active .theme-selector-panel {
  transform: translate(-50%, -50%) scale(1) translateY(0);
  opacity: 1; /* Ensure this is set if opacity was 0 initially */
}
/* If .theme-selector-panel has its own .active class for showing: */
.theme-selector-panel.active { /* This rule would be used if .theme-selector-panel is shown independently */
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1) translateY(0);
}


.theme-selector-content h3 { 
  color: var(--text-color);
  text-align: center;
  margin-bottom: 1.75rem; /* Increased margin */
  font-size: 1.3rem; 
  font-weight: 600; 
}

.theme-grid { 
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); /* Responsive columns */
  gap: 1rem; /* Adjusted gap */
}

.theme-btn { 
  position: relative; 
  width: 100%;
  padding-top: 100%; /* Create square aspect ratio */
  border: 2px solid transparent; /* Border for focus/active state */
  border-radius: 12px; /* Softer radius */
  cursor: pointer;
  transition: transform 0.2s ease-out, box-shadow 0.2s ease-out, border-color 0.2s ease-out;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.1); 
  overflow: hidden; 
  -webkit-tap-highlight-color: transparent;
}

.theme-btn:hover {
  transform: scale(1.07); /* Slightly more pronounced hover */
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

.theme-btn:focus,
.theme-btn.active { /* Combine focus and active for border */
    outline: none; /* Remove default outline, use border */
    border-color: var(--primary-color); /* Theme color border for active/focus */
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.3), 0 5px 15px rgba(0,0,0,0.15); /* Glow and existing shadow */
}
/* For keyboard-only focus if desired, using :focus-visible */
.theme-btn:focus-visible {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.3), 0 5px 15px rgba(0,0,0,0.15);
}

.theme-check { 
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8); /* Start slightly smaller for pop-in */
  color: white;
  font-size: 28px; /* Larger checkmark */
  opacity: 0; 
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); /* Sharper shadow for checkmark */
  transition: opacity 0.2s ease-out, transform 0.2s ease-out; 
  pointer-events: none; 
}

.theme-btn.active .theme-check { 
  opacity: 1;
  transform: translate(-50%, -50%) scale(1); /* Scale to full size */
}

/* Theme Color Backgrounds for Buttons - these are good */
.theme-mint { background: linear-gradient(135deg, #159875, #00A4B6); }
.theme-light-blue { background: linear-gradient(135deg, #64B5F6, #B388FF); }
.theme-blue { background: linear-gradient(135deg, #1976D2, #7E57C2); }
.theme-purple { background: linear-gradient(135deg, #9575CD, #BA68C8); }
.theme-pink { background: linear-gradient(135deg, #FF4081, #FF7043); } /* Adjusted pink gradient */
.theme-red { background: linear-gradient(135deg, #E53935, #F4511E); }    /* Adjusted red gradient */
.theme-yellow { background: linear-gradient(135deg, #FFB74D, #FFEE58); } /* Adjusted yellow gradient */
.theme-green { background: linear-gradient(135deg, #81C784, #26A69A); }  /* Adjusted green gradient */
.theme-orange { background: linear-gradient(135deg, #FF8A65, #FFA726); } /* Adjusted orange gradient */