/**
 * ItemEditor Component - Centralized Styles
 * This file contains all styles for the ItemEditor component
 * Used in: StageCreation, StageUpdate, MultiStageUpdate, LeagueEdit
 */

/* ===== CONTAINER STYLES ===== */

.item-editor-container {
  width: 100%;
  position: relative;
}

.prize-list-container,
.sponsor-list-container {
  margin-top: 1rem;
}

.prize-list-modern,
.sponsor-list-modern {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 15px;
}

/* ===== PRIZE ITEM STYLES ===== */

.prize-item-modern {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 0;
  margin-bottom: 0px;
  border: none;
  transition: all 0.3s ease;
  min-height: 100px;
}

.prize-item-modern:hover {
  background: rgba(255, 255, 255, 0.08);
  transform: translateY(-2px);
}

.prize-item-modern:last-child {
  margin-bottom: 0;
}

/* Specific overrides for different contexts */
.league-edit-page .prize-item-modern,
.league-stage-page .prize-item-modern {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0;
}

.league-edit-page .prize-item-modern:hover,
.league-stage-page .prize-item-modern:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(5px);
}

/* Utility classes for height */
.prize-item-modern.min-h-100 {
  min-height: 100px;
}

.prize-item-modern.min-h-auto {
  min-height: auto;
}

/* ===== SPONSOR ITEM STYLES ===== */

.sponsor-item-modern {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 0;
  margin-bottom: 16px;
  transition: all 0.3s ease;
  min-height: 100px;
}

.sponsor-item-modern:hover {
  background: rgba(255, 255, 255, 0.05);
  transform: translateX(5px);
}

.league-edit-page .sponsor-item-modern,
.league-stage-page .sponsor-item-modern {
  padding: 0;
}

/* ===== THUMBNAIL STYLES ===== */

.prize-item-thumb-wrapper {
  width: 100px;
  height: 100px;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
}

.sponsor-item-thumb-wrapper {
  width: 130px;
  height: 130px;
  flex-shrink: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
}

/* Override for league pages */
.league-edit-page .prize-item-thumb-wrapper,
.league-stage-page .prize-item-thumb-wrapper {
  width: 80px;
  height: 80px;
  border-radius: 8px;
}

.prize-item-thumb-wrapper.sponsor-thumb {
  width: 130px !important;
  height: 130px !important;
}

.prize-item-thumb,
.sponsor-item-thumb,
.prize-thumb,
.sponsor-thumb {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
  border: none;
}

/* ===== UPLOAD PLACEHOLDER STYLES ===== */

.prize-upload-placeholder {
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.03);
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.prize-upload-placeholder:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(255, 255, 255, 0.3);
}

.prize-upload-placeholder svg {
  width: 24px;
  height: 24px;
  opacity: 1;
  color: rgba(255, 255, 255, 0.7);
  display: block;
  margin: 0 auto;
}

.prize-upload-placeholder .placeholder-text {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  font-family: "DINBold", sans-serif;
  margin-top: 4px;
}

/* "NO IMAGE" text - same styling as UPLOAD text */
.text-upload-label-disabled {
  font-size: 10px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
  font-family: "DINBold", sans-serif;
  margin-top: 4px;
  display: block;
}

/* ===== THUMB CONTROLS (OVERLAY BUTTONS) ===== */

.prize-thumb-with-controls {
  position: relative;
  width: 100%;
  height: 100%;
}

.prize-thumb-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  opacity: 0;
  transition: opacity 0.3s ease;
  border-radius: inherit;
}

.prize-thumb-with-controls:hover .prize-thumb-overlay {
  opacity: 1;
}

