/* 
  EZ Stitch DST Viewer - Universal Styles 
  Ported from PES Viewer
*/

/* --- Variables --- */
.ez-dst-viewer {
    --ez-primary: #B11C2B;
    /* Brand Red */
    --ez-accent: #8e1622;
    /* Darker Red */
    --ez-glass: rgba(255, 255, 255, 0.95);
    /* Less transparent for clarity */
    --ez-glass-border: rgba(0, 0, 0, 0.1);
    --ez-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    --ez-text: #2c3e50;
    --ez-radius: 8px;
    /* Slightly sharper */

    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    color: var(--ez-text);
    position: relative;
    width: 100%;
    height: 100vh;
    /* Full viewport height */
    min-height: 600px;
    overflow: hidden;

    /* Engineer Grid Background */
    background-color: #f0f2f5;
    background-image:
        linear-gradient(rgba(0, 0, 0, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 0, 0, 0.05) 1px, transparent 1px);
    background-size: 20px 20px;
}

/* --- Canvas Wrapper --- */
#dstCanvasWrapper {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    z-index: 1;
}

#dstCanvasWrapper canvas {
    display: block;
    outline: none;
    cursor: url('assets/zoom-default.png') 12 12, auto;
    touch-action: none;
    /* OrbitControls needs full touch control on canvas */
}

/* Touch overlay: sits above canvas on mobile for single-finger scroll */
#mobileTouchOverlay {
    display: none;
}

@media (max-width: 768px) {
    #mobileTouchOverlay {
        display: block;
        position: absolute;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        z-index: 2;
        touch-action: pan-y;
        /* Single-finger scroll handled natively by browser */
        background: transparent;
    }
}

/* Mobile zoom buttons */
.ez-mobile-zoom {
    display: none;
}

@media (max-width: 768px) {
    .ez-mobile-zoom {
        display: flex;
        flex-direction: column;
        gap: 6px;
        position: absolute;
        right: 12px;
        bottom: 48px;
        /* Above gesture bar */
        z-index: 10;
    }

    .ez-mobile-zoom button {
        width: 40px;
        height: 40px;
        border-radius: 50%;
        border: none;
        background: rgba(255, 255, 255, 0.92);
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
        font-size: 22px;
        line-height: 1;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        color: #2c3e50;
        -webkit-tap-highlight-color: transparent;
        transition: transform 0.1s, background 0.1s;
    }

    .ez-mobile-zoom button:active {
        transform: scale(0.9);
        background: rgba(240, 242, 245, 0.98);
    }
}

/* Zoom cursor states */
#dstCanvasWrapper canvas.zoom-in-cursor {
    cursor: url('assets/zoom-in.png') 12 12, zoom-in;
}

#dstCanvasWrapper canvas.zoom-out-cursor {
    cursor: url('assets/zoom-out.png') 12 12, zoom-out;
}

/* --- Top-Left Load Button --- */
.ez-load-button {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 100;
    display: flex;
    gap: 10px;
    align-items: center;
}

.ez-btn-guide-small {
    background: #3498db;
    color: white;
    border: none;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.ez-btn-guide-small:hover {
    background: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.4);
}

.ez-btn-load {
    display: flex;
    align-items: center;
    background: var(--ez-primary);
    color: white;
    padding: 10px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 12px rgba(177, 28, 43, 0.3);
}

.ez-btn-load:hover {
    background: var(--ez-accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(177, 28, 43, 0.4);
}

@media (max-width: 768px) {
    .ez-load-button {
        top: 10px;
        left: 10px;
        flex-wrap: wrap;
        max-width: calc(100% - 20px);
    }

    .ez-btn-load {
        padding: 10px 14px;
        font-size: 13px;
        min-height: 44px;
        /* iOS touch target */
    }

    .ez-btn-load svg {
        width: 16px;
        height: 16px;
        margin-right: 6px;
    }

    /* Hide button text on very small screens */
    @media (max-width: 400px) {
        .ez-btn-text {
            display: none;
        }

        .ez-btn-load {
            padding: 10px;
        }
    }
}

/* --- Drag Hint (Empty State) --- */
.ez-dst-drag-zone {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.6);
    backdrop-filter: blur(8px);
    /* Stronger blur for modern look */
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    pointer-events: none;
    /* Let clicks pass through until active */
}

