/* ============================================================
   Custom Bike – Frontend CSS
   Encapsulado bajo #cb-builder  para resistir resets de temas.
============================================================ */

/* Wrapper del shortcode */
.cb-builder-wrapper {
    width: 100%;
}
.cb-builder-wrapper.cb-alignfull {
    position: relative;
    left: 0;
    right: 0;
}

/* Reset interno: neutraliza cualquier herencia del tema */
#cb-builder,
#cb-builder *,
#cb-builder *::before,
#cb-builder *::after {
    box-sizing: border-box !important;
    -webkit-tap-highlight-color: transparent;
}

#cb-builder {
    --cb-primary: var(--wp--preset--color--primary, var(--wp-primary, var(--color-primary, #FF6600)));
    --cb-primary-dark: var(--wp--preset--color--primary-dark, #e55a00);
    --cb-bg: var(--wp--preset--color--base, var(--color-background, #ffffff));
    --cb-surface: var(--wp--preset--color--base-2, var(--color-surface, #ffffff));
    --cb-surface-light: var(--wp--preset--color--base-3, var(--color-surface-2, #ffffff));
    --cb-text: var(--wp--preset--color--contrast, var(--color-text, #1a1a1a));
    --cb-text-muted: var(--wp--preset--color--contrast-2, var(--color-text-muted, #666666));
    --cb-border: var(--wp--preset--color--base-3, var(--color-border, #dedede));

    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif
    font-size: 16px
    color: var(--cb-text)
    background: var(--cb-bg)
    border-radius: var(--cb-radius);
    overflow: visible;
    box-shadow: var(--cb-shadow);
    width: 100%;
    margin: 0 auto;
    -webkit-font-smoothing: antialiased;
}

/* Garantizar que h*, p, ul, ol no hereden estilos raros del tema */
#cb-builder h1, #cb-builder h2, #cb-builder h3,
#cb-builder h4, #cb-builder h5, #cb-builder h6 {
    font-family: inherit;
    color: inherit;
    font-weight: 700;
    line-height: 1.2;
    margin: 0;
    padding: 0;
}

#cb-builder p { margin: 0; padding: 0; color: inherit; }
#cb-builder ul, #cb-builder ol { list-style: none; margin: 0; padding: 0; }
#cb-builder a { color: var(--cb-primary); text-decoration: none; }
#cb-builder img { max-width: 100%; display: block; }
#cb-builder button { font-family: inherit !important; cursor: pointer; }
#cb-builder input, #cb-builder select, #cb-builder textarea {
    font-family: inherit;
}

/* Alias: mantener .cb-builder para compatibilidad con el HTML existente */
.cb-builder {
    display: flex;
    flex-direction: column;
    min-height: 700px;
}

/* Phases */
.cb-phase { display: none; }
.cb-phase-active { display: block; }

/* Upload */
.cb-upload-card {
    text-align: center;
    padding: 3rem 2rem;
}

.cb-title {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 2rem;
}

.cb-drop-zone {
    border: 2px dashed var(--cb-border);
    border-radius: var(--cb-radius);
    padding: 3rem 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    background: var(--cb-surface);
    max-width: 500px;
    margin: 0 auto;
}

.cb-drop-zone:hover,
.cb-drop-zone.dragover {
    border-color: var(--cb-primary);
    background: var(--cb-surface-light);
}

.cb-icon-upload {
    width: 48px;
    height: 48px;
    color: var(--cb-primary);
    margin-bottom: 1rem;
}

.cb-drop-text {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.cb-drop-hint {
    font-size: 0.85rem;
    color: var(--cb-text-muted);
}

/* Calibrate */
.cb-calibrate-card {
    padding: 2rem;
    text-align: center;
}

.cb-calibrate-card h3 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
}

.cb-calibrate-card p {
    color: var(--cb-text-muted);
    margin-bottom: 1.5rem;
}

.cb-calibrate-canvas {
    max-width: 100%;
    border-radius: var(--cb-radius-sm);
    background: var(--cb-surface);
    cursor: crosshair;
    display: block;
    margin: 0 auto 1.5rem;
    box-shadow: var(--cb-shadow-sm);
}

.cb-calibrate-controls {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.cb-distance-input {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: var(--cb-surface);
    padding: 0.75rem 1rem;
    border-radius: var(--cb-radius-sm);
}

.cb-distance-input label {
    font-size: 0.9rem;
    color: var(--cb-text-muted);
}

.cb-distance-input input {
    width: 80px;
    padding: 0.5rem;
    border: 1px solid var(--cb-border);
    border-radius: 8px;
    background: var(--cb-bg);
    color: var(--cb-text);
    text-align: center;
}

/* Buttons */
.cb-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 10px;
    font-size: 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.cb-btn-primary {
    background: var(--cb-primary);
    color: #fff;
}

.cb-btn-primary:hover {
    background: var(--cb-primary-dark);
    transform: translateY(-1px);
}

.cb-btn-secondary {
    background: var(--cb-surface-light);
    color: var(--cb-text);
    border: 1px solid var(--cb-border);
}

.cb-btn-secondary:hover {
    background: var(--cb-border);
}

.cb-btn-block {
    width: 100%;
}

/* Builder Layout */
.cb-builder-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 1.5rem;
    padding: 1.5rem;
    min-height: 500px;
}

/* Canvas Area */
.cb-canvas-area {
    position: relative;
    background: var(--cb-surface);
    border-radius: var(--cb-radius);
    overflow: hidden;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cb-main-canvas {
    display: block;
    max-width: 100%;
    touch-action: none;
    user-select: none;
    cursor: grab;
}

.cb-main-canvas:active {
    cursor: grabbing;
}

/* Zoom Controls */
.cb-zoom-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--cb-surface-light);
    border-radius: 12px;
    padding: 0.5rem;
    box-shadow: 0px 1px 10px rgba(0, 0, 0, 0.15);
}

.cb-zoom-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--cb-surface);
    border: 1px solid var(--cb-border);
    border-radius: 8px;
    color: var(--cb-text);
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.2s;
}

.cb-zoom-btn:hover {
    background: var(--cb-primary);
    border-color: var(--cb-primary);
}
  
/* Help Modal */
.cb-help-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    padding: 1rem;
}

.cb-help-modal {
    background: var(--cb-surface);
    border-radius: var(--cb-radius);
    border: 1px solid var(--cb-border);
    width: 100%;
    max-width: 400px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--cb-shadow);
}

.cb-help-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--cb-border);
}

.cb-help-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--cb-text);
}

.cb-help-close {
    background: none;
    border: none;
    color: var(--cb-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
}

.cb-help-close:hover {
    background: rgba(255,255,255,0.08);
    color: var(--cb-text);
}

.cb-help-body {
    padding: 1.25rem;
}

/* Mobile: help modal arriba del viewport para no requerir scroll */
@media (max-width: 768px) {
    .cb-help-overlay {
        align-items: flex-start;
        padding-top: 0.5rem;
    }
    .cb-help-modal {
        margin-top: 0;
    }
}

/* Product Bar */
.cb-product-bar {
    background: var(--cb-surface);
    border-top: 1px solid var(--cb-border);
    padding: 0.5rem 0.5rem;
}

.cb-filters {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

/* Products Scroll */
.cb-products-scroll {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--cb-border) transparent;
}

.cb-products-scroll::-webkit-scrollbar {
    height: 6px;
}

.cb-products-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.cb-products-scroll::-webkit-scrollbar-thumb {
    background: var(--cb-border);
    border-radius: 6px;
}

.cb-product-item {
    flex-shrink: 0;
    width: 120px;
    background: var(--cb-surface-light);
    border: 1px solid var(--cb-border);
    border-radius: var(--cb-radius-sm);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cb-product-item:hover {
    border-color: var(--cb-primary);
    transform: translateY(-4px);
    box-shadow: var(--cb-shadow-sm);
}

.cb-product-item img {
    width: 120px;
    height: 120px;
    object-fit: contain;
    margin-bottom: 1rem;
    background: rgba(255,255,255,0.05);
}

.cb-product-item .cb-product-name {
    font-size: 1rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.3rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cb-product-item .cb-product-price {
    font-size: 0.9rem;
    color: var(--cb-primary);
    font-weight: 700;
}

.cb-product-item .cb-product-add {
    font-size: 1rem;
    font-weight: 700;
    color: var(--cb-text-muted);
    margin-top: 0.4rem;
    padding: 4px 8px;
    border-radius: 6px;
    background: rgba(255,102,0,0.08);
    border: 1px solid rgba(255,102,0,0.15);
    transition: all 0.2s;
}

.cb-product-item:hover .cb-product-add {
    color: #fff;
    background: var(--cb-primary);
    border-color: var(--cb-primary);
}

.cb-product-no-img {
    width: 80px;
    height: 80px;
    margin: 0 auto 0.5rem;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--cb-text-muted);
}

.cb-no-products {
    padding: 2rem;
    text-align: center;
    color: var(--cb-text-muted);
    font-size: 0.9rem;
    width: 100%;
}

/* Responsive */
@media (max-width: 1100px) {
    .cb-builder-layout {
        grid-template-columns: 1fr;
    }

    .cb-panel-card {
        flex: 1;
    }
}

@media (.cb-product-item .cb-product-add)     {
    padding: 0px;
    }

@media (max-width: 600px) {
    .cb-builder {
        border-radius: 0;
    }

    .cb-builder-layout {
        padding: 0.5rem;
    }

    .cb-zoom-controls,
    .cb-drawing-toolbar {
        transform: scale(0.85);
    }
}

/* ============================================================
   NUEVO DISEÑO SINGLE-SCREEN
   (Las clases anteriores quedan sin uso, se mantienen por compat)
============================================================ */

/* Top Bar */
.cb-top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    background: var(--cb-surface);
    border-bottom: 1px solid var(--cb-border);
}

.cb-top-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 700;
    color: var(--cb-text);
}

.cb-top-upload button svg { flex-shrink: 0; }

.cb-top-upload .cb-btn-secondary {
    padding: 0.65rem 1.1rem;
    font-size: 0.92rem;
}
.cb-top-upload .cb-btn-secondary svg {
    width: 18px;
    height: 18px;
}

/* Workspace */
.cb-workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0;
}

/* Canvas Overlay (instrucciones sobre canvas vacío) */
.cb-canvas-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 2rem;
    background: #ffffff;
    backdrop-filter: blur(4px);
    border-radius: var(--cb-radius);
    z-index: 10;
    text-align: center;
}
.cb-canvas-overlay.cb-hidden { display: none; }
.cb-canvas-overlay-title {
    font-size: 2rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--cb-primary);
}
.cb-canvas-overlay-instructions {
    font-size: 1.5rem;
    color: var(--cb-text-muted);
    max-width: 500px;
}
.cb-canvas-overlay-instructions ol,
.cb-canvas-overlay-instructions ul {
    padding-left: 1.2rem;
    margin: 0;
    text-align: left;
}
.cb-canvas-overlay-instructions li { margin-bottom: 0.5rem; }
.cb-canvas-overlay-instructions strong { color: var(--cb-text); }
.cb-canvas-overlay-upload { margin-top: 0.5rem; cursor: pointer; }

/* Canvas Wrap */
.cb-canvas-wrap {
    position: relative;
    background: var(--cb-surface);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 60dvh;
    min-height: 300px;
}

/* Cuadro de calibración — esquina superior derecha del canvas */
.cb-calibrate-box {
    position: absolute;
    top: 12px;
    right: 12px;
    display: none;
    flex-direction: column;
    gap: 0.5rem;
    background: var(--cb-surface);
    border: 1.5px solid var(--cb-primary);
    border-radius: var(--cb-radius-sm);
    padding: 0.75rem 1rem;
    box-shadow: var(--cb-shadow-sm);
    z-index: 8;
    min-width: 250px;
    max-width: 300px;
}
.cb-calibrate-box-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--cb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.cb-calibrate-box-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}
.cb-calibrate-box-row input {
    flex: 1;
    min-width: 0;
    padding: 0.45rem 0.6rem;
    border: 1px solid var(--cb-border);
    border-radius: 6px;
    background: var(--cb-bg);
    color: var(--cb-text);
    font-size: 0.95rem;
    text-align: center;
}
.cb-calibrate-box-row input:focus {
    outline: none;
    border-color: var(--cb-primary);
}
.cb-calibrate-box-row .cb-btn-primary {
    padding: 0.45rem 0.85rem;
    font-size: 0.85rem;
    white-space: nowrap;
}
.cb-calibrate-reset-btn {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem !important;
    align-self: flex-start;
}