.prize-thumb-controls {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.prize-thumb-with-controls:hover .prize-thumb-controls {
  opacity: 1;
}

.prize-thumb-controls svg,
.prize-thumb-overlay svg {
  color: #FFFFFF !important;
}

.change-btn,
.delete-btn {
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  padding: 8px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.change-btn:hover {
  background: rgba(0, 0, 0, 0.9);
  transform: scale(1.05);
}

.delete-btn:hover {
  background: rgba(245, 72, 77, 0.8);
  transform: scale(1.05);
}

/* ===== ITEM DETAILS STYLES ===== */

.prize-item-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.sponsor-item-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

.sponsor-item-fields {
  display: flex;
  width: 100%;
  gap: 0.5rem;
}

.sponsor-item-fields.desktop {
  flex-direction: row;
}

.sponsor-item-fields.mobile {
  flex-direction: column;
  gap: 0.15rem;
}

/* Mobile first - ensure columns are full width on mobile */
.prize-list-modern .ranking-column,
.prize-list-modern .description-column {
  width: 100%;
  max-width: 100%;
}

/* Desktop layout */
@media (min-width: 769px) {
  .prize-item-details.editable:not(.mobile) {
    display: flex;
    flex-direction: row;
    gap: 0.5rem;
    align-items: center;
  }

  /* Apply to both list view and edit mode */
  .prize-list-modern .ranking-column,
  .prize-item-details.editable .ranking-column {
    flex: 0 0 33.33%;
    max-width: 33.33%;
    width: 33.33%;
  }

  .prize-list-modern .description-column,
  .prize-item-details.editable .description-column {
    flex: 0 0 66.66%;
    max-width: 66.66%;
    width: 66.66%;
  }
}

/* ===== FORM INPUTS STYLES ===== */

.prize-rank-select {
  width: 100%;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: none !important;
  border-radius: 6px;
  color: #fff;
  font-size: 0.9rem;
  transition: all 0.3s ease;
}

.prize-rank-select:focus {
  background: rgba(255, 255, 255, 0.08);
  border: none !important;
  outline: none;
}

.prize-rank-select option {
  background: #1a1a1a;
  color: #fff;
}

.prize-rank-select option:disabled {
  color: rgba(255, 255, 255, 0.3);
  background-color: rgba(0, 0, 0, 0.3);
  font-style: italic;
}

.prize-desc-input,
.sponsor-name-input,
.sponsor-link-input {
  width: 100%;
  padding: 0.5rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: #fff;
  font-size: 0.9rem;
  resize: vertical;
  min-height: 38px;
  transition: all 0.3s ease;
}

.prize-desc-input:focus,
.sponsor-name-input:focus,
.sponsor-link-input:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
  outline: none;
}

.flex-1-min-0 {
  flex: 1;
  min-width: 0;
}

/* ===== DISPLAY TEXT STYLES ===== */

.prize-rank-title {
  color: #f5484d;
  font-family: "DINBold", sans-serif;
  font-size: 20px;
  margin-bottom: 4px;
}

.prize-description {
  color: rgba(255, 255, 255, 0.9);
  font-size: 14px;
  line-height: 1.4;
}

.sponsor-name-display {
  font-weight: 800;
  font-size: 16px;
  color: #f8f9fa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.sponsor-link-display {
  font-size: 14px;
  color: #007bff;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
  max-width: 100%;
  transition: color 0.3s ease;
}

.sponsor-link-display:hover {
  color: #0056b3;
  text-decoration: underline;
}

.sponsor-text-fade {
  position: relative;
  overflow: hidden;
  max-width: 100%;
}

.sponsor-text-fade::after {
  content: '';
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 30px;
  background: linear-gradient(to right, transparent, rgba(18, 18, 18, 0.95));
  pointer-events: none;
}

/* ===== ACTION BUTTONS STYLES ===== */

.prize-item-actions {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  margin-left: auto;
}

/* Mobile styles for action buttons */
@media (max-width: 768px) {
  .prize-item-actions {
    flex-direction: column;  /* Stack buttons vertically */
    padding-right: 0;
    margin-left: 0;
    margin-bottom: 0;
    gap: 2px;  /* Minimal gap between buttons */
    justify-content: center;  /* Center vertically */
  }
}

/* Desktop styles for action buttons */
@media (min-width: 769px) {
  .prize-item-actions {
    padding-right: 16px;
  }
}

.btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.7);
  padding: 8px 16px;
  height: 48px;  /* Match desktop input height */
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: fit-content;
}

.btn-icon:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  transform: translateY(-1px);
}

.btn-icon:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
}

/* Save button - Green theme */
.btn-icon.btn-save {
  background: rgba(40, 167, 69, 0.1);
  border: 1px solid rgba(40, 167, 69, 0.3);
  color: #28a745;
  font-weight: 500;
}