.ez-dst-upload-content {
    text-align: center;
    padding: 50px;
    border: 2px dashed rgba(52, 152, 219, 0.3);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.85);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    color: #576574;
    transform: translateY(0);
    transition: transform 0.4s ease;
    pointer-events: auto;
    /* ✅ Fix: Enable clicks on buttons */
}

/* Hover effect for drag zone */
.ez-dst-viewer:hover .ez-dst-upload-content {
    transform: translateY(-5px);
    border-color: var(--ez-primary);
}

.ez-icon-upload {
    width: 64px;
    height: 64px;
    margin-bottom: 15px;
    opacity: 0.5;
}


/* --- Glassmorphism Toolbar --- */
.ez-dst-toolbar {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    /* Reduced from 15px for compact layout */
    padding: 6px 15px;
    /* Reduced from 10px 20px */

    background: var(--ez-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--ez-glass-border);
    border-radius: 50px;
    box-shadow: var(--ez-shadow);
    width: auto;
    max-width: 95%;
    /* Increased from 90% to allow more space */
    flex-wrap: nowrap;
    /* Changed from wrap to prevent wrapping */
}

/* --- Logo --- */
.ez-logo {
    display: flex;
    align-items: center;
    height: 32px;
}

.ez-logo img {
    height: 100%;
    width: auto;
    object-fit: contain;
}

/* --- Canvas Cursor (Click-to-Zoom Feedback) --- */
#dstCanvas {
    cursor: url('assets/zoom-default.png') 12 12, default;
}

#dstCanvas.zoom-in {
    cursor: url('assets/zoom-in.png') 12 12, zoom-in;
}

#dstCanvas.zoom-out {
    cursor: url('assets/zoom-out.png') 12 12, zoom-out;
}

/* --- Mobile/Desktop Only Elements --- */
.ez-mobile-only {
    display: none;
}

.ez-desktop-only {
    display: flex;
}

@media (max-width: 768px) {
    .ez-mobile-only {
        display: flex;
    }

    .ez-desktop-only {
        display: none !important;
    }
}

/* --- Mobile Menu Dropdown --- */
.ez-mobile-menu {
    position: absolute;
    top: 70px;
    left: 10px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 150;
    min-width: 220px;
    overflow: hidden;
    animation: slideDown 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ez-mobile-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 14px 16px;
    border: none;
    background: white;
    color: #2c3e50;
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f2f5;
}

.ez-mobile-menu-item:last-child {
    border-bottom: none;
}

.ez-mobile-menu-item:active {
    background: #f8f9fa;
}

.ez-mobile-menu-item svg {
    flex-shrink: 0;
    color: var(--ez-primary);
}

/* Mobile menu divider */
.ez-mobile-menu-divider {
    height: 1px;
    background: #e0e0e0;
    margin: 4px 0;
}

/* Mobile menu controls (non-clickable items with inputs) */
.ez-menu-control {
    cursor: default;
    padding: 10px 16px;
}

.ez-menu-control:active {
    background: white;
}

/* --- Gesture Hint Toast --- */
.ez-gesture-toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 16px 24px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 500;
    text-align: center;
    z-index: 9999;
    pointer-events: none;
    animation: fadeInOut 4s ease-in-out;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

@keyframes fadeInOut {

    0%,
    100% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0.9);
    }

    10%,
    90% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
}

/* --- Mobile Gesture Hint Bar (permanent, bottom of canvas) --- */
.ez-gesture-bar {
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(6px);
    color: rgba(255, 255, 255, 0.9);
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 3;
    pointer-events: none;
    white-space: nowrap;
    letter-spacing: 0.2px;
}

.ez-gesture-divider {
    opacity: 0.4;
    font-size: 10px;
}


.ez-gesture-toast span {
    display: block;
    font-size: 24px;
    margin-bottom: 8px;
}

