/* Media Picker Modal */
.media-picker-modal .modal-dialog {
  max-width: 900px;
}

.media-picker-modal .modal-content {
  border-radius: 12px;
}

.media-picker-modal .modal-header,
.media-picker-modal .modal-title {
  color: #ffffff;
}

.media-picker-body {
  padding: 0;
  min-height: 500px;
}

.media-picker-tabs {
  padding: 0 1rem;
  border-bottom: 1px solid #dee2e6;
}

.media-picker-tabs .nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  color: #6c757d;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
}

.media-picker-tabs .nav-link.active {
  color: #B9FF66;
  border-bottom-color: #B9FF66;
  background: transparent;
}

.media-picker-tabs .nav-link:hover:not(.active) {
  border-bottom-color: #dee2e6;
}

.media-picker-content {
  padding: 1rem;
  max-height: 450px;
  overflow-y: auto;
}

/* Filter styles moved to Register.css as part of media-picker-header */

/* Loading */
.media-picker-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  gap: 1rem;
  color: #6c757d;
}

/* Pagination */
.media-picker-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #dee2e6;
}

.media-picker-page-info {
  color: #6c757d;
  font-size: 0.875rem;
}

/* Footer */
.media-picker-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.media-picker-selection-info {
  color: #6c757d;
  font-size: 0.875rem;
}

.media-picker-actions {
  display: flex;
  gap: 0.5rem;
}

/* Media Grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 1rem;
}

.media-grid-item {
  position: relative;
  cursor: pointer;
  border-radius: 8px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.05);
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.media-grid-item:hover {
  border-color: #B9FF66;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.media-grid-item.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Current OR Selected - uses #B9FF66 */
.media-grid-item.selected {
  border-color: #B9FF66;
}

.media-grid-item.selected .media-grid-item-image::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(185, 255, 102, 0.1); /* #B9FF66 at 0.1 opacity */
  pointer-events: none;
  border-radius: 4px;
}

/* Hover state (only when not selected) */
.media-grid-item:not(.selected):hover {
  border-color: rgba(185, 255, 102, 0.5);
  transform: translateY(-1px);
}

.media-grid-item-image {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
}

.media-grid-item-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Current badge - top left */
.media-grid-current-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #B9FF66;
  color: #1a1a2e; /* Dark text for contrast */
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
  font-family: 'DINBold', sans-serif;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Checkbox - top right, shows on current OR selected */
.media-grid-item-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  background: rgba(185, 255, 102, 0.9); /* #B9FF66 */
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1a1a2e; /* Dark checkmark for contrast */
  font-size: 12px;
  z-index: 2;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.media-grid-item-info {
  padding: 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.media-grid-item-name {
  font-size: 0.75rem;
  color: #eeeeee;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.media-grid-item-size {
  font-size: 0.625rem;
  color: #6c757d;
}

.media-grid-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: #6c757d;
  text-align: center;
}

.media-grid-empty p {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 500;
}

.media-grid-empty span {
  font-size: 0.875rem;
}

/* Media Uploader */
.media-uploader {
  padding: 1rem;
}

.media-uploader-dropzone {
  border: 2px dashed rgba(155, 155, 155, 0.3);
  border-radius: 12px;
  padding: 3rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: rgba(255, 255, 255, 0.05);
}

.media-uploader-dropzone:hover,
.media-uploader-dropzone.dragging {
  border-color: #b9ff6666;
  background: rgba(255, 255, 255, 0.1);
}

.media-uploader-icon {
  font-size: 3rem;
  color: #6c757d;
  margin-bottom: 1rem;
}

.media-uploader-text {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: #eeeeee;
}

.media-uploader-hint {
  margin: 0;
  font-size: 0.875rem;
  color: #6c757d;
}

.media-uploader-progress {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 300px;
  margin: 0 auto;
}

.media-uploader-progress .progress {
  width: 100%;
  height: 20px;
}

.media-uploader-error {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  background: #f8d7da;
  border: 1px solid #f5c2c7;
  border-radius: 8px;
  color: #842029;
  display: flex;
  align-items: center;
}

.media-uploader-success {
  margin-top: 1rem;
  padding: 1rem;
  background: #d1e7dd;
  border: 1px solid #badbcc;
  border-radius: 8px;
  color: #0f5132;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
}

.media-uploader-success-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.media-uploader-success-title {
  font-weight: 500;
}

.media-uploader-savings,
.media-uploader-duplicate {
  font-size: 0.875rem;
  opacity: 0.8;
}

.media-uploader-preview {
  flex-shrink: 0;
}

.media-uploader-preview img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 6px;
}

/* Old Media Picker Button styles - now replaced by new .media-picker-with-image styles below */

