/* =========================================================================
   METAL SELECTOR ICON BUTTONS
   Reference: C:/Users/Beta/Desktop/metalicons.html
   Created: 2025-10-31
   ========================================================================= */

/* Container wrapper - ensure proper positioning and prevent overlap */
.metal-selector-container {
    width: 100%;
    max-width: 100%;
    margin: 0 0 2px 0; /* Absolute minimal margin - no top spacing */
    clear: both;
    display: block;
    position: relative; /* Create positioning context */
}

/* Clear fix utility (used in views) */
.clear {
    clear: both !important;
    display: block !important;
    height: 0 !important;
    visibility: hidden !important;
}

/* Container - uses margin-based gaps for Safari < 14.1 compatibility */
.metal-icon-row {
    display: flex;
    flex-wrap: nowrap; /* Keep all icons in one horizontal line */
    margin: -6px; /* Negative margin technique for gap fallback */
    align-items: center;
    overflow-x: auto; /* Allow horizontal scroll if needed */
}

/* Modern browsers: use gap property */
@supports (gap: 12px) {
    .metal-icon-row {
        gap: 12px;
        margin: 0;
    }

    .metal-icon-button {
        margin: 0 !important;
    }
}

/* Icon Button Base */
.metal-icon-button {
    margin: 6px; /* Creates 12px effective gap (fallback) */
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    width: auto !important; /* Override global button width */
    min-width: 0 !important;
}

/* Reduce text size by 10% (26px → 23.4px) for all viewports */
.metal-icon-button svg text {
    font-size: 23.4px !important;
}

.metal-icon-button:hover {
    filter: brightness(1.05);
    transform: scale(1.02);
}

.metal-icon-button:focus {
    outline: 2px solid #0088CC;
    outline-offset: 2px;
}

.metal-icon-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: grayscale(50%);
}

/* SVG Circles - Base styles */
.metal-icon-button svg {
    display: block;
}

.metal-icon-button circle {
    transition: stroke 0.2s ease, stroke-width 0.2s ease;
}

/* Unselected state */
.metal-icon-button:not([aria-checked="true"]) circle {
    stroke: #b0b0b0;
    stroke-width: 3;
}

/* Selected state - blue border from metalicons.html */
.metal-icon-button[aria-checked="true"] circle {
    stroke: #30a8dc;
    stroke-width: 4;
}

/* Disabled state for selected metal - prevent clicks on current selection */
.metal-icon-button[aria-checked="true"] {
    pointer-events: none;
    cursor: default;
    opacity: 0.8;
}

/* =========================================================================
   RESPONSIVE LAYOUT - MOBILE-FIRST APPROACH
   Expert Panel Approved: 2025-11-01
   ========================================================================= */

/* Mobile Extra Small (320px - 479px) - VERTICAL STACK */
@media (max-width: 479px) {
    .product-dropdown {
        display: flex;
        flex-direction: column;  /* Stack vertically */
        gap: 8px;  /* Reduced from 12px for tighter spacing */
        align-items: center;  /* Center icons and dropdown */
    }

    .metal-selector-container {
        order: -1;  /* Metal icons appear FIRST (Row 1) */
        width: 100%;
        margin: 3px 0 5px 0;  /* Reduced vertical spacing */
    }

    .product-select2 {
        order: 2;  /* Ring dropdown appears SECOND (Row 2) */
        width: 100%;
    }

    .metal-icon-button svg {
        width: 42px;
        height: 42px;
    }

    .metal-icon-row {
        margin: -4px;
    }

    .metal-icon-button {
        margin: 4px;
    }

    @supports (gap: 8px) {
        .metal-icon-row {
            gap: 8px;
            margin: 0;
            justify-content: flex-start;
        }

        .metal-icon-button {
            margin: 0 !important;
        }
    }
}

/* Mobile Standard (480px - 767px) - SIDE-BY-SIDE */
@media (min-width: 480px) and (max-width: 767px) {
    .product-dropdown {
        display: flex;
        flex-direction: row;  /* Side-by-side */
        align-items: center;  /* Vertical centering for alignment */
        gap: 12px;  /* Reduced from 16px for tighter spacing */
    }

    .metal-selector-container {
        margin: 3px 0 5px 0;  /* Reduced vertical spacing */
    }

    .metal-icon-button svg {
        width: 34px;  /* Better balance for side-by-side layout */
        height: 34px;
    }

    .metal-icon-row {
        margin: -2px;  /* Adjusted for smaller icons */
    }

    .metal-icon-button {
        margin: 2px;
    }

    @supports (gap: 4px) {
        .metal-icon-row {
            gap: 4px;  /* Reduced from 6px for more space */
            margin: 0;
        }

        .metal-icon-button {
            margin: 0 !important;
        }
    }
}

/* Tablet (768px - 1199px) - SIDE-BY-SIDE */
@media (min-width: 768px) and (max-width: 1199px) {
    .product-dropdown {
        display: flex;
        flex-direction: row;
        align-items: center;  /* Vertical centering for alignment */
        gap: 14px;  /* Reduced from 16px for tighter spacing */
    }

    .metal-selector-container {
        margin: 4px 0 6px 0;  /* Reduced vertical spacing */
    }

    .metal-icon-button svg {
        width: 38px;  /* Increased to match dropdown height for better alignment */
        height: 38px;
    }

    .metal-icon-row {
        margin: -3px;  /* Adjusted for medium icons */
    }

    .metal-icon-button {
        margin: 3px;
    }

    @supports (gap: 6px) {
        .metal-icon-row {
            gap: 6px;  /* Breathing room for larger icons */
            margin: 0;
        }

        .metal-icon-button {
            margin: 0 !important;
        }
    }
}

