/**
 * EMBROIDERY CRITICAL FIXES - MINIMAL APPROACH
 * Last Updated: 2025-10-16
 * Purpose: Fix ONLY essential visual issues without breaking layouts
 * Philosophy: Gentle fixes, no aggressive !important overrides
 */

/* ==================================================
   CRITICAL: HIDE GIANT DECORATIVE CIRCLES/BACKGROUNDS
   ================================================== */

/* Remove any large SVG backgrounds or decorative elements */
svg[class*="background"],
svg[class*="decoration"],
svg[class*="circle-bg"],
.background-decoration,
.decorative-circle,
.bg-decoration {
    display: none !important;
    visibility: hidden !important;
}

/* Hide any absolutely positioned large elements at the bottom */
body > div[style*="position: absolute"][style*="bottom"],
body > svg[style*="position: absolute"][style*="bottom"],
.page-background,
.background-shape {
    display: none !important;
}

/* Ensure body doesn't have giant circular gradients */
body {
    background-image: none !important;
}

/* ==================================================
   GENTLE CENTERING - NO !important OVERRIDES
   ================================================== */

/* Center content sections - gentle approach */
.phase-section {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.logos-container,
.color-swatches-container,
.product-search-container,
.product-display-section,
.products-in-quote-section,
.customer-info-section,
.quote-summary-section {
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

/* ==================================================
   Z-INDEX MANAGEMENT
   ================================================== */

/* Ensure proper stacking order */
.embroidery-header { z-index: 1000; }
.phase-nav { z-index: 100; }
.phase-section { z-index: 10; }
.sidebar-modal { z-index: 2000; }
.sidebar-backdrop { z-index: 1999; }
.modal-overlay { z-index: 9999; }

/* ==================================================
   PREVENT VISUAL GLITCHES
   ================================================== */

/* Smooth rendering */
* {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Prevent layout shift */
img {
    max-width: 100%;
    height: auto;
}

/* Clear floats */
.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

/* ==================================================
   TARGETED FIXES FOR SPECIFIC LAYOUT ISSUES
   ================================================== */

/* FORCE color swatches to display as horizontal grid (not vertical stack) */
.qb-swatch-grid,
#color-swatches-container {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(60px, 1fr)) !important;
    gap: 16px !important;
    max-width: 100% !important;
}

/* FORCE products list to proper position (not bottom-left corner) */
.products-list,
#products-list {
    display: block !important;
    width: 100% !important;
    max-width: 900px !important;
    margin: 2rem auto 0 auto !important;
    position: relative !important;
    float: none !important;
    clear: both !important;
}

/* STYLE suggestion dropdown items properly */
.suggestion-item {
    padding: 12px 16px !important;
    cursor: pointer !important;
    border-bottom: 1px solid #e5e7eb !important;
    transition: background 0.2s ease !important;
    background: white !important;
    display: block !important;
}

.suggestion-item:hover {
    background: #f3f4f6 !important;
}

.suggestion-item:last-child {
    border-bottom: none !important;
}

.suggestion-item strong {
    color: #3a7c52 !important;
    font-weight: 600 !important;
}

/* ==================================================
   TOGGLE SWITCH FIX - Enhanced Layout & Styling
   ==================================================

   ⚠️ CRITICAL: THIS IS THE SINGLE SOURCE OF TRUTH FOR TOGGLE STYLES

   This section controls toggle switches on BOTH:
   - Embroidery Quote Builder (/quote-builders/embroidery-quote-builder.html)
   - Cap Embroidery Quote Builder (/quote-builders/cap-embroidery-quote-builder.html)

   ⚠️ CHANGES HERE AFFECT BOTH PAGES SIMULTANEOUSLY

   DO NOT modify toggle CSS in page-specific files:
   - embroidery-quote-builder-modern.css
   - cap-embroidery-quote-builder-modern.css

   To modify toggle appearance:
   1. Edit this file only
   2. Test on BOTH quote builder pages side-by-side
   3. Clear browser cache before testing
   4. Verify pixel-perfect consistency

   Last Updated: 2025-10-17
   ================================================== */

/* Visual grouping for toggle sections */
.logo-form .form-row {
    background: #f8fafc !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 8px !important;
    padding: 16px !important;
    margin-bottom: 16px !important;
    transition: all 0.2s ease !important;
}

.logo-form .form-row:hover {
    border-color: #cbd5e1 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04) !important;
}

/* Improved description text */
.logo-description {
    color: #64748b !important;
    font-size: 0.875rem !important;
    margin-bottom: 12px !important;
    font-style: italic !important;
    line-height: 1.5 !important;
}

/* Tighter toggle layout - label and control together */
.form-group .toggle-label {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: flex-start !important;  /* CHANGED from space-between */
    gap: 12px !important;  /* NEW: Small gap between text and toggle */
    width: 100% !important;
    margin: 0 !important;
    padding: 8px 0 !important;
    cursor: pointer !important;
    user-select: none !important;
}

/* Enhanced toggle text styling */
.toggle-text {
    font-weight: 500 !important;
    color: #1f2937 !important;  /* Darker for better contrast */
    font-size: 0.9375rem !important;
    line-height: 1.4 !important;  /* Better readability */
}

/* Toggle switch with smooth transitions */
.toggle-switch {
    background: #cbd5e1 !important;  /* Gray background when unchecked */
    cursor: pointer !important;
    transition: background 0.2s ease, box-shadow 0.2s ease, transform 0.1s ease !important;  /* Smooth transitions */
    flex-shrink: 0 !important;  /* Prevent toggle from shrinking */
    position: relative !important;
    width: 56px !important;
    height: 32px !important;
    border-radius: 16px !important;
}

/* Change background when checked - using :has() selector for parent-child relationship */
.toggle-switch:has(.toggle-input:checked),
.toggle-switch.on {
    background: #3a7c52 !important;  /* Green when checked */
}

/* Create the white circle using ::after pseudo-element */
.toggle-switch::after {
    content: "" !important;  /* CRITICAL: Required to create the pseudo-element */
    position: absolute !important;
    top: 4px !important;
    left: 4px !important;
    width: 24px !important;
    height: 24px !important;
    border-radius: 50% !important;  /* Makes it circular */
    background: white !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2) !important;
    transition: transform 0.2s ease !important;  /* Smooth slide animation */
}

