/* ================================================================
   TEMPLATE LIBRARY STYLES
   3-panel slide navigation for Sponsor/Prize templates
   ================================================================ */

/* ----------------------------------------------------------------
   MODAL BASE STYLES
   ---------------------------------------------------------------- */

.template-library-modal .modal-content {
  background: #212529;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  overflow: hidden;
}

.template-library-modal .modal-dialog {
  max-width: 900px;
}

/* Header */
.template-library-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(33, 37, 41, 0.95);
}

.template-library-header .modal-title {
  flex: 1;
  color: #f8f9fa;
  font-size: 18px;
  font-family: "DINBold", sans-serif;
  margin: 0;
}

.template-library-header .btn-header-back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 8px;
  color: #f8f9fa;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-library-header .btn-header-back:hover {
  background: rgba(255, 255, 255, 0.2);
}

.template-library-header .btn-header-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  color: #f8f9fa;
  font-size: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-library-header .btn-header-close:hover {
  color: #ff6b6b;
}

/* Body */
.template-library-body {
  padding: 0;
  min-height: 400px;
  max-height: 70vh;
  overflow: hidden;
}

/* Footer */
.template-library-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(33, 37, 41, 0.95);
}

.template-library-footer .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Edit button - Rumble violet */
/* Target both legacy .template-library-footer and PickerShell .picker-shell-footer */
.template-library-footer .btn-edit,
.template-library-modal .picker-shell-footer .btn-edit,
.picker-shell-footer .btn-edit {
  background-color: #9747ff;
  border-color: #9747ff;
  color: #fff;
}

.template-library-footer .btn-edit:hover,
.template-library-modal .picker-shell-footer .btn-edit:hover,
.picker-shell-footer .btn-edit:hover {
  background-color: #8035e0;
  border-color: #8035e0;
  color: #fff;
}

/* Use Template button - Rumble green */
.template-library-footer .btn-use-template,
.template-library-modal .picker-shell-footer .btn-use-template,
.picker-shell-footer .btn-use-template {
  background-color: #b9ff66;
  border-color: #b9ff66;
  color: #212529;
  font-weight: 600;
}

.template-library-footer .btn-use-template:hover,
.template-library-modal .picker-shell-footer .btn-use-template:hover,
.picker-shell-footer .btn-use-template:hover {
  background-color: #a8e85c;
  border-color: #a8e85c;
  color: #212529;
}

/* Save button - Rumble green */
.template-library-modal .picker-shell-footer .btn-save,
.picker-shell-footer .btn-save {
  background-color: #b9ff66;
  border-color: #b9ff66;
  color: #212529;
  font-weight: 600;
}

.template-library-modal .picker-shell-footer .btn-save:hover,
.picker-shell-footer .btn-save:hover {
  background-color: #a8e85c;
  border-color: #a8e85c;
  color: #212529;
}

/* Cancel/Close button - Match MediaPicker style */
.template-library-modal .picker-shell-footer .btn-cancel,
.picker-shell-footer .btn-cancel {
  background-color: transparent;
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #f8f9fa;
}

.template-library-modal .picker-shell-footer .btn-cancel:hover,
.picker-shell-footer .btn-cancel:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
}

/* Footer layout - left/right sections */
.picker-shell-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.picker-shell-footer .footer-left,
.picker-shell-footer .footer-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.picker-shell-footer .footer-left {
  margin-right: auto;
}

/* ----------------------------------------------------------------
   3-PANEL SLIDE SYSTEM
   ---------------------------------------------------------------- */

.template-slide-container {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Wrapper moves horizontally - 300% width for 3 panels */
.template-slide-wrapper {
  display: flex;
  width: 300%;
  height: 100%;
  transition: transform 0.3s ease-in-out;
}

/* Transform states for 3 panels */
.template-slide-wrapper.view-list {
  transform: translateX(0);
}

.template-slide-wrapper.view-edit {
  transform: translateX(-33.33%);
}

.template-slide-wrapper.view-media {
  transform: translateX(-66.66%);
}

/* Each panel takes 33.33% of wrapper (100% of visible container) */
.template-slide-panel {
  width: 33.33%;
  flex-shrink: 0;
  overflow-y: auto;
}

.template-slide-panel.list-panel {
  padding: 20px;
}

.template-slide-panel.edit-panel {
  padding: 20px;
}

.template-slide-panel.media-panel {
  display: flex;
  flex-direction: column;
}

/* ----------------------------------------------------------------
   TEMPLATE GRID
   ---------------------------------------------------------------- */

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}

.template-grid-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 16px;
}

.template-grid-loading span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

.template-grid-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.1);
  border-top-color: #b9ff66;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.template-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: rgba(255, 255, 255, 0.5);
}

/* ----------------------------------------------------------------
   TEMPLATE CARD
   ---------------------------------------------------------------- */

.template-card {
  position: relative;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.2s ease;
}

.template-card:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-2px);
}

.template-card:focus {
  outline: none;
  border-color: #b9ff66;
}

.template-card.selected {
  border-color: #b9ff66;
  background: rgba(185, 255, 102, 0.1);
}