/* --- Floating Action Buttons (FABs) --- */
.ez-fab-container {
    display: none;
    /* Hidden on desktop */
    position: fixed;
    right: 16px;
    top: 80px;
    /* Below top buttons */
    z-index: 130;
    flex-direction: column;
    /* Stack top to bottom */
    gap: 12px;
}

@media (max-width: 768px) {
    .ez-fab-container {
        display: flex;
    }
}

.ez-fab {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    min-width: 56px;
    height: 56px;
    padding: 0 20px 0 16px;
    border: none;
    border-radius: 28px;
    background: white;
    color: #2c3e50;
    font-size: 15px;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    white-space: nowrap;
}

.ez-fab svg {
    flex-shrink: 0;
}

.ez-fab-label {
    opacity: 1;
    max-width: 200px;
    transition: opacity 0.3s, max-width 0.3s;
}

/* Minimized state */
.ez-fab.minimized {
    min-width: 56px;
    width: 56px;
    padding: 0;
    justify-content: center;
}

.ez-fab.minimized .ez-fab-label {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
}

/* Primary FAB (Quote button) */
.ez-fab-primary {
    background: var(--ez-primary);
    color: white;
}

.ez-fab-primary:active {
    background: var(--ez-accent);
}

.ez-fab:active {
    transform: scale(0.95);
}

/* Expand on tap */
.ez-fab.minimized:active {
    width: auto;
    padding: 0 20px 0 16px;
}

.ez-fab.minimized:active .ez-fab-label {
    opacity: 1;
    max-width: 200px;
}

.ez-divider {
    width: 1px;
    height: 18px;
    /* Reduced from 24px for compact toolbar */
    background: rgba(0, 0, 0, 0.1);
}

.ez-tool-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Inputs & Labels */
.ez-label-small {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 700;
    color: #7f8c8d;
}

.ez-select {
    border: none;
    background: transparent;
    font-size: 14px;
    font-weight: 600;
    color: var(--ez-text);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.ez-select:hover {
    background: rgba(0, 0, 0, 0.05);
}

.ez-select:focus {
    outline: none;
    background: rgba(0, 0, 0, 0.08);
}

.ez-checkbox-btn {
    display: flex;
    align-items: flex-end;
    /* Align bottom to match text */
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
}

.ez-checkbox-btn input {
    margin-right: 6px;
    accent-color: var(--ez-primary);
}

/* Icon Buttons */
.ez-btn-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    /* Reduced from 4px */
    color: var(--ez-text);
    font-size: 10px;
    /* Reduced from 11px */
    font-weight: 600;
    padding: 6px 8px;
    /* Reduced from 8px 12px */
    border-radius: 12px;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.ez-btn-icon:hover {
    background: rgba(52, 152, 219, 0.15);
    color: var(--ez-primary);
    transform: translateY(-2px);
}

.ez-btn-icon:active {
    transform: translateY(0);
}

.ez-btn-icon svg {
    width: 24px;
    height: 24px;
}

/* --- Metadata Panel --- */
.ez-dst-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 260px;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    z-index: 100;
    padding: 20px;
    display: none;
    /* Hidden by default — JS adds .visible to show */
    transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.3s;
}

.ez-dst-panel.visible {
    display: block;
}

.ez-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #f0f2f5;
    padding-bottom: 10px;
}

.ez-panel-header h4 {
    margin: 0;
    font-size: 15px;
    font-weight: 800;
    /* Extra Bold */
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--ez-primary);
    /* Brand Color */
}

.ez-close-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #95a5a6;
    line-height: 1;
    transition: color 0.2s;
}

.ez-close-btn:hover {
    color: var(--ez-primary);
}

.ez-stat-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    /* Gap handled by padding/border */
}

.ez-stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    padding: 8px 0;
    border-bottom: 1px solid #f8f9fa;
}

.ez-stat-item:last-child {
    border-bottom: none;
}

.ez-stat-item .ez-label {
    color: #576574;
    font-weight: 600;
    /* Bold Label */
}

.ez-stat-item .ez-value {
    font-weight: 700;
    /* Bold Value */
    color: #2c3e50;
    text-align: right;
    font-family: 'Roboto Mono', monospace;
    /* Monospace for numbers */
}

