/* ===========================================
   Modal Styles
   =========================================== */

/* Modal Base */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.2); /* Even more transparent */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-index-modal);
  opacity: 1;
  transition: opacity 0.3s ease, visibility 0.3s ease;
  backdrop-filter: blur(1px); /* Reduced blur effect */
}

.modal.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

/* Common styling for all modal forms */
.modal-content {
  background-color: rgba(0, 0, 0, 0.9); /* Semi-transparent black background */
  border-radius: var(--border-radius-md);
  padding: var(--space-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: var(--box-shadow-lg);
  border: 1px solid var(--primary-dark);

  /* Custom spooky scrollbar */
  scrollbar-width: thin;
  scrollbar-color: #ff6600 #181818;
}

.modal-content::-webkit-scrollbar {
  width: 10px;
  background: #181818;
  border-radius: 8px;
}

.modal-content::-webkit-scrollbar-thumb {
  background: linear-gradient(135deg, orange 60%, orangered 100%);
  border-radius: 8px;
  border: 2px solid #181818;
}

.modal-content::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(135deg, #ffae42 40%, #ff4500 100%);
}

.modal-content::-webkit-scrollbar-corner {
  background: #181818;
}

/* Close Button */
.close-modal {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: var(--font-size-xxl);
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: var(--transition-medium);
}

.close-modal:hover {
  color: var(--primary);
  transform: scale(1.2);
}

/* Modal Title */
#modal-title {
  color: var(--primary);
  margin-top: 0;
  margin-bottom: var(--space-md);
  padding-right: 0; /* Remove the right padding that's offsetting the centering */
  font-family: var(--font-secondary);
  text-align: center; /* Ensure text is centered */
  width: 100%; /* Take up full width of container */
}

#modal-date {
  color: var(--text);
  margin-bottom: var(--space-md);
  font-size: var(--font-size-md);
}

/* Standardize form styling */
.auth-form,
#entry-form {
  display: flex;
  flex-direction: column;
}

/* Standardize form label styling */
.auth-form label,
#entry-form label {
  margin-bottom: var(--space-xs);
  color: var(--text);
  text-shadow: none; /* Remove the glow if you don't want it */
}

/* Make form labels bold in the add/edit modal */
#entry-form label {
  font-weight: bold !important;
  color: var(--primary) !important;
}

/* Make file upload label bold too */
#entry-form .file-upload-label,
.file-upload-label {
  font-weight: bold !important;
  color: var(--primary) !important;
}

/* Also make any headings inside the form bold */
#entry-form h3,
#entry-form h4 {
  font-weight: bold !important;
  color: var(--primary) !important;
}

/* Standardize form input styling */
.auth-form .form-control,
#entry-form input[type="text"],
#entry-form select,
#entry-form textarea {
  margin-bottom: var(--space-md);
  padding: var(--space-sm);
  background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent inputs */
  border: 1px solid var(--dark-gray); /* Match the add/edit modal border */
  color: var(--white);
  border-radius: var(--border-radius-sm); /* Match the add/edit modal border-radius */
}

/* Standardize form input focus styling */
.auth-form .form-control:focus,
#entry-form input[type="text"]:focus,
#entry-form select:focus,
#entry-form textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 5px var(--primary-light); /* Same focus effect */
}

#entry-description {
  min-height: 100px;
  resize: vertical;
}

/* Character counters */
#title-counter,
#description-counter {
  text-align: right;
  font-size: var(--font-size-xs);
  color: var(--mid-gray);
  margin-top: -10px;
  margin-bottom: var(--space-sm);
  transition: color 0.2s;
}
#title-counter.char-warn,
#description-counter.char-warn {
  color: orange;
  transition: color 0.2s;
}
#title-counter.char-danger,
#description-counter.char-danger {
  color: #b71c1c;
  transition: color 0.2s;
}

.char-warn {
  color: orange;
}
.char-danger {
  color: #b71c1c;
}

/* Image Upload */
#entry-image {
  padding: var(--space-sm) 0;
}

/* Image Preview Container */
.image-preview-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.image-container {
  position: relative;
  border: 1px solid var(--dark-gray);
  border-radius: var(--border-radius-sm);
  overflow: hidden;
}

.preview-image {
  width: 100%;
  height: 100px;
  object-fit: cover;
}

.delete-image-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  background-color: rgba(0, 0, 0, 0.7);
  color: var(--white);
  border: none;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: var(--font-size-sm);
  padding: 0;
}

.delete-image-btn:hover {
  background-color: var(--danger);
}

.default-image-selector {
  position: absolute;
  bottom: 5px;
  left: 5px;
  background-color: rgba(0, 0, 0, 0.7);
  padding: 2px 5px;
  border-radius: var(--border-radius-sm);
  display: flex;
  align-items: center;
  gap: 3px;
}

.default-image-selector label {
  color: var(--white);
  font-size: var(--font-size-xs);
  margin-bottom: 0;
}

/* Standardize button styling */
.auth-button,
.modal-button {
  padding: var(--space-sm) var(--space-md);
  border: none;
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition-medium);
  margin-top: var(--space-sm);
  font-weight: bold;
  background-color: var(--primary);
  color: var(--white);
}