.cb-btn-ghost {
    background: transparent;
    color: var(--cb-text-muted);
    border: 1px solid var(--cb-border);
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}
.cb-btn-ghost:hover { color: var(--cb-text); }

/* Zoom Controls */
.cb-zoom-controls {
    position: absolute;
    bottom: 1rem;
    right: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    background: var(--cb-surface-light);
    border-radius: 12px;
    padding: 0.4rem;
}

.cb-zoom-btn {
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 8px;
    background: var(--cb-surface);
    color: var(--cb-text);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.cb-zoom-btn:hover {
    background: var(--cb-primary);
    color: #fff;
}

/* Sidebar */
.cb-sidebar {
    background: var(--cb-bg);
    border-left: 1px solid var(--cb-border);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cb-card {
    background: var(--cb-surface);
    border: 1px solid var(--cb-border);
    border-radius: var(--cb-radius-sm);
    padding: 1rem;
}

.cb-card-muted {
    background: rgba(26,26,46,0.5);
}

.cb-card-title {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--cb-text-muted);
    margin-bottom: 0.75rem;
}

.cb-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 0;
    font-size: 1rem;
    border-bottom: 1px solid var(--cb-border);
}
.cb-card-row:last-of-type { border-bottom: none; }

.cb-card-row.cb-total {
    font-size: 1.2rem;
    font-weight: 700;
    padding-top: 0.75rem;
    margin-top: 0.25rem;
    border-top: 2px solid var(--cb-primary);
}