/* Dark mode support */
.dark-mode .media-picker-modal .modal-content {
  background: #1a1a2e;
  color: #fff;
}

.dark-mode .media-picker-tabs {
  border-color: #333;
}

.dark-mode .media-picker-tabs .nav-link {
  color: #aaa;
}

.dark-mode .media-picker-tabs .nav-link.active {
  color: #90caf9;
  border-bottom-color: #90caf9;
}

.dark-mode .media-grid-item {
  background: #2d2d44;
}

.dark-mode .media-grid-item.selected {
  background: #1e3a5f;
  border-color: #90caf9;
}

.dark-mode .media-grid-item-name {
  color: #fff;
}

.dark-mode .media-uploader-dropzone {
  background: #2d2d44;
  border-color: #444;
}

.dark-mode .media-uploader-dropzone:hover,
.dark-mode .media-uploader-dropzone.dragging {
  background: #1e3a5f;
  border-color: #90caf9;
}

.dark-mode .media-picker-button-preview {
  border-color: #444;
}

/* Responsive */
@media (max-width: 767px) {
  .media-picker-modal .modal-dialog {
    max-width: 100%;
    margin: 0.5rem;
  }

  .media-picker-body {
    min-height: 400px;
  }

  .media-picker-content {
    max-height: 350px;
  }

  /* Old filter mobile styles removed - now in Register.css */

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 0.5rem;
  }

  .media-picker-footer {
    flex-direction: column;
    gap: 0.5rem;
  }

  .media-picker-actions {
    width: 100%;
  }

  .media-picker-actions .btn {
    flex: 1;
  }
}

/* ================================================================
   MEDIA PICKER BUTTON - CENTRALIZED STYLES
   Desktop: Square image with overlay controls on hover
   Mobile: Horizontal layout with buttons on side
   ================================================================ */

/* Main container */
.media-picker-button {
  width: 100%;
}

/* ================================================================
   PLACEHOLDER STATE (no image)
   ================================================================ */

/* Desktop - Square placeholder */
.mpb-placeholder-container {
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.02);
  border: 2px dashed rgba(255, 255, 255, 0.3);
  border-radius: 10px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.mpb-placeholder-container:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.5);
}

.mpb-placeholder-icon {
  color: rgba(255, 255, 255, 0.4);
}

.mpb-placeholder-icon svg {
  width: 32px;
  height: 32px;
}

.mpb-placeholder-text {
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  text-align: center;
  padding: 0 10px;
}

/* ================================================================
   WITH IMAGE STATE - DESKTOP (overlay on hover)
   ================================================================ */

/* Image container - square, 180px max */
.mpb-image-container {
  aspect-ratio: 1 / 1;
  width: 100%;
  max-width: 180px;
  position: relative;
  border-radius: 10px;
  overflow: hidden;
}

/* Image wrapper with overlay */
.mpb-image-wrapper {
  width: 100%;
  height: 100%;
  position: relative;
}

.mpb-image-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Overlay - hidden by default, visible on hover */
.mpb-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mpb-image-wrapper:hover .mpb-overlay {
  opacity: 1;
}

/* Control buttons in overlay */
.mpb-controls {
  display: flex;
  gap: 12px;
}

