/* ============================================================
 *  CUSTOM SIZE SELECTOR MODAL – Premium Styling System
 *  WoodMart Child Theme
 * ============================================================ */

/* ---------- SIZE GUIDE TRIGGER LINK ---------- */
.ag-size-guide-trigger {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #333;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: color 0.3s ease;
    margin-left: 10px;
}

.ag-size-guide-trigger:hover {
    color: #bfa37a;
    text-decoration: underline;
}

.ag-info-icon {
    width: 15px;
    height: 15px;
    stroke: currentColor;
}

/* ---------- MODAL OVERLAY (Backdrop blur) ---------- */
.ag-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.ag-modal-overlay.ag-active {
    opacity: 1;
    pointer-events: auto;
}

/* ---------- MODAL CONTAINER (Right Drawer) ---------- */
.ag-modal {
    background-color: #ffffff;
    width: 400px;
    max-width: 90%;
    height: 100vh;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 1000000;
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.ag-modal-overlay.ag-active .ag-modal {
    transform: translateX(0);
}

/* ---------- MODAL HEADER ---------- */
.ag-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 28px 16px;
    border-bottom: none;
}

.ag-modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 2px;
    color: #1a1a1a;
    text-transform: uppercase;
}

.ag-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ag-modal-close:hover {
    color: #1a1a1a;
    transform: rotate(90deg);
}

/* ---------- SIZE GUIDE ROW ---------- */
.ag-size-guide {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 28px;
    background-color: #faf7f2;
    /* Cream background */
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.ag-size-guide:hover {
    background-color: #f5eedf;
}

.ag-size-guide-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ag-size-guide-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bfa37a;
}

.ag-size-guide-icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ag-size-guide-text {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: #1a1a1a;
    text-transform: uppercase;
}

.ag-size-guide-arrow {
    color: #bfa37a;
    font-size: 20px;
    line-height: 1;
    font-weight: 300;
}

/* ---------- FILTER BAR ---------- */
.ag-filter-bar {
    display: flex;
    gap: 12px;
    padding: 20px 28px;
}

.ag-filter-select {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e5e5e5;
    border-radius: 8px;
    background-color: #ffffff;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    appearance: none;
    -webkit-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='%23999999' stroke-width='2' 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 14px center;
    background-size: 12px;
    padding-right: 36px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ag-filter-select:focus {
    border-color: #bfa37a;
    box-shadow: 0 0 0 2px rgba(191, 163, 122, 0.1);
    outline: none;
}

/* ---------- SIZE LIST ---------- */
.ag-size-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 28px 24px;
}

/* Custom Scrollbar */
.ag-size-list::-webkit-scrollbar {
    width: 6px;
}

.ag-size-list::-webkit-scrollbar-track {
    background: transparent;
}

.ag-size-list::-webkit-scrollbar-thumb {
    background-color: #e5e5e5;
    border-radius: 10px;
}

.ag-size-list::-webkit-scrollbar-thumb:hover {
    background-color: #cccccc;
}

/* ---------- SIZE ITEM ---------- */
.ag-size-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s ease;
    margin-bottom: 4px;
}

.ag-size-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.ag-size-item:hover {
    background-color: #fcfcfc;
}

.ag-size-name {
    font-size: 15px;
    font-weight: 600;
    color: #1a1a1a;
    letter-spacing: 0.5px;
}

.ag-size-measurement {
    font-size: 13px;
    font-weight: 500;
    color: #777;
}

/* Selected State */
.ag-size-item.ag-selected {
    background-color: #1a1a1a;
    color: #ffffff;
}

.ag-size-item.ag-selected .ag-size-name {
    color: #ffffff;
}

.ag-size-item.ag-selected .ag-size-measurement {
    color: #ffffff;
}

.ag-size-empty {
    padding: 20px 0;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* ---------- SCROLL LOCK ---------- */
body.ag-modal-open {
    overflow: hidden !important;
}

/* ---------- RESPONSIVE DESIGN (Mobile Bottom-sheet to Left Drawer) ---------- */
@media (max-width: 768px) {
    .ag-modal {
        width: 85%;
        max-width: 350px;
    }

    .ag-modal-header {
        padding: 20px 24px 12px;
    }

    .ag-size-guide {
        padding: 14px 24px;
    }

    .ag-filter-bar {
        padding: 16px 24px;
    }

    .ag-size-list {
        padding: 0 24px 16px;
    }

    .ag-size-item {
        padding: 14px 16px;
    }
}

/* ============================================================
 *  PREMIUM CUSTOM ATTRIBUTES UI
 * ============================================================ */

/* Hide native elements when premium UI is active */
body.ag-premium-ui-active table.variations select {
    display: none !important;
}

body.ag-premium-ui-active table.variations .wd-swatches-product {
    display: none !important;
}

body.ag-premium-ui-active table.variations .reset_variations {
    display: none !important;
}

/* Card Layout for Variations Table */
body.ag-premium-ui-active form.variations_form {
    background-color: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    padding: 0 24px 25px 24px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.02);
    margin-bottom: 30px;
}