.ez-panel-footer {
    margin-top: 15px;
    padding-top: 12px;
    border-top: 2px solid #f0f2f5;
    font-size: 11px;
    color: #95a5a6;
    text-align: center;
    font-weight: 500;
}

/* --- Loader --- */
.ez-dst-loader {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(4px);
    z-index: 200;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    color: var(--ez-primary);
}

.ez-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(52, 152, 219, 0.3);
    border-top: 3px solid var(--ez-primary);
    border-radius: 50%;
    animation: ez-spin 1s linear infinite;
}

@keyframes ez-spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}


/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {

    /* Hide desktop toolbar completely on mobile */
    .ez-dst-toolbar {
        display: none !important;
    }

    /* Hide desktop panel by default (show only via FAB) */
    .ez-dst-panel {
        display: none;
        top: 80px;
        right: 10px;
        left: 10px;
        width: auto;
        max-height: 60vh;
        overflow-y: auto;
        z-index: 140;
        /* Above FABs */
    }

    .ez-dst-panel.visible {
        display: block;
        animation: slideInRight 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes slideInRight {
        from {
            transform: translateX(100%);
            opacity: 0;
        }

        to {
            transform: translateX(0);
            opacity: 1;
        }
    }

    .ez-label-small {
        display: none;
    }

    /* Hamburger menu button visibility */
    #mobileMenuBtn {
        display: flex !important;
    }
}

