/**
 * TeaTime Frontend Tier Pricing Styles
 * Stili per il sistema di tier pricing TeaTime
 * 
 * @version 1.0.0
 */

/* =============================================================================
   PRODUCT STATUS ICONS (ADMIN TABLE)
   ============================================================================= */

/* Icona WC base */
.wc-icon, 
[class*="wc-status"] {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    position: relative;
    transition: all 0.3s ease;
}

/* Stato: Prodotto caricato/sincronizzato */
.wc-synced,
.wc-icon.synced,
td:has(.fa-cart-shopping) {
    background: linear-gradient(135deg, #4caf50, #45a049);
    color: white;
}

.wc-synced::after,
.wc-icon.synced::after {
    content: "✓";
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: #4caf50;
    color: white;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* Stato: Non sincronizzato/In attesa */
.wc-pending,
.wc-icon.pending {
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: white;
    animation: pulse-pending 2s infinite;
}

@keyframes pulse-pending {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* Stato: Errore */
.wc-error,
.wc-icon.error {
    background: linear-gradient(135deg, #f44336, #d32f2f);
    color: white;
}

.wc-error::after,
.wc-icon.error::after {
    content: "!";
    position: absolute;
    bottom: -2px;
    right: -2px;
    background: #f44336;
    color: white;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    font-size: 10px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

/* Hover effects per icone stato */
.wc-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    cursor: pointer;
}

/* Tooltip per stato */
.wc-icon[title]:hover::before {
    content: attr(title);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    white-space: nowrap;
    margin-bottom: 4px;
    z-index: 1000;
}

/* =============================================================================
   TIER PRICING CONTAINER
   ============================================================================= */

#teatime-tier-pricing,
#teatime-tier-pricing-simple {
    background: linear-gradient(135deg, #ffffff 0%, #f9f9f9 100%);
    border: 2px solid #e8f5e9;
    border-radius: 12px;
    padding: 25px;
    margin: 25px 0;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.08);
    /* Removed animation to prevent opacity issues */
    display: block !important; /* Always visible */
    opacity: 1 !important;
    visibility: visible !important;
    width: 100%;
    box-sizing: border-box;
}

/* Override any class that tries to hide it */
#teatime-tier-pricing.hide,
#teatime-tier-pricing.hidden,
#teatime-tier-pricing.teatime-loading,
#teatime-tier-pricing:not(.show),
#teatime-tier-pricing-simple.hide,
#teatime-tier-pricing-simple.hidden {
    display: block !important;
    opacity: 1 !important;
    visibility: visible !important;
}

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

/* =============================================================================
   QUANTITY SECTION
   ============================================================================= */

.teatime-quantity-section {
    margin-bottom: 20px;
}

.teatime-quantity-section label {
    display: block;
    font-weight: 700;
    font-size: 13px;
    color: #2e7d32;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

#teatime-quantity-select,
#teatime-quantity-select-simple {
    width: 100%;
    padding: 14px 45px 14px 18px;
    font-size: 16px;
    font-weight: 500;
    border: 2px solid #c8e6c9;
    border-radius: 8px;
    background-color: #ffffff;
    color: #333;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%234caf50" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 22px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

#teatime-quantity-select:hover,
#teatime-quantity-select-simple:hover {
    border-color: #66bb6a;
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.15);
    transform: translateY(-1px);
}

#teatime-quantity-select:focus,
#teatime-quantity-select-simple:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2);
}

/* =============================================================================
   PRICING INFO
   ============================================================================= */

.teatime-pricing-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 15px;
    width: 100%;
}

.unit-price,
.total-price {
    text-align: center;
    padding: 25px 20px;
    border-radius: 12px;
    transition: all 0.3s ease;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.unit-price {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 2px solid #90caf9;
}

.total-price {
    background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
    border: 2px solid #81c784;
}

.unit-price .label,
.total-price .label {
    display: block;
    font-size: 15px;
    color: #555;
    margin-bottom: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.unit-price .price,
.total-price .price {
    display: block;
    font-size: 28px;
    font-weight: 700;
    color: #1565c0;
    margin-bottom: 5px;
    line-height: 1;
}

.total-price .price {
    color: #1b5e20;
    font-size: 32px;
}

/* 🆕 AGGIUNTO: Supporto per prezzi prodotti semplici */
#teatime-unit-price,
#teatime-total-price,
#teatime-simple-unit-price,
#teatime-simple-total-price {
    /* Inherits from .price */
}

.per-piece {
    font-size: 13px;
    color: #666;
    font-style: italic;
    opacity: 0.8;
}

/* =============================================================================
   TIER INFO
   ============================================================================= */

#teatime-tier-info {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 15px;
    margin: 15px 0;
    text-align: center;
    display: none; /* Hidden by default */
}