body.ag-premium-ui-active table.variations {
    width: 100%;
    border-spacing: 0;
    border-collapse: collapse;
}

body.ag-premium-ui-active table.variations tbody {
    display: block;
    width: 100%;
}

body.ag-premium-ui-active table.variations tr {
    display: block;
    border-bottom: 1px solid #f0f0f0;
    padding: 24px 0;
    position: relative;
}

body.ag-premium-ui-active table.variations tr:last-child {
    border-bottom: none;
}

body.ag-premium-ui-active table.variations th.label {
    display: block;
    text-align: left;
    padding: 0 0 16px 0;
    background: none;
    border: none;
    width: 100%;
    position: relative;
}

body.ag-premium-ui-active table.variations th.label label {
    font-size: 16px;
    font-weight: 500;
    color: #1a1a1a;
    letter-spacing: 0.2px;
    display: inline-block;
}

body.ag-premium-ui-active table.variations td.value {
    display: block;
    padding: 0;
    border: none;
    width: 100%;
}

/* Adjust Guide Link inside the TH */
body.ag-premium-ui-active table.variations th.label .woodmart-size-guide-btn,
body.ag-premium-ui-active table.variations th.label .ag-size-guide-trigger,
body.ag-premium-ui-active table.variations td.value .woodmart-size-guide-btn,
body.ag-premium-ui-active table.variations td.value .ag-size-guide-trigger {
    float: right;
    font-size: 13px;
    font-weight: 400;
    color: #333;
    text-decoration: underline;
    margin-top: 2px;
}

/* ---------- CUSTOM SWATCHES CONTAINER ---------- */
.ag-custom-swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-start;
}

/* ---------- IMAGE SWATCHES (Diamond, Metal) ---------- */
.ag-image-swatches .ag-custom-swatch {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    background-color: transparent;
    transition: all 0.3s ease;
    min-width: 76px;
}

.ag-image-swatches .ag-custom-swatch:hover {
    background-color: #fafafa;
}

.ag-image-swatches .ag-custom-swatch.active {
    background-color: #f7f7f7;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.04);
}

.ag-image-swatches .ag-swatch-img {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #fff;
    box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
}

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

.ag-swatch-color,
.ag-swatch-fallback {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
}

.ag-swatch-fallback {
    background-color: #eee;
}

.ag-image-swatches .ag-swatch-label {
    font-size: 12px;
    color: #333;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}

/* ---------- TEXT SWATCHES (Size) ---------- */
.ag-text-swatches {
    gap: 8px;
}

.ag-text-swatches .ag-custom-swatch {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f9f9f9;
    color: #333;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
}

.ag-text-swatches .ag-custom-swatch:hover {
    background-color: #f0f0f0;
}

.ag-text-swatches .ag-custom-swatch.active {
    background-color: #ffffff;
    border-bottom: 2px solid #1a1a1a;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    font-weight: 600;
}

.ag-text-swatches .ag-swatch-img {
    display: none;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    body.ag-premium-ui-active form.variations_form {
        padding: 0 16px;
        border-radius: 8px;
        border-width: 0;
        box-shadow: none;
        border-top: 1px solid #eaeaea;
        border-bottom: 1px solid #eaeaea;
    }

    body.ag-premium-ui-active table.variations tr {
        padding: 20px 0;
    }

    .ag-image-swatches .ag-custom-swatch {
        padding: 10px 12px;
        min-width: 66px;
    }

    .ag-image-swatches .ag-swatch-img {
        width: 38px;
        height: 38px;
    }
}

/* ============================================================
 *  ENGRAVING FIELD
 * ============================================================ */
.ag-engraving-wrapper {
    margin-bottom: 24px;
    padding: 18px 24px;
    background-color: #ffffff;
    border: 1px solid #eaeaea;
    border-radius: 12px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.02);
}

.ag-engraving-label {
    display: block;
    font-size: 16px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 10px;
}

.ag-engraving-input {
    width: 100%;
    padding: 14px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    color: #333;
    transition: all 0.3s ease;
    background-color: #fcfcfc;
}

.ag-engraving-input:focus {
    background-color: #ffffff;
    border-color: #bfa37a;
    outline: none;
    box-shadow: 0 0 0 3px rgba(191, 163, 122, 0.1);
}

.ag-engraving-desc {
    font-size: 12px;
    color: #888;
    margin-top: 8px;
    margin-bottom: 0;
}