.mpb-btn-edit,
.mpb-btn-delete {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.mpb-btn-edit {
  background: rgba(255, 255, 255, 0.9);
  color: #333;
}

.mpb-btn-edit:hover {
  background: #fff;
  transform: scale(1.1);
}

.mpb-btn-delete {
  background: rgba(220, 53, 69, 0.9);
  color: #fff;
}

.mpb-btn-delete:hover {
  background: #dc3545;
  transform: scale(1.1);
}

.mpb-btn-edit:disabled,
.mpb-btn-delete:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.mpb-btn-edit svg,
.mpb-btn-delete svg {
  width: 16px;
  height: 16px;
}

/* ================================================================
   WITH IMAGE STATE - MOBILE (horizontal layout)
   ================================================================ */

/* Mobile wrapper - horizontal flex */
.mpb-mobile-wrapper {
  display: none; /* Hidden on desktop */
}

/* Mobile image preview */
.mpb-mobile-preview {
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  border-radius: 8px;
  overflow: hidden;
}

.mpb-mobile-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Mobile controls - horizontal layout with labels */
.mpb-mobile-controls {
  display: flex;
  flex-direction: row;
  gap: 8px;
  flex-wrap: wrap;
}

.mpb-mobile-controls .mpb-btn {
  width: auto;
  height: 36px;
  padding: 0 12px;
  border-radius: 18px; /* Pill shape */
  border: none;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  font-family: 'DINBold', sans-serif;
}

.mpb-mobile-controls .mpb-btn svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.mpb-mobile-controls .mpb-btn-label {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

.mpb-mobile-controls .mpb-btn-edit {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.mpb-mobile-controls .mpb-btn-edit:hover {
  background: rgba(255, 255, 255, 0.25);
}

.mpb-mobile-controls .mpb-btn-delete {
  background: rgba(220, 53, 69, 0.3);
  color: #dc3545;
}

.mpb-mobile-controls .mpb-btn-delete:hover {
  background: rgba(220, 53, 69, 0.5);
}

.mpb-mobile-controls .mpb-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Very small screens - stack vertically */
@media (max-width: 400px) {
  .mpb-mobile-controls {
    flex-direction: column;
  }

  .mpb-mobile-controls .mpb-btn {
    width: 100%;
    justify-content: center;
  }
}

/* ================================================================
   MOBILE RESPONSIVE
   ================================================================ */
@media (max-width: 768px) {
  /* Hide desktop image container on mobile */
  .mpb-image-container {
    display: none;
  }

  /* Show mobile wrapper */
  .mpb-mobile-wrapper {
    display: flex;
    align-items: center;
    gap: 15px;
    /* background: rgba(255, 255, 255, 0.05); */ 
    border-radius: 10px;
  }

  /* Placeholder - Horizontal layout on mobile */
  .mpb-placeholder-container {
    aspect-ratio: auto;
    max-width: 100%;
    flex-direction: row;
    justify-content: flex-start;
    padding: 15px;
    gap: 15px;
    background: rgba(255, 255, 255, 0.05);
    border: none;
  }

  .mpb-placeholder-icon {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed rgba(255, 255, 255, 0.3);
    border-radius: 8px;
  }

  .mpb-placeholder-icon svg {
    width: 24px;
    height: 24px;
  }

  .mpb-placeholder-text {
    flex: 1;
    text-align: left;
    font-size: 14px;
    padding: 0;
  }
}

/* ================================================================
   SIZE VARIANTS
   ================================================================ */

/* Small */
.mpb-size-sm .mpb-image-container,
.mpb-size-sm .mpb-placeholder-container {
  max-width: 120px;
}

.mpb-size-sm .mpb-placeholder-icon svg {
  width: 24px;
  height: 24px;
}

.mpb-size-sm .mpb-placeholder-text {
  font-size: 11px;
}

.mpb-size-sm .mpb-btn-edit,
.mpb-size-sm .mpb-btn-delete {
  width: 32px;
  height: 32px;
}

.mpb-size-sm .mpb-btn-edit svg,
.mpb-size-sm .mpb-btn-delete svg {
  width: 12px;
  height: 12px;
}

/* Large */
.mpb-size-lg .mpb-image-container,
.mpb-size-lg .mpb-placeholder-container {
  max-width: 240px;
}

.mpb-size-lg .mpb-placeholder-icon svg {
  width: 40px;
  height: 40px;
}

.mpb-size-lg .mpb-placeholder-text {
  font-size: 14px;
}

.mpb-size-lg .mpb-btn-edit,
.mpb-size-lg .mpb-btn-delete {
  width: 48px;
  height: 48px;
}

.mpb-size-lg .mpb-btn-edit svg,
.mpb-size-lg .mpb-btn-delete svg {
  width: 20px;
  height: 20px;
}

/* ================================================================
   ASPECT RATIO VARIANTS
   ================================================================ */

.mpb-ratio-16-9 .mpb-image-container,
.mpb-ratio-16-9 .mpb-placeholder-container {
  aspect-ratio: 16 / 9;
}

.mpb-ratio-4-3 .mpb-image-container,
.mpb-ratio-4-3 .mpb-placeholder-container {
  aspect-ratio: 4 / 3;
}

.mpb-ratio-3-2 .mpb-image-container,
.mpb-ratio-3-2 .mpb-placeholder-container {
  aspect-ratio: 3 / 2;
}

/* ================================================================
   FULL WIDTH VARIANT
   ================================================================ */

.mpb-full-width .mpb-image-container,
.mpb-full-width .mpb-placeholder-container {
  max-width: 100%;
}

/* ================================================================
   UNIFIED SELECTION PATTERN - Single Checkbox per Image
   User selects first, then chooses action (Use or Delete)
   ================================================================ */

/* Checkbox - top right corner (unified for all selection) */
.media-grid-item-check {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #6c757d;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  z-index: 3;
}

/* Show on hover (desktop) */
.media-grid-item:hover .media-grid-item-check {
  opacity: 1;
}

/* Always show when ANY item is selected (selection mode active) */
.media-grid-item-check.always-visible {
  opacity: 1;
}

/* Checked state */
.media-grid-item-check.checked {
  background: #B9FF66;
  border-color: #B9FF66;
  color: #212529;
  opacity: 1;
}

.media-grid-item-check.checked svg {
  width: 12px;
  height: 12px;
}

/* Selected item border */
.media-grid-item.selected {
  outline: 3px solid #B9FF66;
  outline-offset: -3px;
}

.media-grid-item.selected .media-grid-item-image::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(185, 255, 102, 0.1);
  pointer-events: none;
  border-radius: 4px;
}

/* ================================================================
   UNIFIED FOOTER LAYOUT
   Shows selection count, bulk actions, and all available actions
   ================================================================ */

/* ================================================================
   INLINE FOOTER LAYOUT - Base styles for slide panel usage
   Required for 2-panel slide patterns (Edit Profile, etc.)
   ================================================================ */
.media-picker-inline-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: rgb(33, 37, 41);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  margin-top: auto;
  flex-shrink: 0;
  width: 100%;
  box-sizing: border-box;
}

/* Footer left section - selection info and bulk actions */
.media-picker-footer-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.media-picker-selection-count {
  font-weight: 500;
  color: #fff;
  font-size: 14px;
}

.media-picker-bulk-actions {
  display: flex;
  gap: 8px;
}

.media-picker-bulk-actions .btn-link {
  color: #B9FF66;
  text-decoration: none;
  padding: 0;
  font-size: 13px;
}

.media-picker-bulk-actions .btn-link:hover {
  text-decoration: underline;
}

/* Footer right section - action buttons */
.media-picker-footer-right {
  display: flex;
  gap: 8px;
}

/* Delete button - outline danger style */
.media-picker-btn-delete {
  display: flex;
  align-items: center;
  gap: 6px;
}

.media-picker-btn-delete svg {
  width: 14px;
  height: 14px;
}

/* Select button with icon */
.media-picker-btn-select {
  display: flex;
  align-items: center;
  gap: 6px;
}

.media-picker-btn-select svg {
  width: 14px;
  height: 14px;
}

/* Delete confirmation dialog */
.delete-confirm-content {
  padding: 20px 0;
  text-align: center;
}

.delete-confirm-content h4 {
  margin: 0 0 10px;
  color: #fff;
  font-size: 18px;
}

.delete-confirm-content p {
  color: rgba(255, 255, 255, 0.7);
  margin: 0 0 20px;
  font-size: 14px;
}

.delete-warning {
  background: rgba(255, 193, 7, 0.15);
  border: 1px solid rgba(255, 193, 7, 0.5);
  border-radius: 6px;
  padding: 12px 16px;
  margin-bottom: 20px;
  text-align: left;
}

.delete-warning p {
  color: #ffc107;
  margin: 0 0 10px;
  font-size: 14px;
}

.delete-warning-btn {
  background: rgba(255, 193, 7, 0.2);
  border: 1px solid rgba(255, 193, 7, 0.5);
  color: #ffc107;
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.delete-warning-btn:hover {
  background: rgba(255, 193, 7, 0.3);
}

.delete-confirm-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.delete-confirm-actions button {
  padding: 10px 24px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.15s ease;
}

.delete-confirm-actions .btn-cancel {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
}

.delete-confirm-actions .btn-cancel:hover {
  background: rgba(255, 255, 255, 0.1);
}

.delete-confirm-actions .btn-danger {
  background: #dc3545;
  color: white;
  border: none;
}

.delete-confirm-actions .btn-danger:hover {
  background: #c82333;
}

/* ================================================================
   MOBILE: Flexbox layout for full-height modal
   ================================================================ */
@media (max-width: 768px) {
  /* Content panel fills the modal body */
  .media-picker-content-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0; /* Important for flex children to shrink */
  }

  /* Header stays at top */
  .media-picker-header {
    flex-shrink: 0;
  }

  /* Content fills remaining space and scrolls */
  .media-picker-inline-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding-bottom: 140px; /* Space for fixed footer */
  }

  /* Footer fixed at bottom of screen */
  .media-picker-inline-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1050;
    background: rgb(33, 37, 41);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 0;
    padding: 12px 16px;
    /* Add safe area for notched phones */
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    /* Stack footer content on mobile */
    flex-direction: column;
    gap: 12px;
  }

  .media-picker-footer-left,
  .media-picker-footer-right {
    width: 100%;
    justify-content: center;
  }

  .media-picker-footer-left {
    flex-direction: column;
    gap: 8px;
    text-align: center;
  }

  .media-picker-footer-right {
    flex-wrap: wrap;
  }

  .media-picker-footer-right .btn {
    flex: 1;
    min-width: 80px;
  }

  /* Delete confirm dialog adjustments */
  .delete-confirm-actions {
    flex-direction: column;
  }

  .delete-confirm-actions button {
    width: 100%;
  }

  /* Always show checkboxes on mobile when in selection mode */
  .media-grid-item-check.always-visible {
    opacity: 1;
  }
}
