/**
 * Aratice Product Options Sidebar
 * Styles pour la sidebar des options de produits variables
 */

/* === Sidebar Container === */
.apg-options-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 9999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.apg-options-sidebar.active {
    display: block;
    opacity: 1;
}

/* === Overlay === */
.apg-options-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(2px);
}

/* === Content === */
.apg-options-content {
    position: absolute;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 500px;
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 24px rgba(0, 0, 0, 0.15);
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.apg-options-sidebar.active .apg-options-content {
    right: 0;
}

/* === Header === */
.apg-options-header {
    padding: 8px 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.apg-options-title {
    margin: 0;
    font-size: 20px;
    font-weight: 700;
    color: #163C79;
}

.apg-options-close {
    width: 40px;
    height: 40px;
    padding: 0;
    background: #f8f9fa;
    border: none;
    border-radius: 8px;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.apg-options-close:hover {
    background: #e5e7eb;
    color: #163C79;
}

.apg-options-close svg {
    width: 20px;
    height: 20px;
}

/* === Loader === */
.apg-options-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 24px;
    flex: 1;
}

.apg-options-loader p {
    margin-top: 16px;
    color: #6b7280;
    font-size: 14px;
}

/* === Spinner === */
.apg-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #163C79;
    border-radius: 50%;
    animation: apg-spin 1s linear infinite;
}

.apg-spinner-small {
    width: 16px;
    height: 16px;
    border-width: 2px;
    vertical-align: middle;
    margin-right: 4px;
}

@keyframes apg-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* === Body === */
.apg-options-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Scrollbar custom */
.apg-options-body::-webkit-scrollbar {
    width: 8px;
}

.apg-options-body::-webkit-scrollbar-track {
    background: #f8f9fa;
}

.apg-options-body::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.apg-options-body::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* === Image Section === */
.apg-options-image-wrapper {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.apg-options-image-container {
    width: 100%;
    height: 200px;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.08);
}

.apg-options-image {
    width: 100%;
    height: 100% !important;
    object-fit: contain;
}

/* === Thumbnails === */
.apg-options-thumbnails {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding: 4px 0;
}

.apg-options-thumbnails::-webkit-scrollbar {
    height: 6px;
}

.apg-options-thumbnails::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 3px;
}

.apg-options-thumbnails::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.apg-options-thumbnail {
    width: 70px;
    height: 70px;
    flex-shrink: 0;
    background: #f8f9fa;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s ease;
}

.apg-options-thumbnail:hover {
    border-color: #163C79;
}

.apg-options-thumbnail.active {
    border-color: #163C79;
    box-shadow: 0 0 0 1px #163C79;
}

.apg-options-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 8px;
}

/* === Info Section === */
.apg-options-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.apg-options-product-title {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #2C3E50;
    line-height: 1.3;
}

.apg-options-product-category {
    margin-top: 8px;
    font-size: 13px;
    font-weight: 400;
    margin-bottom: 8px;
    padding: 4px 8px;
    background-color: #EAF7FA;
    width: fit-content;
    border-radius: 20px;
    color: #163C79;
}

