/**
 * Add to Cart Improved - Estilos
 * Baseado nos padrões do WooCommerce/Storefront
 */

/* Ocultar botão Ver Carrinho padrão do WooCommerce */
.atci-hide-wc-view-cart + .added_to_cart,
.atci-hide-wc-view-cart ~ .added_to_cart,
li.product:has(.atci-hide-wc-view-cart) .added_to_cart:not(.atci-view-cart-link) {
    display: none !important;
}

/* Wrapper principal */
.atci-add-to-cart-wrapper {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 0.5em;
    width: 100%;
}

/* Variações */
.atci-variations-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.atci-variation-row {
    width: 100%;
}

/* Select - usando estilos padrão do WooCommerce */
.atci-variation-select {
    width: 100%;
    max-width: 100%;
    padding: 0.5em;
    font-size: 1em;
    line-height: 1.5;
    border: 1px solid #d3ced2;
    border-radius: 3px;
    background-color: #fff;
    color: inherit;
}

.atci-variation-select:focus {
    outline: none;
    border-color: #007acc;
    box-shadow: 0 0 0 1px #007acc;
}

.atci-variation-select.atci-selected {
    border-color: #007acc;
}

/* Ações (quantidade + botão) */
.atci-actions-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
    width: 100%;
    flex-wrap: wrap;
}

/* Quantidade - Estilo WooCommerce padrão */
.atci-quantity-wrapper {
    display: inline-flex;
    align-items: center;
    vertical-align: middle;
}

.atci-quantity-wrapper .qty,
.atci-quantity-wrapper .atci-quantity {
    width: 3.631em;
    height: 2.507em;
    padding: 0;
    text-align: center;
    background-color: #fff;
    color: inherit;
    font-size: 1em;
    border: 1px solid #d3ced2;
    border-radius: 3px;
    -moz-appearance: textfield;
}

.atci-quantity-wrapper .atci-quantity::-webkit-outer-spin-button,
.atci-quantity-wrapper .atci-quantity::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.atci-quantity-wrapper .atci-quantity:focus {
    outline: none;
    border-color: #007acc;
}

/* Botões de quantidade - estilo discreto */
.atci-qty-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2em;
    height: 2.507em;
    padding: 0;
    margin: 0;
    border: 1px solid #d3ced2;
    background-color: #f7f6f7;
    color: inherit;
    font-size: 1em;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease;
    user-select: none;
}

.atci-qty-btn:first-child {
    border-radius: 3px 0 0 3px;
    border-right: none;
}

.atci-qty-btn:last-child {
    border-radius: 0 3px 3px 0;
    border-left: none;
}

.atci-quantity-wrapper .atci-quantity {
    border-radius: 0;
    border-left: none;
    border-right: none;
}

.atci-qty-btn:hover {
    background-color: #e2e2e2;
}

.atci-qty-btn:active {
    background-color: #d5d5d5;
}

/* Botões - Usando classes do WooCommerce */
.atci-add-to-cart-wrapper .button,
.atci-add-to-cart-wrapper .atci-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    flex: 1;
    min-height: 2.507em;
    padding: 0.618em 1em;
    font-size: 1em;
    font-weight: 700;
    line-height: 1.618;
    text-decoration: none;
    text-align: center;
    border: 0;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease;
}

/* Botão principal - herdar cores do tema */
.atci-add-to-cart-btn {
    background-color: #333;
    color: #fff;
}

.atci-add-to-cart-btn:hover:not(:disabled) {
    background-color: #555;
    color: #fff;
}

.atci-add-to-cart-btn:disabled {
    background-color: #bbb;
    color: #fff;
    cursor: not-allowed;
}

.atci-add-to-cart-btn.atci-adding {
    pointer-events: none;
    opacity: 0.7;
}

.atci-add-to-cart-btn.atci-added {
    background-color: #7ad03a;
    color: #fff;
}

/* Botão Ver Produto */
.atci-read-more {
    background-color: transparent;
    color: inherit;
    border: 1px solid currentColor;
}

.atci-read-more:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Spinner de loading */
.atci-spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: currentColor;
    animation: atci-spin 0.8s linear infinite;
}

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

/* Preço da variação */
.atci-price-wrapper {
    font-size: 0.875em;
    color: inherit;
}

/* Preço Base "A partir de" */
.atci-base-price {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.35em;
    margin-bottom: 0.75em;
    font-size: 1em;
}

.atci-base-price .atci-price-prefix {
    font-size: 0.85em;
    font-weight: 400;
    opacity: 0.85;
}

.atci-base-price .atci-current-price,
.atci-base-price .atci-sale-price {
    font-weight: 700;
}

.atci-base-price .atci-original-price {
    opacity: 0.6;
    font-weight: 400;
    text-decoration: line-through;
    font-size: 0.9em;
}

.atci-base-price .atci-sale-price {
    text-decoration: none;
}

/* Preço base quando variação está selecionada */
.atci-base-price.atci-variation-selected {
    /* Remove estilos de "a partir de" */
}

