/**
 * Frontend Styles for WooCommerce Image Personalizer
 */

/* Modal styling */
.x2wcpip-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 999999;
}

.x2wcpip-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
}

.x2wcpip-modal-content {
  position: relative;
  max-width: 1200px !important;
  max-height: 95vh !important;
  margin: 2.5vh auto !important;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.x2wcpip-modal-header {
  padding: 20px 30px;
  background: #f7f7f7;
  border-bottom: 1px solid #ddd;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.x2wcpip-modal-header h2 {
  margin: 0;
  font-size: 24px;
}

.x2wcpip-modal-close {
  background: none;
  border: none;
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 32px;
  height: 32px;
}

.x2wcpip-modal-close:hover {
  color: #000;
}

.x2wcpip-modal-body {
  padding: 30px;
  overflow-y: auto;
  flex: 1;
  min-height: 600px !important;
}

.x2wcpip-modal-footer {
  padding: 20px 30px;
  background: #f7f7f7;
  border-top: 1px solid #ddd;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

body.x2wcpip-modal-open {
  overflow: hidden;
}

/* Personalize button */
.x2wcpip-personalize-wrapper {
  margin: 15px 0;
}

.x2wcpip-personalize-btn {
  background: #0071a1;
  color: #fff;
  border: none;
  padding: 12px 24px;
  font-size: 16px;
  border-radius: 4px;
  cursor: pointer;
}

.x2wcpip-personalize-btn:hover {
  background: #005177;
}

/* Image slots */
.x2wcpip-image-slots-section {
  margin-bottom: 30px;
}

.x2wcpip-image-slots-section h3 {
  margin-top: 0;
  margin-bottom: 20px;
}

.x2wcpip-image-slot {
  margin-bottom: 20px;
  padding: 15px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fafafa;
}

.x2wcpip-image-slot label {
  display: block;
  font-weight: bold;
  margin-bottom: 10px;
}

.x2wcpip-image-preview {
  width: 200px;
  height: 200px;
  border: 2px dashed #ddd;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  background: #fff;
}

.x2wcpip-image-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.x2wcpip-no-image {
  color: #999;
  text-align: center;
}

.x2wcpip-select-image-btn,
.x2wcpip-remove-image-btn {
  margin-right: 5px;
}

/* Text slots */
.x2wcpip-text-slots-section {
  margin-bottom: 30px;
}

.x2wcpip-text-slots-section h3 {
  margin-top: 0;
  margin-bottom: 20px;
}

.x2wcpip-text-slot {
  margin-bottom: 15px;
}

.x2wcpip-text-slot label {
  display: block;
  font-weight: bold;
  margin-bottom: 5px;
}

.x2wcpip-text-input,
.x2wcpip-font-select {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  margin-bottom: 10px;
}

/* Image library */
.x2wcpip-image-library {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  padding: 20px;
  overflow-y: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.x2wcpip-library-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.x2wcpip-library-header h3 {
  margin: 0;
}

.x2wcpip-library-search {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.x2wcpip-search-input {
  flex: 1;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.x2wcpip-category-filter {
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  min-width: 150px;
}

.x2wcpip-library-results {
  flex: 1;
  overflow-y: auto;
}

.x2wcpip-loading {
  text-align: center;
  padding: 40px;
  color: #666;
}

.x2wcpip-images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 15px;
  margin-bottom: 20px;
}

.x2wcpip-library-image {
  cursor: pointer;
  border: 2px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.2s;
  background: #fff;
  display: flex;
  flex-direction: column;
}

.x2wcpip-library-image:hover {
  border-color: #0071a1;
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.x2wcpip-library-image img {
  width: 100% !important;
  height: 150px !important;
  object-fit: contain !important;
  display: block !important;
  padding: 5px !important;
  background: #fff !important;
}

.x2wcpip-image-title {
  padding: 8px;
  background: #f7f7f7;
  font-size: 12px;
  text-align: center;
  word-wrap: break-word;
}

.x2wcpip-pagination {
  display: flex;
  gap: 5px;
  justify-content: center;
  padding: 20px 0;
}

.x2wcpip-pagination a {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  text-decoration: none;
  color: #333;
}

.x2wcpip-pagination a:hover,
.x2wcpip-pagination a.current {
  background: #0071a1;
  color: #fff;
  border-color: #0071a1;
}

/* Responsive */
@media (max-width: 768px) {
  .x2wcpip-modal-content {
    max-width: 95%;
    margin: 2vh auto;
    max-height: 96vh;
  }

  .x2wcpip-images-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }

  .x2wcpip-library-search {
    flex-direction: column;
  }

  .x2wcpip-image-preview {
    width: 150px;
    height: 150px;
  }
}