/* --- Buttons --- */
.ez-btn-primary {
    display: inline-block;
    background: var(--ez-primary);
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.ez-btn-primary:hover {
    background: var(--ez-accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(52, 152, 219, 0.3);
}

.ez-btn-accent {
    display: flex;
    align-items: center;
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.ez-btn-accent:hover {
    background: #c0392b;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.3);
}

/* --- Quote Form Styles --- */
.ez-quote-form {
    margin-top: 20px;
}

.ez-form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.ez-form-group {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ez-form-group.full-width {
    flex: 100%;
}

.ez-form-group label {
    font-size: 13px;
    font-weight: 600;
    color: #34495e;
}

.ez-form-group .required {
    color: #e74c3c;
}

.ez-form-group input,
.ez-form-group select,
.ez-form-group textarea {
    padding: 10px 12px;
    border: 1px solid #dfe6e9;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s;
    background: #fff;
}

.ez-form-group input:focus,
.ez-form-group select:focus,
.ez-form-group textarea:focus {
    outline: none;
    border-color: var(--ez-primary);
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

.ez-file-drop {
    border: 2px dashed #bdc3c7;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: #7f8c8d;
    background: #f9f9f9;
}

.ez-file-drop:hover,
.ez-file-drop.dragover {
    border-color: var(--ez-primary);
    background: #ebf5fb;
    color: var(--ez-primary);
}

.ez-btn-submit {
    width: 100%;
    padding: 12px;
    background: #2c3e50;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s;
}

.ez-btn-submit:hover {
    background: #34495e;
}

/* --- HIDE TOOLBAR UNTIL LOADED --- */
/* Default State: Toolbar and Panel are VISIBLE (User Feedback) */
.ez-dst-toolbar,
.ez-dst-panel {
    opacity: 1;
    pointer-events: auto;
    transform: none;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

/* Loaded State: No change needed if always visible */
.ez-dst-viewer.ez-has-file .ez-dst-toolbar {
    transform: none;
}

.ez-dst-viewer.ez-has-file .ez-dst-panel {
    transform: none;
}

/* Mobile Adjustments for Form */
@media (max-width: 600px) {
    .ez-form-row {
        flex-direction: column;
        gap: 15px;
    }

    .ez-modal-content {
        width: 95%;
        margin: 10px;
        padding: 20px;
    }
}

/* --- Modal Styles (Migrated) --- */
.ez-info-modal {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    z-index: 300;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    overflow-y: auto;
}

.ez-info-modal.active,
.ez-info-modal.visible {
    display: block;
    opacity: 1;
}

.ez-modal-content {
    max-width: 800px;
    margin: 40px auto;
    padding: 0 20px 40px;
}

.ez-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0;
    position: sticky;
    top: 0;
    background: rgba(255, 255, 255, 0.95);
    z-index: 10;
    border-bottom: 1px solid #eee;
}

.ez-close-modal {
    background: #e74c3c;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s;
}

.ez-close-modal:hover {
    transform: scale(1.05);
}

.ez-content-body h1 {
    font-size: 2.2rem;
    color: #2c3e50;
    margin-bottom: 0.5rem;
}

.ez-content-body h2 {
    font-size: 1.5rem;
    color: #34495e;
    margin-top: 2rem;
}

.ez-content-body h3 {
    font-size: 1.2rem;
    color: #3498db;
    margin-top: 1.5rem;
}

.ez-content-body p {
    line-height: 1.6;
    color: #576574;
    font-size: 1.05rem;
}

.ez-content-body ul {
    line-height: 1.6;
    color: #576574;
}

.ez-content-body li {
    margin-bottom: 8px;
}

/* Free Samples Modal Styles */
.ez-samples-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.ez-sample-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: 1px solid #eee;
    text-align: center;
}

.ez-sample-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.12);
}

.ez-sample-img-container {
    position: relative;
    width: 100%;
    height: 200px;
    background: #f8f9fa;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ez-sample-img-container img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    padding: 10px;
    transition: transform 0.3s ease;
}

.ez-sample-card:hover .ez-sample-img-container img {
    transform: scale(1.05);
}

.ez-sample-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ez-sample-card:hover .ez-sample-overlay {
    opacity: 1;
}

.ez-sample-card h3 {
    margin: 15px 0 10px;
    font-size: 16px;
    color: #2c3e50;
    font-weight: 600;
}

.ez-btn-sample-download {
    display: inline-block;
    margin-bottom: 20px;
    padding: 8px 20px;
    background: #27ae60;
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-weight: 600;
    font-size: 13px;
    transition: background 0.2s, transform 0.2s;
}

.ez-btn-sample-download:hover {
    background: #219150;
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(39, 174, 96, 0.3);
}

/* ========================================
   MOBILE OPTIMIZATIONS
   ======================================== */

/* Tablet and Mobile (768px and below) */
@media (max-width: 768px) {

    /* Larger Touch Targets (Minimum 48x48px) */
    .ez-btn-icon {
        min-width: 48px;
        min-height: 48px;
        padding: 12px;
    }

    .ez-btn-guide-small {
        min-width: 44px;
        min-height: 44px;
        padding: 12px 14px;
        font-size: 13px;
    }

    .ez-btn-load {
        min-height: 48px;
        padding: 12px 16px;
    }

    /* Simplified Toolbar - Hide Text Labels on Small Screens */
    .ez-btn-icon span {
        display: none;
        /* Show icons only */
    }

    /* Hide Palette Selector on Mobile (Not Essential) */
    .ez-tool-group:has(#paletteSelect) {
        display: none;
    }

    /* Larger Loader for Visibility */
    .ez-dst-loader {
        font-size: 18px;
    }

    .ez-spinner {
        width: 60px;
        height: 60px;
        border-width: 4px;
    }

    /* Improve Modal Readability */
    .ez-modal-content {
        padding: 15px;
    }

    .ez-content-body h1 {
        font-size: 1.8rem;
    }

    .ez-content-body h2 {
        font-size: 1.3rem;
    }

    .ez-content-body p {
        font-size: 1rem;
    }

    /* Form Input Touch Targets */
    .ez-form-group input,
    .ez-form-group select,
    .ez-form-group textarea {
        min-height: 44px;
        font-size: 16px;
        /* Prevents iOS zoom on focus */
    }

    .ez-btn-submit {
        min-height: 48px;
        font-size: 17px;
    }

    /* Reduce Panel Padding on Mobile */
    .ez-dst-panel {
        padding: 15px;
        width: calc(100% - 20px);
        max-width: 400px;
        margin: 0 auto;
        left: 10px;
        right: 10px;
    }

    /* Zoom Buttons - Show Text on Mobile for Clarity */
    #zoomInBtn span,
    #zoomOutBtn span {
        display: inline;
        /* Override general rule for zoom buttons */
        font-size: 12px;
    }
}

/* Small Mobile (480px and below) */
@media (max-width: 480px) {

    /* Even More Compact Toolbar */
    .ez-dst-toolbar {
        gap: 8px;
        padding: 6px 10px;
    }

    .ez-btn-icon {
        padding: 10px;
    }

    .ez-btn-icon svg {
        width: 20px;
        height: 20px;
    }

    /* Hide Dividers on Very Small Screens */
    .ez-divider {
        display: none;
    }

    /* Stack Load Buttons Vertically */
    .ez-load-button {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    /* Smaller Logo */
    .ez-logo {
        height: 24px;
    }

    /* Compact Panel */
    .ez-dst-panel {
        font-size: 13px;
    }

    .ez-stat-item {
        font-size: 12px;
        padding: 6px 0;
    }

    /* Reduce Modal Padding */
    .ez-modal-content {
        margin: 20px auto;
        padding: 10px;
    }

    .ez-modal-header {
        padding: 15px 0;
    }

    .ez-modal-header h2 {
        font-size: 1.2rem;
    }
}

/* Landscape Mobile Optimization */
@media (max-width: 768px) and (orientation: landscape) {

    /* Reduce Top/Bottom Spacing in Landscape */
    .ez-load-button {
        top: 5px;
        left: 5px;
    }

    .ez-dst-toolbar {
        bottom: 5px;
    }

    .ez-dst-panel {
        bottom: 60px;
    }

    /* Compact Upload Content */
    .ez-dst-upload-content {
        padding: 20px;
    }

    .ez-dst-upload-content h3 {
        font-size: 1.2rem;
    }
}

/* Touch-Friendly Hover States (Disable on Touch Devices) */
@media (hover: none) {

    .ez-btn-icon:hover,
    .ez-btn-load:hover,
    .ez-btn-primary:hover,
    .ez-btn-accent:hover {
        transform: none;
        /* Disable lift effect on touch */
    }
}

/* High DPI Screens (Retina) */
@media (-webkit-min-device-pixel-ratio: 2),
(min-resolution: 192dpi) {

    /* Ensure crisp rendering on Retina displays */
    .ez-logo img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* success/error msg */
/* success/error msg */
.ez-success-msg {
    color: #27ae60;
    margin-top: 10px;
    font-weight: 600;
}

.ez-error-msg {
    color: #c0392b;
    margin-top: 10px;
    font-weight: 600;
}

/* --- Added Missing Features --- */

/* Gesture Hint Toast */
.ez-gesture-toast {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(44, 62, 80, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 14px;
    font-weight: 500;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    pointer-events: none;
    animation: slideUpFade 0.5s ease-out;
    transition: opacity 0.5s;
}

.ez-gesture-toast span {
    font-size: 1.2rem;
}

.ez-gesture-toast.fade-out {
    opacity: 0;
}

@keyframes slideUpFade {
    from {
        transform: translate(-50%, 20px);
        opacity: 0;
    }

    to {
        transform: translate(-50%, 0);
        opacity: 1;
    }
}

/* FAB Minimal Mode (Slide Out partially) */
.ez-fab {
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s;
}

.ez-fab.minimized {
    transform: translateX(calc(100% + 10px));
    /* Slide off screen right */
    box-shadow: none;
    opacity: 0.6;
}

/* Left aligned FABs might need negative translate, but current layout puts most on right? 
   If FABs are on left, we need a specific rule. Assuming they are right-aligned mostly or bottom. 
   Actually, FAB container .ez-fab-container dictates position. */

/* Spinner Animation */
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.ez-spinner {
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 3px solid #fff;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    vertical-align: middle;
    margin-right: 8px;
}

/* History List Styles */
#historyList {
    list-style: none;
    padding: 0;
    margin: 0;
}

#historyList li:last-child {
    border-bottom: none !important;
}


/* PDF Button in Toolbar (Hidden by default until file load) */
#downloadPdfBtn {
    display: none;
}

/* Ensure it shows flex when active */
#downloadPdfBtn[style*="display: flex"] {
    display: flex !important;
}