.atci-base-price .atci-variation-price-value {
    font-weight: 700;
}

.atci-base-price .atci-variation-price-value del {
    opacity: 0.6;
    font-weight: 400;
    margin-right: 0.35em;
}

.atci-base-price .atci-variation-price-value ins {
    text-decoration: none;
}

/* Preço da variação selecionada (oculto até selecionar) */
.atci-selected-price {
    margin-top: 0.5em;
}

.atci-variation-price {
    display: block;
}

.atci-variation-price del {
    opacity: 0.5;
    font-weight: 400;
}

.atci-variation-price ins {
    text-decoration: none;
    font-weight: 700;
}

/* Mensagem de sucesso - estilo WooCommerce */
.atci-message {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1em;
    padding: 0.75em 1em;
    margin-top: 0.5em;
    font-size: 0.875em;
    border-radius: 3px;
}

.atci-message.atci-success {
    background-color: #e0f0d9;
    color: #3c763d;
    border-top: 3px solid #7ad03a;
}

.atci-message.atci-error {
    background-color: #f8d7da;
    color: #721c24;
    border-top: 3px solid #dc3232;
}

/* Link ver carrinho - estilo WooCommerce */
.atci-message .atci-view-cart-link {
    display: inline-block;
    padding: 0.3em 0.8em;
    font-size: 0.875em;
    font-weight: 600;
    color: #fff;
    background-color: #333;
    border-radius: 3px;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

.atci-message .atci-view-cart-link:hover {
    background-color: #555;
    color: #fff;
}

/* Stock status */
.atci-stock-status {
    font-size: 0.875em;
    margin-top: 0.25em;
}

.atci-stock-status.in-stock {
    color: #7ad03a;
}

.atci-stock-status.out-of-stock {
    color: #dc3232;
}

.atci-stock-status.low-stock {
    color: #ffba00;
}

/* Responsivo */
@media (max-width: 768px) {
    .atci-actions-wrapper {
        flex-direction: row;
    }

    .atci-quantity-wrapper {
        flex-shrink: 0;
    }
}

/* Remover animação para melhor performance */
.atci-add-to-cart-wrapper {
    animation: none;
}

/* Ajustes para WooCommerce */
.woocommerce ul.products li.product .atci-add-to-cart-wrapper {
    margin-top: 0.5em;
}

.woocommerce ul.products li.product .atci-add-to-cart-wrapper .button {
    margin: 0;
}

/* Suporte para swatches de cor/imagem */
.atci-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}

.atci-swatch {
    border: 2px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
    background: #fff;
    position: relative;
}

.atci-swatch:hover {
    border-color: #999;
}

.atci-swatch.atci-selected {
    border-color: #0073aa;
    box-shadow: 0 0 0 1px #0073aa;
}

.atci-swatch.atci-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    position: relative;
}

.atci-swatch.atci-disabled::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 2px;
    background: #dc3232;
    transform: rotate(-45deg);
}

/* Button Swatches */
.atci-swatch-button {
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 500;
    min-width: 40px;
    text-align: center;
}

.atci-swatch-button:hover {
    background: #f5f5f5;
}

.atci-swatch-button.atci-selected {
    background: #0073aa;
    color: #fff;
    border-color: #0073aa;
}

/* Color Swatches */
.atci-swatch-color {
    width: 28px;
    height: 28px;
    border-radius: 4px;
}

.atci-swatch-color .screen-reader-text {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Image Swatches */
.atci-swatch-image {
    width: 32px;
    height: 32px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.atci-swatch-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: cover;
}

.atci-swatch-image .atci-no-image {
    font-size: 10px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
}

/* Radio Swatches */
.atci-radio-swatches {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.atci-radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    transition: all 0.2s ease;
    font-size: 13px;
}

.atci-radio-label:hover {
    border-color: #999;
    background: #f9f9f9;
}

.atci-radio-label input {
    margin: 0;
}

.atci-radio-label input:checked + .atci-radio-text {
    font-weight: 600;
    color: #0073aa;
}

/* Swatch Sizes */
.atci-swatch-small .atci-swatch-color {
    width: 24px;
    height: 24px;
}

.atci-swatch-small .atci-swatch-image {
    width: 28px;
    height: 28px;
}

.atci-swatch-medium .atci-swatch-color {
    width: 32px;
    height: 32px;
}

.atci-swatch-medium .atci-swatch-image {
    width: 36px;
    height: 36px;
}

.atci-swatch-large .atci-swatch-color {
    width: 40px;
    height: 40px;
}

.atci-swatch-large .atci-swatch-image {
    width: 44px;
    height: 44px;
}

/* Swatch Shapes */
.atci-shape-square .atci-swatch-color,
.atci-shape-square .atci-swatch-image {
    border-radius: 4px;
}

.atci-shape-rounded .atci-swatch-color,
.atci-shape-rounded .atci-swatch-image {
    border-radius: 8px;
}

.atci-shape-circle .atci-swatch-color,
.atci-shape-circle .atci-swatch-image {
    border-radius: 50%;
}
