/* --- AddMedia Component Styles --- */

/* Define color variables for easy theming */
:root {
  --background-dark: #111827; /* gray-900 */
  --background-medium: #1f2937; /* gray-800 */
  --border-color: #374151; /* gray-700 */
  --text-primary: #f9fafb; /* gray-50 */
  --text-secondary: #d1d5db; /* gray-300 */
  --text-muted: #9ca3b0; /* gray-400 */
  --accent-blue: #2563eb; /* blue-600 */
  --accent-blue-hover: #3b82f6; /* blue-500 */
  --danger-text: #fca5a5; /* red-300 */
  --danger-bg: rgba(239, 68, 68, 0.2); /* red-500/20 */
}

/* --- Main Modal & Overlay --- */

.add-media-overlay {
  text-align: left;
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 790;
}

.add-media-modal {
  position: relative;
  background-color: var(--background-dark);
  color: var(--text-primary);
  border-radius: 0.75rem; /* rounded-xl */
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  width: 100%;
  max-width: 25rem; /* max-w-2xl */
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

/* --- Loading Spinner / Overlay --- */
.loading-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 0.75rem;
}

.loading-text {
  font-size: 1.125rem; /* text-lg */
}

/* --- Header, Body, Footer Layout --- */

.modal-header {
  display: flex;
  justify-content: center; /* Centers horizontally */
  align-items: center;     /* Centers vertically */
  width: 100%;
  padding: 15px 0;         /* Adds some nice breathing room */
  border-bottom: 1px solid #eee; /* Optional: adds a separator line */
}

.modal-header h2 {
  margin: 0;               /* Removes default browser margins */
  text-align: center;
}

.modal-body {
  padding: 0 0.5rem 0.5rem;
  overflow-y: auto;
  /* Adds space between direct children */
  & > * + * {
    margin-top: 1.5rem;
  }
}

.modal-footer {
  padding: 1rem;
  background-color: rgba(31, 41, 55, 0.5); /* gray-800/50 */
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: auto; /* Pushes footer to the bottom */
}


/* --- Form Elements & Messages --- */

.error-message {
  background-color: var(--danger-bg);
  color: var(--danger-text);
  padding: 0.75rem;
  border-radius: 0.375rem; /* rounded-md */
  font-size: 0.875rem; /* text-sm */
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.text-input {
  width: 100%;
  background-color: var(--background-medium);
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  padding: 0.5rem;
  transition: box-shadow 0.2s ease-in-out;
}

.text-input:focus {
  outline: none;
  box-shadow: 0 0 0 2px var(--accent-blue);
}

.section-title {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
}

.helper-text {
  font-size: 0.75rem; /* text-xs */
  color: var(--text-muted);
  margin-bottom: 0.75rem;
  margin-top: -0.5rem;
  color: lightslategray;
}

/* --- Media Grid --- */

.media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

.premium-grid {
    grid-template-columns: repeat(1, 1fr);
}
/* Responsive grid columns */
@media (min-width: 640px) {
  .media-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}
@media (min-width: 768px) {
  .media-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* --- Grid Item (Preview & Add Button) --- */

.grid-item {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0.5rem; /* rounded-lg */
  overflow: hidden;
}

.media-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.remove-button {
  position: absolute;
  top: 0.25rem;
  right: 0.25rem;
  background-color: rgba(0, 0, 0, 0.5);
  color: white;
  border-radius: 9999px; /* rounded-full */
  width: 1.5rem; /* w-6 */
  height: 1.5rem; /* h-6 */
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s ease-in-out;
  font-size: 1.25rem;
  line-height: 1;
}

/* Show remove button on hover */
.grid-item:hover .remove-button {
  opacity: 1;
}

/* --- Add Media Label --- */

.add-media-label {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 0.5rem;
  border: 2px dashed #6b7280; /* border-gray-400 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s, border-color 0.2s;
  cursor: pointer;
}

.add-media-label:hover {
  background-color: var(--background-medium);
  border-color: #4b5563; /* border-gray-500 */
}

.add-media-label.loading {
  cursor: not-allowed;
  background-color: var(--background-medium);
}

.add-media-icon {
  font-size: 2.25rem; /* text-4xl */
  color: #6b7280; /* text-gray-500 */
}

.add-media-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

.hidden-input {
  display: none;
}


/* --- Action Buttons --- */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease-in-out, opacity 0.2s ease-in-out;
  font-weight: 600;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-cancel {
  background-color: #4b5563; /* gray-600 */
  color: var(--text-primary);
}

.btn-cancel:hover:not(:disabled) {
  background-color: #6b7280; /* gray-500 */
}

.btn-save {
  background-color: var(--accent-blue);
  color: var(--text-primary);
}

.btn-save:hover:not(:disabled) {
  background-color: var(--accent-blue-hover);
}