/**
 * Assistify AI Editor Styles.
 *
 * @package Assistify_For_WooCommerce
 * @since   1.0.0
 */

/* ==========================================================================
   Block Editor Sidebar Panel (React)
   ========================================================================== */

.assistify-generate-btn {
  width: 100%;
  justify-content: center;
}

.assistify-generate-btn .components-spinner {
  margin-right: 8px;
}

/* ==========================================================================
   Sidebar Meta Box (Classic Editor / WooCommerce)
   ========================================================================== */

.assistify-sidebar-panel .description {
  color: #757575;
  font-size: 12px;
}

.assistify-sidebar-panel p > .button {
  margin-bottom: 0;
}

/* Instructions panel - hidden by default */
#assistify-instructions {
  display: none;
  margin: 12px 0;
  padding: 12px;
  background: #f0f0f1;
  border-left: 4px solid #2271b1;
}

#assistify-instructions p:first-child {
  margin-top: 0;
}

#assistify-instructions p:last-child {
  margin-bottom: 0;
}

/* Preview panel - hidden by default */
#assistify-preview {
  display: none;
  margin: 12px 0;
  padding: 12px;
  background: #f0f6fc;
  border-left: 4px solid #2271b1;
}

#assistify-preview p:first-child {
  margin-top: 0;
}

#assistify-preview p:last-child {
  margin-bottom: 0;
}

/* Options container - scrollable */
#assistify-options {
  max-height: 300px;
  overflow-y: auto;
}

/* Loading - hidden by default */
#assistify-loading {
  display: none;
  margin: 12px 0;
}

#assistify-loading .spinner {
  float: none;
}

/* Individual option */
.assistify-option {
  margin-bottom: 10px;
  padding: 10px;
  background: #fff;
  border: 1px solid #c3c4c7;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1.5;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.assistify-option:hover {
  border-color: #2271b1;
  background: #f0f6fc;
}

/* Option buttons row */
.assistify-option-buttons {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid #e0e0e0;
}

.assistify-option-buttons .button {
  margin-right: 5px;
}

/* ==========================================================================
   Image Generation Buttons (Product Image & Gallery)
   ========================================================================== */

/* Product image button */
#postimagediv .assistify-featured-image-btn {
  margin-top: 5px;
}

/* Product gallery button */
#woocommerce-product-images .assistify-gallery-btn {
  margin-top: 5px;
}

/* ==========================================================================
   Image Generation Modal
   ========================================================================== */

.assistify-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.assistify-modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.assistify-modal-content {
  position: relative;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.assistify-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #ddd;
  background: #f6f7f7;
}

.assistify-modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #1d2327;
}

.assistify-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #666;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.2s;
}

.assistify-modal-close:hover {
  background: #ddd;
  color: #1d2327;
}

.assistify-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.assistify-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid #ddd;
  background: #f6f7f7;
}

/* Image form */
.assistify-image-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.assistify-form-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.assistify-form-row label {
  font-weight: 600;
  font-size: 13px;
  color: #1d2327;
}

.assistify-form-row textarea,
.assistify-form-row select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #8c8f94;
  border-radius: 4px;
  font-size: 14px;
}

.assistify-form-row textarea:focus,
.assistify-form-row select:focus {
  border-color: #2271b1;
  box-shadow: 0 0 0 1px #2271b1;
  outline: none;
}

.assistify-form-row-inline {
  flex-direction: row;
  gap: 12px;
}

.assistify-form-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Loading state */
.assistify-image-loading {
  text-align: center;
  padding: 40px 20px;
}

.assistify-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid #ddd;
  border-top-color: #2271b1;
  border-radius: 50%;
  animation: assistify-spin 1s linear infinite;
  margin: 0 auto 16px;
}

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

.assistify-image-loading p {
  color: #666;
  font-size: 14px;
  margin: 0;
}

/* Image preview */
.assistify-image-preview {
  padding: 10px 0;
}

#assistify-generated-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 15px;
  margin-bottom: 16px;
}

.assistify-image-item {
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
  background: #f9f9f9;
}

.assistify-image-item img {
  width: 100%;
  height: 150px;
  object-fit: cover;
  display: block;
}

.assistify-image-actions {
  padding: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.assistify-image-actions .button {
  font-size: 11px;
  padding: 2px 8px;
  min-height: 24px;
}

.assistify-image-success {
  background: #d4edda;
  color: #155724;
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  grid-column: 1 / -1;
}

.assistify-image-success .dashicons {
  color: #28a745;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media screen and (max-width: 782px) {
  .assistify-sidebar-panel p > .button {
    width: 100%;
  }

  .assistify-modal-content {
    width: 95%;
    max-height: 95vh;
  }

  .assistify-form-row-inline {
    flex-direction: column;
  }

  #assistify-generated-images {
    grid-template-columns: repeat(2, 1fr);
  }
}