#teatime-tier-info h4 {
    margin: 0 0 10px 0;
    color: #856404;
}

#teatime-tier-info p {
    margin: 0;
    color: #856404;
}

/* =============================================================================
   LOADING STATE
   ============================================================================= */

.teatime-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.teatime-loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #333;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* =============================================================================
   UPDATE ANIMATION
   ============================================================================= */

.teatime-updated {
    animation: pulse 0.6s ease-in-out;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* =============================================================================
   ERROR MESSAGE
   ============================================================================= */

.teatime-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
    padding: 10px;
    border-radius: 4px;
    margin: 10px 0;
}

/* =============================================================================
   HIDE STANDARD ELEMENTS
   ============================================================================= */

/* Hide standard quantity input for TeaTime products */
.product[data-teatime="1"] .quantity {
    display: none !important;
}

/* Hide ALL standard prices for TeaTime products */
body.single-product .summary .price,
body.single-product .summary .woocommerce-Price-amount,
body.single-product .summary p.price,
body.single-product .summary span.price {
    display: none !important;
}

/* =============================================================================
   UNIFORMA SELECT PRODOTTI SEMPLICI CON VARIANTI
   ============================================================================= */

#teatime-quantity-select-simple {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background-color: #fff;
    font-size: 16px;
    font-family: inherit;
    color: #333;
    cursor: pointer;
    transition: all 0.3s ease;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23666'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 20px;
}

#teatime-quantity-select-simple:hover {
    border-color: #007cba;
    box-shadow: 0 2px 8px rgba(0, 124, 186, 0.15);
}

#teatime-quantity-select-simple:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 3px rgba(0, 124, 186, 0.1);
}

/* Uniforma anche il container - gli stili base sono ereditati dalle classi sopra */
#teatime-tier-pricing-simple .teatime-quantity-section {
    margin-bottom: 20px;
}

#teatime-tier-pricing-simple .teatime-quantity-section label {
    display: block;
    font-weight: 700;
    font-size: 13px;
    color: #2e7d32;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* Pricing info grid - stesso layout */
#teatime-tier-pricing-simple .teatime-pricing-info {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 20px;
    width: 100%;
}

/* Unit e Total price - stesso stile */
#teatime-tier-pricing-simple .unit-price,
#teatime-tier-pricing-simple .total-price {
    padding: 25px 20px;
    border-radius: 12px;
    text-align: center;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

#teatime-tier-pricing-simple .unit-price {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 2px solid #90caf9;
}

#teatime-tier-pricing-simple .total-price {
    background: linear-gradient(135deg, #e8f5e8 0%, #c8e6c9 100%);
    border: 2px solid #81c784;
}

/* =============================================================================
   UNIFIED SELECTION BOX (Material, Quantity, Tea Selection)
   ============================================================================= */

.teatime-unified-selection {
    background: linear-gradient(135deg, #ffffff 0%, #f9f9f9 100%);
    border: 2px solid #e8f5e9;
    border-radius: 12px;
    padding: 25px;
    margin: 25px 0;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.08);
}

/* Material section inside unified box */
.teatime-material-section {
    margin-bottom: 20px;
}

/* Style WooCommerce variations table inside our box */
.teatime-material-section .variations {
    display: table !important;
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.teatime-material-section .variations tr {
    display: table-row;
}

.teatime-material-section .variations .label {
    display: table-cell;
    width: 25%;
    padding: 10px 0;
    vertical-align: middle;
}

.teatime-material-section .variations .label label {
    display: block !important;
    font-weight: 700 !important;
    font-size: 13px !important;
    color: #2e7d32 !important;
    margin: 0 0 10px 0 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.8px !important;
}

.teatime-material-section .variations .value {
    display: table-cell;
    width: 75%;
    padding: 10px 0;
}

.teatime-material-section .variations select,
.teatime-unified-selection .variations select,
#teatime-material-placeholder select {
    width: 100% !important;
    padding: 14px 45px 14px 18px !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    border: 2px solid #c8e6c9 !important;
    border-radius: 8px !important;
    background-color: #ffffff !important;
    color: #333 !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%234caf50" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e') !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 22px !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
}