/* Selection Checkbox - matches MediaPicker pattern */
.template-card-checkbox {
  position: absolute;
  top: 8px;
  right: 8px;  /* Top-right position like MediaPicker */
  width: 24px;
  height: 24px;
  border-radius: 50%;  /* Circle shape */
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid #6c757d;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;  /* Hidden by default */
  transition: opacity 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
  z-index: 3;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Show on card hover */
.template-card:hover .template-card-checkbox {
  opacity: 1;
}

/* Always visible when selection mode active */
.template-card-checkbox.always-visible {
  opacity: 1;
}

/* Checked state */
.template-card-checkbox.checked {
  background: #B9FF66;
  border-color: #B9FF66;
  color: #212529;
  opacity: 1;
}

.template-card.selected .template-card-checkbox {
  background: #B9FF66;
  border-color: #B9FF66;
  color: #212529;
}

.template-card-checkbox svg {
  width: 12px;
  height: 12px;
}

/* Card Image */
.template-card-image {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.template-card-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.template-card-no-image {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: rgba(255, 255, 255, 0.3);
  font-size: 32px;
}

.template-card-selected-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  background: #b9ff66;
  color: #212529;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  border-radius: 4px;
}

/* Card Content */
.template-card-content {
  padding: 12px;
}

.template-card-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0 0 4px 0;
  font-size: 14px;
  font-weight: 600;
  color: #f8f9fa;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-card-title .rank-icon {
  color: #ffd700;
  font-size: 12px;
}

.template-card-meta {
  display: flex;
  gap: 8px;
}

.template-card-link {
  color: rgba(255, 255, 255, 0.5);
  font-size: 14px;
}

.template-card-link:hover {
  color: #b9ff66;
}

.template-card-description {
  margin: 0;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Add New Card */
.template-card-add {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 180px;
  border-style: dashed;
  border-color: rgba(255, 255, 255, 0.2);
}

.template-card-add:hover {
  border-color: #b9ff66;
  background: rgba(185, 255, 102, 0.05);
}

.template-card-add-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: rgba(255, 255, 255, 0.5);
}

.template-card-add-content .add-icon {
  font-size: 24px;
}

.template-card-add:hover .template-card-add-content {
  color: #b9ff66;
}

/* ----------------------------------------------------------------
   EDIT FORM
   ---------------------------------------------------------------- */

.template-edit-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Image Section */
.template-edit-image-section {
  display: flex;
  justify-content: center;
}

.template-edit-image {
  width: 150px;
  height: 150px;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  transition: all 0.2s ease;
}

.template-edit-image:hover {
  border-color: #b9ff66;
}

.template-edit-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.template-edit-no-image {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 8px;
  color: rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.2);
}

.template-edit-no-image svg {
  font-size: 32px;
}

.template-edit-no-image span {
  font-size: 12px;
}

/* Form Fields */
.template-edit-fields {
  display: flex;
  flex-direction: column;
}

.template-edit-fields .form-label {
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  margin-bottom: 6px;
}

.template-edit-fields .form-control,
.template-edit-fields .form-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #f8f9fa;
  border-radius: 6px;
}

.template-edit-fields .form-control:focus,
.template-edit-fields .form-select:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: #b9ff66;
  box-shadow: 0 0 0 2px rgba(185, 255, 102, 0.2);
  color: #f8f9fa;
}

.template-edit-fields .form-control::placeholder {
  color: rgba(255, 255, 255, 0.4);
}

.template-edit-fields textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

/* ----------------------------------------------------------------
   MEDIA PICKER INTEGRATION
   ---------------------------------------------------------------- */

.template-slide-panel.media-panel .media-picker-content-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ----------------------------------------------------------------
   MOBILE RESPONSIVE
   ---------------------------------------------------------------- */

@media (max-width: 767px) {
  .template-library-modal .modal-dialog {
    margin: 10px;
    max-width: calc(100% - 20px);
  }

  .template-library-body {
    min-height: 350px;
    max-height: 65vh;
  }

  .template-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .template-card-add {
    min-height: 140px;
  }

  .template-edit-image {
    width: 120px;
    height: 120px;
  }

  .template-slide-panel.list-panel,
  .template-slide-panel.edit-panel {
    padding: 16px;
  }

  .template-library-footer {
    flex-wrap: wrap;
    gap: 8px;
  }

  .template-library-footer .btn {
    flex: 1;
    min-width: 100px;
  }

  .template-library-footer .btn-outline-danger {
    flex: 0 0 auto;
  }
}

/* ----------------------------------------------------------------
   BULK ACTIONS (MediaPicker Pattern)
   ---------------------------------------------------------------- */

.template-library-bulk-actions {
  display: flex;
  gap: 8px;
  margin-left: 12px;
}

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

.template-library-bulk-actions .btn-link:hover {
  text-decoration: underline;
  color: #B9FF66;
}

/* ----------------------------------------------------------------
   SELECTION COUNT
   ---------------------------------------------------------------- */

.selection-count {
  font-size: 13px;
  color: #aaa;
}

/* ----------------------------------------------------------------
   FOOTER LEFT LAYOUT
   ---------------------------------------------------------------- */

.footer-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* ----------------------------------------------------------------
   PICKER ACTIVE STATE
   ---------------------------------------------------------------- */

.template-library-modal.picker-active .template-library-footer {
  display: none;
}