/* === FAB (Floating Action Buttons) === */
.ez-fab-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 200;
    display: none;
    /* Hidden by default, shown on mobile */
    flex-direction: column;
    gap: 12px;
    align-items: flex-end;
}

@media (max-width: 768px) {
    .ez-fab-container {
        display: flex;
    }
}

.ez-fab {
    display: flex;
    align-items: center;
    gap: 10px;
    background: white;
    color: #2c3e50;
    border: none;
    padding: 12px 16px;
    border-radius: 50px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.ez-fab svg {
    flex-shrink: 0;
}

.ez-fab-label {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1;
    max-width: 150px;
}

.ez-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.ez-fab:active {
    transform: translateY(0);
}

/* Minimized State - Icon Only */
.ez-fab.minimized {
    padding: 12px;
    width: 48px;
    height: 48px;
    border-radius: 50%;
}

.ez-fab.minimized .ez-fab-label {
    opacity: 0;
    max-width: 0;
    overflow: hidden;
}

/* Primary FAB (Quote Button) */
.ez-fab-primary {
    background: linear-gradient(135deg, #B11C2B 0%, #8e1622 100%);
    color: white;
}

.ez-fab-primary:hover {
    background: linear-gradient(135deg, #8e1622 0%, #6d1119 100%);
}

/* === Mobile Improvements === */

/* History list touch-friendly items */
#historyList {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 60vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#historyList li {
    min-height: 52px;
}

/* Modals: bottom-sheet on mobile */
@media (max-width: 768px) {
    .ez-modal .ez-modal-content {
        width: 100% !important;
        max-width: 100% !important;
        max-height: 85vh;
        border-radius: 16px 16px 0 0;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        margin: 0;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .ez-modal {
        align-items: flex-end;
    }

    /* Metadata panel: compact popup near info FAB (top-right) on mobile */
    .ez-dst-panel {
        display: block !important;
        position: fixed !important;
        top: 70px !important;
        right: 12px !important;
        left: auto !important;
        bottom: auto !important;
        width: 260px !important;
        max-height: 70vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        border-radius: 14px !important;
        transform: scale(0.85) translateY(-10px);
        transform-origin: top right;
        opacity: 0;
        pointer-events: none;
        transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.2s;
        z-index: 9000 !important;
        padding: 14px !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.22) !important;
    }

    .ez-dst-panel.visible {
        transform: scale(1) translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    /* Single-column stats in compact popup */
    .ez-stat-grid {
        display: block;
    }

    .ez-stat-item {
        font-size: 11px !important;
        padding: 5px 4px !important;
        border-bottom: 1px solid #f0f2f5;
        flex-direction: column;
        align-items: flex-start;
        gap: 1px;
    }

    .ez-label {
        font-size: 10px !important;
        color: #95a5a6 !important;
    }

    .ez-value {
        font-size: 12px !important;
        font-weight: 700 !important;
    }

    .ez-panel-header {
        margin-bottom: 10px !important;
        padding-bottom: 8px !important;
    }

    .ez-panel-header h4 {
        font-size: 13px !important;
    }

    .ez-panel-footer {
        margin-top: 8px !important;
        padding-top: 8px !important;
        font-size: 10px !important;
    }


    /* FAB: icon-only circles on mobile */
    .ez-fab {
        padding: 10px;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        justify-content: center;
    }

    .ez-fab .ez-fab-label {
        display: none;
        /* Always hide labels on mobile — icon only */
    }

    .ez-fab svg {
        width: 20px !important;
        height: 20px !important;
        flex-shrink: 0;
        display: block !important;
        opacity: 1 !important;
    }

    /* FAB container: tighter gap on mobile */
    .ez-fab-container {
        gap: 8px;
        top: 12px;
        right: 12px;
    }
}

/* Share button */
.ez-share-btn {
    background: #27ae60;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: background 0.2s;
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

.ez-share-btn:hover {
    background: #219a52;
}

/* Utility: mobile-only elements */
.ez-mobile-only {
    display: none !important;
}

@media (max-width: 768px) {
    .ez-mobile-only {
        display: flex !important;
    }
}