/**
 * WooCommerce Dynamic Pricing - Frontend Styles
 * 
 * @package WC_Dynamic_Pricing
 */

/* Main Interface Container */
.wcdp-pricing-interface {
  margin: 15px 0;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Field Groups */
.wcdp-field-group {
  margin-bottom: 12px;
}

.wcdp-field-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  color: #333;
  font-size: 14px;
}

/* Select Dropdown */
.wcdp-select {
  width: 100%;
  max-width: 300px;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  background-color: #fff;
  transition: border-color 0.3s ease;
  cursor: pointer;
}

.wcdp-select:hover {
  border-color: #bbb;
}

.wcdp-select:focus {
  outline: none;
  border-color: #0073aa;
  box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

/* Delivery Options */
.wcdp-delivery-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 15px;
  max-width: 600px;
}

.wcdp-delivery-option {
  position: relative;
}

.wcdp-delivery-radio {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.wcdp-delivery-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  background: #fff;
  border: 2px solid #e0e0e0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  min-height: 120px;
  justify-content: center;
}

.wcdp-delivery-label:hover {
  border-color: #0073aa;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 115, 170, 0.15);
}

.wcdp-delivery-radio:checked + .wcdp-delivery-label {
  border-color: #0073aa;
  background: #f0f8ff;
  box-shadow: 0 4px 12px rgba(0, 115, 170, 0.15);
}

.wcdp-delivery-radio:focus + .wcdp-delivery-label {
  outline: 2px solid #0073aa;
  outline-offset: 2px;
}

.wcdp-delivery-date {
  font-weight: 700;
  font-size: 17px;
  color: #333;
  margin-bottom: 5px;
}

.wcdp-delivery-day {
  color: #666;
  font-size: 14px;
  margin-bottom: 8px;
}

.wcdp-delivery-days {
  color: #0073aa;
  font-size: 13px;
  font-weight: 500;
}

/* Price Display */
.wcdp-price-display {
  background: #fff;
  padding: 25px;
  border-radius: 10px;
  margin-top: 25px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  animation: slideIn 0.3s ease;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.wcdp-price-header h3 {
  margin: 0 0 20px 0;
  color: #333;
  font-size: 20px;
  font-weight: 600;
}

.wcdp-price-details {
  margin-bottom: 20px;
}

.wcdp-price-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid #f0f0f0;
}

.wcdp-price-row:last-child {
  border-bottom: none;
}

.wcdp-price-label {
  color: #666;
  font-size: 15px;
}

.wcdp-price-value {
  font-weight: 600;
  font-size: 18px;
  color: #333;
}

.wcdp-total-price {
  padding-top: 15px;
  margin-top: 15px;
  border-top: 2px solid #f0f0f0;
}

.wcdp-total-price .wcdp-price-value {
  font-size: 26px;
  color: #0073aa;
}

.wcdp-savings {
  background: #f0f9f0;
  padding: 15px;
  border-radius: 6px;
  margin-top: 15px;
}

.wcdp-savings .wcdp-price-value {
  color: #4caf50;
}

.wcdp-discount-badge {
  background: #4caf50;
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 14px;
  font-weight: 600;
  margin-left: 10px;
}

/* Delivery Info */
.wcdp-delivery-info {
  display: flex;
  align-items: center;
  padding: 15px;
  background: #f8f9fa;
  border-radius: 6px;
  margin-top: 20px;
  color: #666;
  font-size: 15px;
}

.wcdp-delivery-info .dashicons {
  font-size: 20px;
  width: 20px;
  height: 20px;
  margin-right: 10px;
  color: #0073aa;
}

.wcdp-delivery-info strong {
  color: #333;
  margin-left: 5px;
}

/* Loading State */
.wcdp-loading {
  text-align: center;
  padding: 30px;
  color: #666;
}

.wcdp-loading .spinner {
  float: none;
  margin: 0 auto 15px;
  visibility: visible;
}

/* Custom Price Display */
.wcdp-custom-price del {
  opacity: 0.5;
  font-size: 0.9em;
}

.wcdp-custom-price ins {
  text-decoration: none;
  font-weight: 700;
  color: #0073aa;
}

/* Compact Pricing Table Matrix Styles */
.wcdp-pricing-table-container {
    margin: 12px 0;
}

.wcdp-pricing-table-container h3 {
    margin-bottom: 8px;
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.wcdp-pricing-table-wrapper {
    overflow-x: auto;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    background: #fff;
}

.wcdp-pricing-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    min-width: 500px;
}

.wcdp-pricing-table th,
.wcdp-pricing-table td {
    border: 1px solid #e0e0e0;
    text-align: center;
    position: relative;
    padding: 6px 8px;
}

/* Header Styles */
.wcdp-pricing-table th {
    background: #f8f9fa;
    padding: 8px 6px;
    font-weight: 600;
    color: #333;
    font-size: 11px;
}

.wcdp-quantity-header {
    background: #fff !important;
    border: none !important;
    font-size: 12px;
    width: 80px;
    padding: 8px 4px !important;
}

.wcdp-delivery-header {
    min-width: 90px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 6px 4px !important;
}

.wcdp-delivery-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.wcdp-delivery-day {
    font-size: 10px;
    text-transform: lowercase;
    opacity: 0.9;
}

.wcdp-delivery-date {
    font-size: 11px;
    font-weight: bold;
}

/* Quantity Cell Styles */
.wcdp-quantity-cell {
    padding: 8px 6px !important;
    background: #f8f9fa;
    font-size: 12px;
    font-weight: 600;
    color: #333;
    border-right: 2px solid #dee2e6;
}

/* Price Cell Styles */
.wcdp-price-cell {
    padding: 6px 4px !important;
    cursor: pointer;
    transition: background 0.2s ease;
    background: #fff;
    position: relative;
    min-height: 50px;
    vertical-align: middle;
}