.btn-icon.btn-save:hover:not(:disabled) {
  background: rgba(40, 167, 69, 0.2);
  border-color: rgba(40, 167, 69, 0.4);
  color: #34ce57;
  box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

/* Cancel button - Red theme */
.btn-icon.btn-cancel {
  background: rgba(220, 53, 69, 0.1);
  border: 1px solid rgba(220, 53, 69, 0.3);
  color: #dc3545;
}

.btn-icon.btn-cancel:hover:not(:disabled) {
  background: rgba(220, 53, 69, 0.2);
  border-color: rgba(220, 53, 69, 0.4);
  color: #ff3847;
  transform: translateY(-1px);
}

/* X icon styling in action buttons */
.btn-icon.btn-cancel svg,
.btn-icon-danger svg {
  width: 28px !important;
  height: 28px !important;
  stroke-width: 1 !important;
}

/* Keep X cancel button at normal size (after save button) */
.prize-item-actions .btn-save + .btn-icon.btn-cancel svg {
  width: 28px !important;
  height: 28px !important;
}

/* Override trash icon size (after edit button) */
.prize-item-actions .btn-icon:not(.btn-save):not(.btn-cancel) + .btn-icon.btn-cancel svg {
  width: 16px !important;
  height: 16px !important;
}

/* Mobile overrides */
@media (max-width: 768px) {
  /* Ensure X stays 28px on mobile */
  .prize-item-actions .btn-save + .btn-icon.btn-cancel svg {
    width: 28px !important;
    height: 28px !important;
  }

  /* Ensure trash stays 16px on mobile */
  .prize-item-actions .btn-icon:not(.btn-save):not(.btn-cancel) + .btn-icon.btn-cancel svg {
    width: 16px !important;
    height: 16px !important;
  }
}

/* Icon button utilities */
.btn-icon-32 {
  width: 32px !important;
  height: 32px !important;
  padding: 0 !important;
  border-radius: 6px !important;
}

.btn-icon-bg {
  background-color: rgba(255, 255, 255, 0.05) !important;
  color: #f8f9fa !important;
}

.btn-icon-danger {
  background-color: rgba(220, 53, 69, 0.1) !important;
  color: #dc3545 !important;
}

.btn-icon-base {
  width: 32px !important;
  height: 32px !important;
  border-radius: 6px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  border: none !important;
}

/* ===== ADD BUTTON STYLES ===== */

.add-prize-button-wrapper {
  margin-bottom: 1rem;
  display: flex;
  justify-content: center;
  margin-top: 0;
}

.add-btn-modern {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 14px;
}

.add-btn-modern:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.add-btn-modern:disabled,
.add-btn-modern.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.add-btn-modern svg {
  width: 16px;
  height: 16px;
}

/* ===== DUAL BUTTON UPLOAD (Library Integration) ===== */

.prize-upload-dual-buttons {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
}

.prize-upload-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.prize-upload-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.3);
  color: #f8f9fa;
}

.prize-upload-btn.upload-btn:hover {
  border-color: rgba(255, 255, 255, 0.4);
}

.prize-upload-btn.library-btn {
  background: rgba(185, 255, 102, 0.05);
  border-color: rgba(185, 255, 102, 0.3);
  color: rgba(185, 255, 102, 0.8);
}

.prize-upload-btn.library-btn:hover {
  background: rgba(185, 255, 102, 0.1);
  border-color: rgba(185, 255, 102, 0.5);
  color: #b9ff66;
}

.prize-upload-btn svg {
  flex-shrink: 0;
}

.prize-upload-btn span {
  white-space: nowrap;
}

/* Mobile adjustments for dual buttons */
@media (max-width: 768px) {
  .prize-upload-dual-buttons {
    padding: 2px;
    gap: 2px;
  }

  .prize-upload-btn {
    font-size: 9px;
    gap: 4px;
  }

  .prize-upload-btn svg {
    width: 14px;
    height: 14px;
  }
}

/* ===== UTILITY STYLES ===== */

.icon-opacity-1 {
  opacity: 0.6;
}

.icon-opacity-3 {
  opacity: 0.3;
}

.text-muted {
  color: rgba(255, 255, 255, 0.6);
}

.text-center {
  text-align: center;
}

/* ===== MOBILE OPTIMIZATIONS ===== */