.teatime-material-section .variations select:hover,
.teatime-unified-selection .variations select:hover,
#teatime-material-placeholder select:hover {
    border-color: #66bb6a !important;
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.15) !important;
    transform: translateY(-1px) !important;
}

.teatime-material-section .variations select:focus,
.teatime-unified-selection .variations select:focus,
#teatime-material-placeholder select:focus {
    outline: none !important;
    border-color: #4caf50 !important;
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2) !important;
}

/* Tier pricing inside unified box - remove duplicate border/background */
.teatime-unified-selection #teatime-tier-pricing {
    background: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    margin: 20px 0 0 0;
    box-shadow: none;
}

.teatime-tea-type-section,
.teatime-tea-section {
    margin-bottom: 20px;
}

.teatime-tea-type-section label,
.teatime-tea-section label {
    display: block;
    font-weight: 700;
    font-size: 13px;
    color: #2e7d32;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

/* Tea Type and Tea Select specific styles */
#teatime-tea-type-select,
#teatime-tea-select {
    width: 100% !important;
    padding: 14px 45px 14px 18px !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    border: 2px solid #c8e6c9 !important;
    border-radius: 8px !important;
    background-color: #ffffff !important;
    color: #333 !important;
    cursor: pointer !important;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    appearance: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%234caf50" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e') !important;
    background-repeat: no-repeat !important;
    background-position: right 12px center !important;
    background-size: 22px !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05) !important;
}

#teatime-tea-type-select:hover,
#teatime-tea-select:hover {
    border-color: #66bb6a !important;
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.15) !important;
    transform: translateY(-1px) !important;
}

#teatime-tea-type-select:focus,
#teatime-tea-select:focus {
    outline: none !important;
    border-color: #4caf50 !important;
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2) !important;
}

#teatime-tea-select:disabled {
    background-color: #f5f5f5 !important;
    cursor: not-allowed !important;
    opacity: 0.6 !important;
}

/* UNIFORMA TUTTE LE SELECT: Material, Tea Type, Tea, Quantity - STESSA ALTEZZA */
.teatime-unified-selection select,
.teatime-material-section select,
#teatime-material-placeholder select,
#teatime-tea-type-select,
#teatime-tea-select,
#teatime-quantity-select,
#teatime-quantity-select-simple {
    height: 52px !important;
    line-height: 1.4 !important;
    padding: 14px 45px 14px 18px !important;
    font-size: 16px !important;
    box-sizing: border-box !important;
}

.teatime-tea-selection select {
    width: 100%;
    padding: 14px 45px 14px 18px;
    font-size: 16px;
    font-weight: 500;
    border: 2px solid #c8e6c9;
    border-radius: 8px;
    background-color: #ffffff;
    color: #333;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url('data:image/svg+xml;charset=UTF-8,%3csvg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%234caf50" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"%3e%3cpolyline points="6 9 12 15 18 9"%3e%3c/polyline%3e%3c/svg%3e');
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 22px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.teatime-tea-selection select:hover {
    border-color: #66bb6a;
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.15);
    transform: translateY(-1px);
}

.teatime-tea-selection select:focus {
    outline: none;
    border-color: #4caf50;
    box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.2);
}

.teatime-tea-selection select:disabled {
    background-color: #f5f5f5;
    border-color: #e0e0e0;
    cursor: not-allowed;
    opacity: 0.6;
    color: #999;
}

.teatime-tea-info {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border-left: 4px solid #4caf50;
    border-radius: 6px;
}

.teatime-tea-info .tea-name {
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 600;
    color: #2e7d32;
}

.teatime-tea-info .tea-description {
    color: #555;
    line-height: 1.6;
    font-size: 14px;
}

.teatime-tea-info .tea-description p {
    margin: 0 0 10px 0;
}

.teatime-tea-info .tea-description p:last-child {
    margin-bottom: 0;
}

/* Animation for tea section appearance */
.teatime-tea-section {
    animation: slideDown 0.3s ease-out;
}

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

/* =============================================================================
   RESPONSIVE DESIGN
   ============================================================================= */

@media (max-width: 768px) {
    .teatime-pricing-info {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    #teatime-tier-pricing-simple .teatime-pricing-info {
        grid-template-columns: 1fr;
    }

    .teatime-tea-selection {
        padding: 15px;
    }

    .teatime-tea-selection select {
        font-size: 14px;
        padding: 10px 12px;
    }

    .teatime-tea-info {
        padding: 15px;
    }

    .teatime-tea-info .tea-name {
        font-size: 16px;
    }
}