/* Desktop Small (1200px - 1599px) - SIDE-BY-SIDE */
@media (min-width: 1200px) and (max-width: 1599px) {
    .product-dropdown {
        display: flex;
        flex-direction: row;
        align-items: center;  /* Vertical centering for alignment */
        gap: 14px;  /* Reduced from 16px for tighter spacing */
    }

    .metal-selector-container {
        margin: 5px 0 8px 0;  /* Reduced vertical spacing */
    }

    .metal-icon-button svg {
        width: 40px;  /* Balanced size for desktop - not oversized */
        height: 40px;
    }

    .metal-icon-row {
        margin: -5px;  /* Adjusted for icons */
    }

    .metal-icon-button {
        margin: 5px;
    }

    @supports (gap: 10px) {
        .metal-icon-row {
            gap: 10px;  /* Reduced from 12px for more space */
            margin: 0;
        }

        .metal-icon-button {
            margin: 0 !important;
        }
    }
}

/* Desktop Large (1600px+) - SIDE-BY-SIDE */
@media (min-width: 1600px) {
    .product-dropdown {
        display: flex;
        flex-direction: row;
        align-items: center;  /* Vertical centering for alignment */
        gap: 16px;  /* Reduced from 18px for tighter spacing */
    }

    .metal-selector-container {
        margin: 5px 0 8px 0;  /* Reduced vertical spacing */
    }

    .metal-icon-button svg {
        width: 50px;  /* Balanced size for large desktop - proportional */
        height: 50px;
    }

    .metal-icon-row {
        margin: -6px;  /* Adjusted for icons */
    }

    .metal-icon-button {
        margin: 6px;
    }

    @supports (gap: 12px) {
        .metal-icon-row {
            gap: 12px;  /* Reduced from 14px for more space */
            margin: 0;
        }

        .metal-icon-button {
            margin: 0 !important;
        }
    }
}

/* =========================================================================
   EDGE CASES
   ========================================================================= */

/* Edge Case: 0 Metal Options - Hide Container */
.metal-icon-row:empty {
    display: none;
}

.metal-icon-row:not(:has(.metal-icon-button)) {
    display: none;
}

.metal-selector-container:has(.metal-icon-row:empty),
.metal-selector-container:not(:has(.metal-icon-button)) {
    display: none !important;
}

/* Edge Case: 1 Metal Option - Show as Read-Only with Blue Border */
.metal-icon-row.single-option {
    pointer-events: none;
}

.metal-icon-row.single-option .metal-icon-button {
    cursor: default;
}

.metal-icon-row.single-option .metal-icon-button circle {
    stroke: #30a8dc !important;
    stroke-width: 4 !important;
}

.metal-icon-row.single-option .metal-icon-button svg {
    opacity: 1;
}

/* =========================================================================
   VISUAL SCROLL INDICATOR
   Appears only when horizontal scroll is needed
   ========================================================================= */

.metal-icon-row {
    position: relative;
}

.metal-icon-row.has-overflow::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, rgba(255,255,255,0), rgba(255,255,255,0.9));
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
    z-index: 1;
}

.metal-icon-row.has-overflow.scrolled-end::after {
    opacity: 0;
}

/* Tooltip */
.metal-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
    margin-bottom: 8px;
    z-index: 1000;
}

.metal-tooltip.visible {
    opacity: 1;
}

/* Loading state */
.metal-icon-button.loading circle {
    stroke: #30a8dc;
    stroke-width: 4;
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.product-price.price-updated {
    background-color: #E3F2FD;
    padding: 4px 8px;
    border-radius: 4px;
}

/* Screen reader only */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Disable pointer events during AJAX */
.metal-icon-row.updating {
    pointer-events: none;
    opacity: 0.7;
}

/* =========================================================================
   LOADING OVERLAY - Metal Selection Feedback
   Non-blocking notification at 30% from top, horizontally centered
   ========================================================================= */

.metal-loading-overlay {
    position: fixed;
    top: 30%; /* 30% from top of viewport */
    left: 50%;
    transform: translate(-50%, -50%); /* Center horizontally and adjust for overlay height */
    z-index: 99999;
    animation: fadeIn 0.2s ease-in;
    pointer-events: none; /* Allow clicks to pass through */
}

.metal-loading-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: white;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.metal-loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #30a8dc;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    flex-shrink: 0;
}

.metal-loading-text {
    font-size: 14px;
    color: #333;
    font-family: 'Manrope', sans-serif;
    font-weight: 500;
    white-space: nowrap;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Fade-out animation for loading overlay */
.metal-loading-overlay.fade-out {
    animation: fadeOut 0.2s ease-out;
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Responsive adjustments for loading overlay */
@media (max-width: 767px) {
    .metal-loading-overlay {
        top: 25%; /* Slightly higher on mobile for better visibility */
    }

    .metal-loading-content {
        padding: 16px 20px;
    }

    .metal-loading-spinner {
        width: 28px;
        height: 28px;
        border-width: 3px;
    }

    .metal-loading-text {
        font-size: 14px;
    }
}
