/**
 * TradePrint Configurator - Frontend Styles
 */

/* Reset & Container */
.tpc-configurator {
    --tpc-primary: #2271b1;
    --tpc-primary-hover: #135e96;
    --tpc-success: #46b450;
    --tpc-border: #ddd;
    --tpc-border-hover: #999;
    --tpc-bg: #f9f9f9;
    --tpc-text: #333;
    --tpc-text-light: #666;
    --tpc-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --tpc-radius: 8px;
    --tpc-transition: 0.2s ease;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

.tpc-configurator * {
    box-sizing: border-box;
}

/* Title */
.tpc-configurator-title {
    text-align: center;
    font-size: 28px;
    font-weight: 600;
    margin: 0 0 30px;
    color: var(--tpc-text);
}

/* Product Grid */
.tpc-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

/* Product Card */
.tpc-product-card {
    position: relative;
    background: #fff;
    border: 2px solid var(--tpc-border);
    border-radius: var(--tpc-radius);
    overflow: hidden;
    cursor: pointer;
    transition: all var(--tpc-transition);
}

.tpc-product-card:hover {
    border-color: var(--tpc-border-hover);
    box-shadow: var(--tpc-shadow);
    transform: translateY(-2px);
}

.tpc-product-card.selected {
    border-color: var(--tpc-primary);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.2);
}

.tpc-product-card-image {
    aspect-ratio: 1;
    background: var(--tpc-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.tpc-product-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--tpc-transition);
}

.tpc-product-card:hover .tpc-product-card-image img {
    transform: scale(1.05);
}

.tpc-product-card-placeholder {
    width: 60%;
    height: 60%;
    color: #ccc;
}

.tpc-product-card-placeholder svg {
    width: 100%;
    height: 100%;
}

.tpc-product-card-content {
    padding: 15px;
    text-align: center;
}

.tpc-product-card-title {
    margin: 0 0 8px;
    font-size: 16px;
    font-weight: 600;
    color: var(--tpc-text);
}

.tpc-product-card-price {
    font-size: 14px;
    color: var(--tpc-text-light);
}

/* Check Mark */
.tpc-product-card-check {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    background: var(--tpc-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.5);
    transition: all var(--tpc-transition);
}

.tpc-product-card.selected .tpc-product-card-check {
    opacity: 1;
    transform: scale(1);
}

.tpc-product-card-check svg {
    width: 18px;
    height: 18px;
    color: #fff;
}

/* Attributes Section */
.tpc-attributes-section {
    background: #fff;
    border: 1px solid var(--tpc-border);
    border-radius: var(--tpc-radius);
    padding: 30px;
    animation: tpcSlideDown 0.3s ease;
}

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

.tpc-attributes-header {
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--tpc-border);
}

.tpc-attributes-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--tpc-text);
}

/* Attributes Container */
.tpc-attributes-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
}

/* Single Attribute */
.tpc-attribute-label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--tpc-text);
    margin-bottom: 10px;
}

.tpc-attribute-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

/* Option Button */
.tpc-option {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    background: #fff;
    border: 2px solid var(--tpc-border);
    border-radius: 6px;
    font-size: 14px;
    color: var(--tpc-text);
    cursor: pointer;
    transition: all var(--tpc-transition);
    min-width: 80px;
}

.tpc-option:hover {
    border-color: var(--tpc-border-hover);
    background: var(--tpc-bg);
}

.tpc-option.selected {
    border-color: var(--tpc-primary);
    background: var(--tpc-primary);
    color: #fff;
}

/* Select dropdown */
.tpc-attribute-select {
    width: 100%;
    max-width: 400px;
    padding: 12px 16px;
    font-size: 14px;
    border: 2px solid var(--tpc-border);
    border-radius: 6px;
    background: #fff;
    color: var(--tpc-text);
    cursor: pointer;
    transition: border-color var(--tpc-transition);
}

.tpc-attribute-select:hover,
.tpc-attribute-select:focus {
    border-color: var(--tpc-border-hover);
    outline: none;
}

/* Loading */
.tpc-attributes-loading,
.tpc-pricing-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
    padding: 40px;
    color: var(--tpc-text-light);
}

.tpc-spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--tpc-border);
    border-top-color: var(--tpc-primary);
    border-radius: 50%;
    animation: tpcSpin 0.8s linear infinite;
}

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

/* Pricing Section */
.tpc-pricing-section {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid var(--tpc-border);
}

.tpc-pricing-title {
    margin: 0 0 20px;
    font-size: 18px;
    font-weight: 600;
    color: var(--tpc-text);
}