.cb-cart-message {
    font-size: 0.9rem;
    color: #4caf50;
    margin-top: 0.5rem;
    text-align: center;
    min-height: 1.2em;
}

.cb-instructions {
    font-size: 0.9rem;
    color: var(--cb-text-muted);
}
.cb-instructions ol,
.cb-instructions ul {
    padding-left: 1.2rem;
    margin: 0;
}
.cb-instructions li { margin-bottom: 0.5rem; }
.cb-instructions p { margin-bottom: 0.5rem; line-height: 1.5; }
.cb-instructions strong { color: #e8e8f0; }
.cb-instructions a { color: var(--cb-primary); text-decoration: underline; }

/* Product Bar */
.cb-product-bar {
    background: var(--cb-surface);
    border-top: 1px solid var(--cb-border);
}

.cb-bar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.75rem;
    gap: 1rem;
    flex-wrap: wrap;
}

.cb-bar-filters {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: nowrap;
    flex: 1;
    min-width: 0;
}

.cb-bar-info {
    font-size: 0.9rem;
    color: var(--cb-text-muted);
    background: var(--cb-bg);
    padding: 0.35rem 0.75rem;
    border-radius: 8px;
}

/* Flechas de scroll */

.cb-products-scroll {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-top: 0.5rem;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--cb-border) transparent;
}