@media (max-width: 768px) {
  .prize-item-modern,
  .sponsor-item-modern {
    display: flex;
    flex-direction: row;  /* Keep horizontal on mobile */
    align-items: center;
    padding: 0;  /* No padding */
    height: 100px;  /* Fixed height */
    min-height: 100px;
    max-height: 100px;
    gap: 0.5rem;
  }

  /* Remove all margins from direct children */
  .prize-item-modern > *,
  .sponsor-item-modern > * {
    margin-bottom: 0 !important;
  }

  .prize-item-thumb-wrapper,
  .sponsor-item-thumb-wrapper {
    flex-shrink: 0;
    width: 100px;
    height: 100px;
    margin-bottom: 0;
    align-self: center;
  }

  .prize-item-details {
    flex: 1;
    width: auto;
    margin-bottom: 0;
  }

  .sponsor-item-details {
    flex: 1;
    width: auto;
    margin-bottom: 0;
    height: 100px;  /* Exact height for sponsor container */
    display: flex;
    flex-direction: column;
    padding: 0;
  }

  /* Fix sponsor fields to fit within 100px with gaps */
  .sponsor-item-fields.mobile {
    height: 100%;  /* Fill parent container */
    display: flex;
    flex-direction: column;
    gap: 2px;  /* Small gap between fields */
    padding: 0;
    margin: 0;
    justify-content: center;  /* Center vertically */
  }

  .sponsor-item-fields.mobile input,
  .sponsor-item-fields.mobile .sponsor-name-input,
  .sponsor-item-fields.mobile .sponsor-link-input {
    height: 32px;  /* Fixed height for each field */
    min-height: 32px;
    max-height: 32px;
    margin: 0;
    padding: 4px 8px;
    box-sizing: border-box;  /* Include padding in height */
  }

  /* Prize inputs mobile - optimal height (only for prizes, not sponsors) */
  .prize-item-modern .prize-item-details.mobile .prize-desc-input,
  .prize-item-modern .prize-item-details.mobile .prize-rank-select {
    height: 46px !important;
    min-height: 46px;
    max-height: 46px;
  }

  /* Sponsor inputs mobile - ensure 32px height */
  .sponsor-item-modern .prize-item-details.mobile input,
  .sponsors-editor .prize-item-details.mobile input {
    height: 32px !important;
    min-height: 32px !important;
    max-height: 32px !important;
  }

  .prize-item-actions {
    flex-shrink: 0;
    margin-bottom: 0;
    height: 100px;  /* Full container height */
    width: 50px;  /* Fixed width for square buttons */
    display: flex;
    flex-direction: column;  /* Stack vertically */
    gap: 0;  /* No gap between buttons */
  }

  .prize-item-actions .btn-icon {
    width: 50px !important;  /* Square dimensions */
    height: 50px !important;  /* Square dimensions */
    min-width: 50px;
    min-height: 50px;
    max-width: 50px;
    max-height: 50px;
    padding: 0;  /* No padding */
    margin: 0;  /* No margins */
    font-size: 12px;  /* Smaller font on mobile */
    border-radius: 0;  /* Remove border radius for seamless stacking */
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
  }

  .btn-icon:first-child {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
  }

  .btn-icon:last-child {
    border-bottom-left-radius: 6px;
    border-bottom-right-radius: 6px;
  }
}

/* ===== DARK MODE SUPPORT ===== */

/* Removed - was overriding save/cancel button colors
body.dark-mode-active .btn-icon {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.8);
}
*/

body.dark-mode-active .prize-desc-input,
body.dark-mode-active .prize-rank-select,
body.dark-mode-active .sponsor-name-input,
body.dark-mode-active .sponsor-link-input {
  background: rgba(255, 255, 255, 0.05);
  color: #f8f9fa;
}

/* ===== SPECIAL CAROUSEL PANEL FIX ===== */

.carousel-panel:has(.prize-list-modern),
.carousel-panel:has(.sponsor-list-modern) {
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch;
  max-height: calc(100vh - 250px);
}

/* ===== ANIMATION STATES ===== */

.item-entering {
  animation: slideIn 0.3s ease forwards;
}

.item-leaving {
  animation: slideOut 0.3s ease forwards;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes slideOut {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ===== INLINE EDITABLE FIELDS (alwaysEditable support) ===== */

.inline-editable-field {
  display: flex;
  align-items: center;
}

.inline-editable-select {
  background: rgba(33, 37, 41, 0.9);
  border: none;
  border-radius: 6px;
  color: #f8f9fa;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  min-width: 140px;
  height: 40px !important;
  transition: all 0.2s ease;
  font-family: "DINBold", sans-serif;
}

.inline-editable-select:hover {
  background: rgba(33, 37, 41, 1);
}

.inline-editable-select:focus {
  outline: none;
  border: none;
  box-shadow: 0 0 0 2px rgba(185, 255, 102, 0.3);
}

.inline-editable-select option {
  background: #212529;
  color: #f8f9fa;
  padding: 8px;
}

.inline-editable-select:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Mobile adjustments for inline editable */
@media (max-width: 768px) {
  .inline-editable-select {
    padding: 6px 10px;
    font-size: 13px;
    min-width: 120px;
    height: 36px;
  }
}

/* ===== PRIZE ROW LAYOUT: Description top, Rank bottom ===== */

/* Ensure prize details stack vertically */
.prize-item-details {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  justify-content: center;
}

/* Description field on top */
.prize-item-details .prize-description {
  order: 1;
  font-size: 16px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.9);
  line-height: 1.4;
}

/* Rank dropdown below */
.prize-item-details .inline-editable-field {
  order: 2;
}

/* Empty image placeholder - minimal style */
.prize-item-thumb-empty {
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.03);
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
}