.auth-button:hover,
.modal-button:hover {
  background-color: var(--primary-dark);
  transform: translateY(-2px);
  box-shadow: var(--box-shadow-sm);
}

/* Loading State */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255, 102, 0, 0.3);
  border-radius: 50%;
  border-top-color: var(--primary);
  animation: spin 1s ease-in-out infinite;
}

/* Inner content for loading overlay */
.loading-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.loading-overlay-text {
  color: var(--white);
  font-weight: bold;
}

/* New checkbox styling that won't conflict */
.checkbox-wrapper {
  display: flex;
  align-items: center;
  margin-bottom: var(--space-md);
}

.auth-checkbox {
  margin-right: 8px;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  accent-color: var(--info); /* Modern browsers */

}

.checkbox-wrapper label {
  margin-bottom: 0 !important;
  display: inline !important;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Reset any potential interference */
.form-group {
  margin-bottom: var(--space-md);
  position: relative; /* For positioning any counters or icons */
}

/* Add these styles to your CSS */
.form-group.checkbox-wrapper {
  display: grid !important;
  grid-template-columns: auto 1fr !important;
  align-items: center !important;
  grid-gap: 10px !important;
  margin-bottom: var(--space-md) !important;
}

.form-group.checkbox-wrapper input[type="checkbox"].auth-checkbox {
  margin: 0 !important;
  justify-self: start !important;
  width: 18px !important;
  height: 18px !important;
}

.form-group.checkbox-wrapper label {
  margin: 0 !important;
  padding: 0 !important;
  text-align: left !important;
  white-space: normal !important;
  line-height: 1.4 !important;
}

/* Update these styles in your modal.css or styles.css file */

/* Main modal content container */
.modal-content.auth-container {
  background-color: rgba(0, 0, 0, 0.7); /* Change from solid black to semi-transparent */
  border: 1px solid var(--primary); /* Add a border for definition */
  box-shadow: 0 0 15px var(--primary-light); /* Add a glow effect */
}

/* For better visibility of content */
.auth-title {
  color: var(--white);
  text-shadow: 0 0 8px var(--primary); /* Add a subtle glow to the title */
}

/* Make form labels more visible against transparent background */
.auth-form label {
  color: var(--white);
  text-shadow: 0 0 4px rgba(255, 102, 0, 0.8); /* Subtle orange glow */
}

/* Ensure form inputs stand out against the transparent background */
.auth-form .form-control {
  background-color: rgba(0, 0, 0, 0.6); /* Semi-transparent inputs */
  border: 1px solid var(--dark-gray); /* Match the add/edit modal border */
  color: var(--white);
  border-radius: var(--border-radius-sm); /* Match the add/edit modal border-radius */
  margin-bottom: var (--space-md);
  padding: var(--space-sm);
}

/* Fix the checkbox and label alignment */
.form-group.checkbox-wrapper {
  display: flex !important;
  align-items: center !important;
  margin-bottom: var(--space-md) !important;
}

.form-group.checkbox-wrapper input[type="checkbox"].auth-checkbox {
  margin-right: 8px !important;
}

.form-group.checkbox-wrapper label {
  margin: 0 !important;
}

/* Match title styling */
.auth-title,
#modal-title {
  color: var(--primary);
  margin-top: 0;
  margin-bottom: var(--space-md);
  font-family: var(--font-secondary);
  text-align: center;
  width: 100%;
}

/* Make form control focus states consistent */
.auth-form .form-control:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 5px var (--primary-light); /* Same focus effect */
}

/* Make auth-form inputs match the size of entry-form inputs */
.auth-form input[type="text"],
.auth-form input[type="email"],
.auth-form input[type="password"] {
  height: auto;
  padding: var(--space-sm);
  width: 100%;
}

/* Remove border from file input button */
input[type="file"] {
  border: none !important;
  background: none !important;
  padding: 0 !important;
  margin-bottom: var(--space-md);
}

/* Style the file input button more consistently with other buttons */
input[type="file"]::file-selector-button {
  background-color: var(--dark-gray);
  color: var(--white);
  border: none;
  padding: var(--space-xs) var(--space-sm);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition-medium);
  margin-right: var(--space-sm);
}

/* Hover effect for the file selector button */
input[type="file"]::file-selector-button:hover {
  background-color: var(--primary);
}

/* Hide delete button in add modal, show only in edit modal */
.modal:not([data-editing="true"]) #delete-entry {
  display: none;
}

/* Ensure the delete button is visible in edit mode */
.modal[data-editing="true"] #delete-entry {
  display: block;
}

/* Style the delete button with danger color */
#delete-entry {
  background-color: var(--danger) !important;
  border-color: var(--danger) !important;
  color: var(--white) !important;
}

/* Style the hover state for the delete button */
#delete-entry:hover {
  background-color: #d32f2f !important; /* Slightly darker red */
  box-shadow: 0 0 8px rgba(244, 67, 54, 0.6) !important; /* Red glow */
}