.cb-products-scroll::-webkit-scrollbar {
    height: 6px;
}
.cb-products-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.cb-products-scroll::-webkit-scrollbar-thumb {
    background: var(--cb-border);
    border-radius: 3px;
}

.cb-products-scroll-wrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
	margin-left: -20px;
	margin-right: -20px;
}

.cb-scroll-arrow {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 1px solid var(--cb-border);
    background: var(--cb-surface);
    display: flex;
    align-items: center;
    transition: all 0.2s;
    z-index: 2;
	box-shadow: 0px 1px 10px rgba(0, 0, 0, 0.15);
}
.cb-scroll-arrow:hover {
    background: var(--cb-primary);
    border-color: var(--cb-primary);
}
.cb-scroll-arrow svg {
    pointer-events: none;
}

/* Product Item */
.cb-product-item {
    flex-shrink: 0;
    width: 120px;
    padding: 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cb-product-item:hover {
    border-color: var(--cb-primary);
    transform: translateY(-4px);
    box-shadow: var(--cb-shadow-sm);
}

.cb-product-unavailable {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}
.cb-product-unavailable:hover {
    border-color: var(--cb-border);
    transform: none;
    box-shadow: none;
}

.cb-product-item img {
    width: 80px;
    height: 80px;
    object-fit: contain;
    margin: 0 auto 0.5rem;
    background: ffffff;
}

.cb-product-no-img {
    width: 80px;
    height: 80px;
    margin: 0 auto 0.5rem;
    border-radius: 8px;
    background: rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--cb-text-muted);
}

.cb-product-item .cb-product-name {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: 0.3rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.cb-product-item .cb-product-variation {
    font-size: 1rem;
    color: var(--cb-text-muted);
    margin-bottom: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cb-product-item .cb-product-price {
	display: none;
	font-size: 0.8rem;
    color: var(--cb-primary);
    font-weight: 700;
}

.cb-product-item .cb-product-dims {
	font-size: 0.8rem;
    color: var(--cb-text-muted);
    margin-top: 0.2rem;
}

.cb-product-item .cb-product-add {
    display: none;
}

.cb-product-item:hover .cb-product-add {
    color: #fff;
    background: var(--cb-primary);
    border-color: var(--cb-primary);
}

.cb-no-products {
    padding: 2rem;
    text-align: center;
    color: var(--cb-text-muted);
    font-size: 0.9rem;
    width: 100%;
}

/* Responsive */
@media (max-width: 1100px) {
    .cb-workspace {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr auto;
    }
    .cb-bar-header { margin-bottom: 0; }
}

@media (max-width: 600px) {
	
    .cb-top-upload .cb-btn-secondary {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
        gap: 0.35rem;
    }
    .cb-top-upload .cb-btn-secondary svg { width: 14px; height: 14px; }
    .cb-help-text { display: none; }
    .cb-sidebar { display: none; }
    .cb-product-bar { padding: 0.5rem 0.75rem; }
    .cb-bar-header { gap: 0.5rem; flex-direction: column; align-items: stretch; }
    .cb-bar-filters { width: 100%; }
    .cb-filter-select { width: 100%; max-width: none; }
    .cb-bar-info { width: 100%; text-align: center; }
    .cb-zoom-controls { gap: 0.3rem; }
    .cb-zoom-btn { width: 28px; height: 28px; font-size: 0.85rem; }
    .cb-calibrate-box {
        top: 8px;
        right: 8px;
        min-width: 180px;
        padding: 0.6rem 0.75rem;
    }
}