/* Move circle when checked - using :has() selector */
.toggle-switch:has(.toggle-input:checked)::after,
.toggle-switch.on::after {
    transform: translateX(24px) !important;
}

/* Enhanced focus state - using :has() selector */
.toggle-switch:has(.toggle-input:focus) {
    box-shadow: 0 0 0 3px rgba(58, 124, 82, 0.2) !important;
    outline: none !important;
}

/* Focus visible for keyboard navigation (accessibility) */
.toggle-switch:focus-visible {
    outline: 2px solid #3a7c52 !important;
    outline-offset: 2px !important;
}

/* Improved hover effects */
.toggle-label:hover .toggle-switch {
    opacity: 0.9 !important;
}

.toggle-switch:hover {
    background: #b0bcc8 !important;  /* Slightly darker gray on hover */
}

.toggle-switch:has(.toggle-input:checked):hover,
.toggle-switch.on:hover {
    background: #2f6742 !important;  /* Darker green on hover when checked */
}

/* Active state - tactile press feedback */
.toggle-label:active .toggle-switch {
    transform: scale(0.95) !important;
}

/* Disabled state */
.toggle-label.disabled {
    opacity: 0.5 !important;
    cursor: not-allowed !important;
    pointer-events: none !important;
}

.toggle-label.disabled .toggle-switch {
    background: #e5e7eb !important;
    cursor: not-allowed !important;
}

/* Loading state for async operations */
.toggle-switch.loading {
    opacity: 0.6 !important;
    cursor: wait !important;
    animation: togglePulse 1.5s ease-in-out infinite !important;
}

@keyframes togglePulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.8; }
}

/* Hide the actual checkbox input */
.toggle-input {
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    position: absolute !important;
}

/* ==================================================
   RESPONSIVE - MOBILE ADJUSTMENTS
   ================================================== */

@media (max-width: 768px) {
    .phase-section {
        max-width: 100%;
        padding: 1.5rem;
    }

    /* All containers full width on mobile */
    .logos-container,
    .color-swatches-container,
    .product-search-container,
    .product-display-section,
    .products-in-quote-section,
    .customer-info-section,
    .quote-summary-section {
        max-width: 100%;
    }

    /* Adjust color swatches for mobile */
    .qb-swatch-grid,
    #color-swatches-container {
        grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)) !important;
        gap: 12px !important;
    }
}