.wcdp-price-cell:hover {
    background: #f0f8ff;
}

.wcdp-price-cell.selected {
    background: #fff3cd;
    border: 2px solid #ffc107;
    box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.3);
    z-index: 5;
}

.wcdp-price-cell.selected:hover {
    background: #fff3cd;
}

.wcdp-cell-content {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 40px;
}

/* Discount Badge */
.wcdp-discount-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #dc3545;
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
    z-index: 10;
}

.wcdp-discount-badge.discount-5 { background: #28a745; }
.wcdp-discount-badge.discount-10 { background: #fd7e14; }
.wcdp-discount-badge.discount-15 { background: #dc3545; }
.wcdp-discount-badge.discount-20 { background: #6f42c1; }

/* Pricing Display */
.wcdp-pricing {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.wcdp-final-price {
    font-size: 12px;
    font-weight: bold;
    color: #28a745;
}

.wcdp-price-cell.no-discount .wcdp-final-price {
    color: #333;
}

/* Loading State */
.wcdp-loading-cell {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.wcdp-loading-cell .spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Selection Summary */
.wcdp-selection-summary {
    margin-top: 10px;
    padding: 10px;
    background: #e8f5e8;
    border-radius: 4px;
    border: 1px solid #28a745;
    font-size: 13px;
}

.wcdp-pagination-controls {
    margin-top: 12px;
    padding: 12px;
    background: #fff;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.wcdp-pagination-buttons {
    display: flex;
    align-items: center;
    gap: 4px;
}

.wcdp-pagination-button {
    min-width: 38px;
    padding: 8px 12px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 500;
    color: #333;
}

.wcdp-pagination-button:hover:not(.disabled) {
    background: #f8f9fa;
    border-color: #0073aa;
    color: #0073aa;
}

.wcdp-pagination-button.active {
    background: #0073aa;
    color: white;
    border-color: #0073aa;
    font-weight: 600;
}

.wcdp-pagination-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: #f5f5f5;
}

.wcdp-pagination-prev,
.wcdp-pagination-next {
    font-weight: bold;
}

.wcdp-pagination-ellipsis {
    padding: 8px 8px;
    color: #666;
    display: inline-block;
    line-height: 1.5;
}

.wcdp-pagination-info {
    color: #666;
    font-size: 12px;
    font-weight: 500;
    padding: 4px 8px;
    background: #f8f9fa;
    border-radius: 4px;
}

.wcdp-selected-quantity::before {
    content: "📦 ";
}

.wcdp-selected-delivery::before {
    content: "📅 ";
}

.wcdp-selected-price::before {
    content: "💰 ";
}

/* Responsive Design */
@media (max-width: 768px) {
  .wcdp-pricing-interface {
    padding: 20px;
    margin: 20px -10px;
    border-radius: 0;
  }

  .wcdp-delivery-options {
    grid-template-columns: 1fr;
    max-width: 100%;
  }

  .wcdp-delivery-label {
    flex-direction: row;
    justify-content: space-between;
    min-height: auto;
    padding: 15px;
  }

  .wcdp-delivery-date,
  .wcdp-delivery-day,
  .wcdp-delivery-days {
    margin: 0 5px;
  }

  .wcdp-price-display {
    padding: 20px;
  }

  .wcdp-total-price .wcdp-price-value {
    font-size: 22px;
  }

  .wcdp-select {
    max-width: 100%;
  }

    .wcdp-pricing-table-wrapper {
        overflow-x: scroll;
        -webkit-overflow-scrolling: touch;
    }
    
    .wcdp-pricing-table {
        min-width: 500px;
    }
    
    .wcdp-delivery-header {
        min-width: 85px;
    }
    
    .wcdp-quantity-cell {
        width: 70px;
        padding: 6px 4px;
    }
    
    .wcdp-price-cell {
        min-height: 45px;
    }
    
    .wcdp-selected-info {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
}

@media (max-width: 480px) {
  .wcdp-field-group label {
    font-size: 15px;
  }

  .wcdp-price-header h3 {
    font-size: 18px;
  }

  .wcdp-price-row {
    flex-direction: column;
    align-items: flex-start;
    padding: 10px 0;
  }

  .wcdp-price-value {
    margin-top: 5px;
  }
}

/* Integration with Themes */
.single-product .wcdp-pricing-interface {
  clear: both;
}

/* Elementor Compatibility */
.elementor-widget-woocommerce-product-add-to-cart .wcdp-pricing-interface {
  margin: 20px 0;
}

/* Animation Effects */
.wcdp-price-display,
.wcdp-savings {
  transition: all 0.3s ease;
}

.wcdp-price-value {
  transition: color 0.3s ease;
}

/* Accessibility */
.wcdp-pricing-interface:focus-within {
  outline: 2px solid #0073aa;
  outline-offset: 2px;
}

.screen-reader-text {
  position: absolute;
  left: -9999px;
}

/* Print Styles */
@media print {
  .wcdp-pricing-interface {
    background: none;
    border: 1px solid #ddd;
    box-shadow: none;
  }

  .wcdp-delivery-label {
    border: 1px solid #333;
  }

  .wcdp-loading {
    display: none;
  }
}

/* High contrast for better accessibility */
@media (prefers-contrast: high) {
    .wcdp-price-cell {
        border: 2px solid #000;
    }
    
    .wcdp-price-cell.selected {
        border: 3px solid #000;
        background: #ffff00;
    }
    
    .wcdp-discount-badge {
        border: 1px solid #000;
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .wcdp-price-cell {
        transition: none;
    }
    
    .wcdp-price-cell:hover {
        transform: none;
    }
    
    .wcdp-loading-cell .spinner {
        animation: none;
    }
}