/* Pricing Table */
.tpc-pricing-table-wrapper {
    overflow-x: auto;
}

.tpc-pricing-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.tpc-pricing-table th,
.tpc-pricing-table td {
    padding: 12px 16px;
    text-align: center;
    border: 1px solid var(--tpc-border);
}

.tpc-pricing-table th {
    background: var(--tpc-bg);
    font-weight: 600;
    color: var(--tpc-text);
}

.tpc-pricing-table th .tpc-speed-name {
    display: block;
}

.tpc-pricing-table th .tpc-speed-days {
    display: block;
    font-size: 12px;
    font-weight: 400;
    color: var(--tpc-text-light);
    margin-top: 2px;
}

.tpc-pricing-table .tpc-qty-cell {
    font-weight: 600;
    background: var(--tpc-bg);
}

.tpc-pricing-table .tpc-price-cell {
    cursor: pointer;
    transition: all var(--tpc-transition);
}

.tpc-pricing-table .tpc-price-cell:hover:not(.tpc-unavailable) {
    background: #e8f4fc;
}

.tpc-pricing-table .tpc-price-cell.selected {
    background: var(--tpc-primary);
    color: #fff;
    font-weight: 600;
}

.tpc-pricing-table .tpc-price-cell.tpc-unavailable {
    color: #ccc;
    cursor: not-allowed;
    background: #fafafa;
}

.tpc-pricing-table .tpc-cell-price {
    display: block;
}

/* Pricing Error */
.tpc-pricing-error {
    padding: 15px 20px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    text-align: center;
}

/* Cart Section */
.tpc-cart-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid var(--tpc-border);
    gap: 20px;
    flex-wrap: wrap;
}

/* Selected Summary */
.tpc-selected-summary {
    display: flex;
    gap: 30px;
    flex-wrap: wrap;
}

.tpc-summary-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tpc-summary-label {
    font-size: 12px;
    color: var(--tpc-text-light);
    text-transform: uppercase;
}

.tpc-summary-qty,
.tpc-summary-delivery {
    font-size: 16px;
    font-weight: 600;
    color: var(--tpc-text);
}

.tpc-summary-price-row .tpc-summary-price {
    font-size: 24px;
    font-weight: 700;
    color: var(--tpc-primary);
}

/* Add to Cart Button */
.tpc-add-to-cart {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px;
    background: var(--tpc-primary);
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--tpc-transition);
}

.tpc-add-to-cart:hover:not(:disabled) {
    background: var(--tpc-primary-hover);
    transform: translateY(-1px);
}

.tpc-add-to-cart:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.tpc-add-to-cart svg {
    width: 20px;
    height: 20px;
}

.tpc-add-to-cart.loading {
    pointer-events: none;
}

.tpc-add-to-cart.loading svg {
    animation: tpcSpin 0.8s linear infinite;
}

/* Messages */
.tpc-messages {
    width: 100%;
    margin-top: 20px;
}

.tpc-message {
    padding: 15px 20px;
    border-radius: 6px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.tpc-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.tpc-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.tpc-message a {
    color: inherit;
    font-weight: 600;
}

/* Error State */
.tpc-error {
    padding: 20px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: var(--tpc-radius);
    text-align: center;
}

/* Column highlights for delivery types */
.tpc-col-saver {
    background: #f0fff4;
}

.tpc-col-standard {
    background: #f0f7ff;
}

.tpc-col-express {
    background: #fff8f0;
}

/* Responsive */
@media (max-width: 768px) {
    .tpc-configurator {
        padding: 15px;
    }

    .tpc-configurator-title {
        font-size: 22px;
        margin-bottom: 20px;
    }

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

    .tpc-product-card-content {
        padding: 12px;
    }

    .tpc-product-card-title {
        font-size: 14px;
    }

    .tpc-attributes-section {
        padding: 20px;
    }

    .tpc-cart-section {
        flex-direction: column;
        text-align: center;
    }

    .tpc-selected-summary {
        justify-content: center;
    }

    .tpc-add-to-cart {
        width: 100%;
        justify-content: center;
    }

    .tpc-option {
        padding: 8px 15px;
        font-size: 13px;
        min-width: auto;
    }

    .tpc-pricing-table th,
    .tpc-pricing-table td {
        padding: 8px 10px;
        font-size: 13px;
    }
}

@media (max-width: 480px) {
    .tpc-product-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .tpc-product-card-check {
        width: 24px;
        height: 24px;
        top: 6px;
        right: 6px;
    }

    .tpc-product-card-check svg {
        width: 14px;
        height: 14px;
    }

    .tpc-selected-summary {
        gap: 20px;
    }
}