.apg-options-product-description {
    font-size: 14px;
    line-height: 1.6;
    color: #6b7280;
    margin: 0;
    display: -webkit-box;
    line-clamp: 3;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.apg-options-view-details {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #163C79;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s ease;
}

.apg-options-view-details:hover {
    color: #0f2a5a;
    gap: 8px;
}

.apg-options-view-details svg {
    width: 14px;
    height: 14px;
}

/* === Price Section === */
.apg-options-price-wrapper {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.apg-options-price-container {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.apg-options-price-row {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

.apg-options-price-ht {
    margin-bottom: 0;
}

.apg-options-price-amount-ht {
    font-size: 16px;
    font-weight: 700;
    color: #163C79;
}

.apg-options-price-label-ht {
    font-size: 16px;
    font-weight: 700;
    color: #163C79;
}

.apg-options-price-ttc {
    font-size: 14px;
    font-weight: 500;
    color: #7F8C8D;
}

.apg-options-price-amount-ttc {
    font-size: 14px;
    font-weight: 500;
    color: #7F8C8D;
}

.apg-options-price-label-ttc {
    font-size: 14px;
    font-weight: 500;
    color: #7F8C8D;
}

/* Prix barrés */
.apg-options-price-row .apg-price-old {
    font-size: 18px;
    color: #163C79;
    text-decoration: line-through;
    font-weight: 500;
}

.apg-options-price-row .apg-price-old-small {
    font-size: 14px;
    color: #7F8C8D;
    text-decoration: line-through;
    font-weight: 400;
}

.apg-options-price-row .apg-price-discounted {
    color: #7AC143;
}

/* Texte "À partir de" */
.apg-price-starting {
    font-size: 14px;
    color: #6b7280;
    font-weight: 500;
    margin-right: 4px;
}

/* === Attributes Section === */
.apg-options-attributes {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.apg-attribute-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.apg-attribute-label {
    font-size: 14px;
    font-weight: 600;
    color: #2C3E50;
}

.apg-attribute-select {
    width: 100%;
    padding: 12px 16px;
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 15px;
    color: #2C3E50;
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L6 6L11 1' stroke='%236b7280' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 44px;
}

.apg-attribute-select:hover {
    border-color: #163C79;
}

.apg-attribute-select:focus {
    outline: none;
    border-color: #163C79;
    box-shadow: 0 0 0 3px rgba(22, 60, 121, 0.1);
}

/* Options désactivées */
.apg-attribute-select option:disabled {
    color: #9ca3af;
    background: #f3f4f6;
    font-style: italic;
}

/* === Message indisponible === */
.apg-options-unavailable {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: #fef3c7;
    border: 1px solid #fbbf24;
    border-radius: 8px;
}

.apg-options-unavailable svg {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    stroke: #d97706;
}

.apg-options-unavailable p {
    margin: 0;
    font-size: 14px;
    color: #92400e;
    line-height: 1.5;
}

/* === Quantity Section === */
.apg-options-quantity-wrapper {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.apg-options-quantity-wrapper label {
    font-size: 14px;
    font-weight: 600;
    color: #2C3E50;
}

.apg-options-quantity-control {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 8px 16px;
    width: fit-content;
}

.apg-options-qty-btn {
    width: 36px;
    height: 36px;
    background: #163C79;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.apg-options-qty-btn:hover {
    background: #0f2a5a;
    transform: scale(1.05);
}

.apg-options-qty-btn:active {
    transform: scale(0.95);
}

.apg-options-qty-input {
    width: 60px;
    text-align: center;
    font-size: 18px;
    font-weight: 700;
    color: #163C79;
    border: none;
    background: transparent;
    outline: none;
}

/* Supprimer les flèches du input number */
.apg-options-qty-input::-webkit-inner-spin-button,
.apg-options-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.apg-options-qty-input[type=number] {
    -moz-appearance: textfield;
}

/* === Footer === */
.apg-options-footer {
    flex-shrink: 0;
}

.apg-options-add-to-quote {
    width: 100%;
    padding: 16px 24px;
    background: #163C79;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 2px 4px rgba(22, 60, 121, 0.2);
}

.apg-options-add-to-quote:hover:not(:disabled) {
    background: #0f2a5a;
    box-shadow: 0 4px 12px rgba(22, 60, 121, 0.3);
    transform: translateY(-1px);
}

.apg-options-add-to-quote:active:not(:disabled) {
    transform: translateY(0);
}

.apg-options-add-to-quote:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
    box-shadow: none;
}

.apg-options-add-to-quote svg {
    width: 20px;
    height: 20px;
}

/* === Error State === */
.apg-options-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 24px;
    text-align: center;
}

.apg-options-error svg {
    width: 64px;
    height: 64px;
    color: #ef4444;
    margin-bottom: 16px;
}

.apg-options-error p {
    margin: 0 0 24px 0;
    font-size: 16px;
    color: #6b7280;
}

.apg-options-close-error {
    padding: 12px 24px;
    background: #163C79;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.apg-options-close-error:hover {
    background: #0f2a5a;
}

/* === Body Lock === */
body.apg-sidebar-open {
    overflow: hidden;
}

/* === Responsive === */
@media (max-width: 768px) {
    .apg-options-content {
        max-width: 100%;
    }

    .apg-options-header {
        padding: 20px;
    }

    .apg-options-title {
        font-size: 18px;
    }

    .apg-options-body {
        padding: 20px;
        gap: 20px;
    }

    .apg-options-product-title {
        font-size: 18px;
    }

    .apg-options-price-amount-ht {
        font-size: 22px;
    }

    .apg-options-price-label-ht {
        font-size: 22px;
    }

    .apg-options-footer {
        padding: 16px 20px;
    }
}

@media (max-width: 480px) {
    .apg-options-header {
        padding: 16px;
    }

    .apg-options-body {
        padding: 16px;
        gap: 16px;
    }

    .apg-options-footer {
        padding: 12px 16px;
    }

    .apg-options-add-to-quote {
        padding: 14px 20px;
        font-size: 15px;
    }
}