/* ============================================
   CABLE BUILDER MODULE - CORE
   PrestaShop 9 + Bootstrap 5
   Version: 6.2 - Fully Cleaned & Optimized
   ============================================ */

/* ===== CSS Variables - Modern Design Tokens ===== */
:root {
    /* Primary Brand Colors - PrestaShop Inspired */
    --ps-primary: #00b9b9;
    --ps-primary-hover: #00a0a0;
    --ps-primary-light: rgba(0, 185, 185, 0.1);
    --ps-secondary: #2e3a4b;
    --ps-success: #2c9e5c;
    --ps-danger: #e34f4f;
    --ps-warning: #f39c12;
    --ps-info: #17a2b8;
    
    /* Neutral Colors */
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    
    /* Spacing - 8px Base */
    --space-1: 0.125rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.5rem;
    --space-6: 2rem;
    --space-8: 3rem;
    --space-10: 4rem;
    
    /* Shadows */
    --shadow-xs: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    --shadow-focus: 0 0 0 0.25rem rgba(0, 185, 185, 0.25);
    
    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.25rem;
    --radius-full: 9999px;
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;
    
    /* Container Max Widths */
    --container-sm: 540px;
    --container-md: 720px;
    --container-lg: 960px;
    --container-xl: 1140px;
    --container-xxl: 1320px;
}

/* ===== Base Container & Loading ===== */
.cable-builder-container {
    max-width: var(--container-xl);
    margin: 0 auto;
    padding: var(--space-5) var(--space-4);
}

.category-card.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.category-card.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid var(--gray-300);
    border-top-color: var(--ps-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.btn.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 1rem;
    height: 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: var(--space-2);
}

/* ===== Progress Steps ===== */
.builder-steps {
    position: relative;
    display: flex;
    justify-content: space-between;
    max-width: 600px;
    margin: 0 auto var(--space-8);
    gap: var(--space-2);
}

.builder-steps::before {
    content: '';
    position: absolute;
    top: calc(1.5rem - 1px);
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--gray-200), var(--gray-300), var(--gray-200));
    border-radius: var(--radius-full);
}

.builder-steps .step {
    position: relative;
    z-index: 2;
    flex: 1;
    text-align: center;
    cursor: pointer;
    transition: transform var(--transition-base);
}

.builder-steps .step:hover {
    transform: translateY(-2px);
}

.builder-steps .step .step-circle {
    width: 3rem;
    height: 3rem;
    margin: 0 auto var(--space-2);
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 2px solid var(--gray-300);
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 1rem;
    color: var(--gray-600);
    transition: all var(--transition-base);
    position: relative;
    background: var(--gray-50);
}

.builder-steps .step.completed .step-circle {
    background: var(--ps-primary);
    border-color: var(--ps-primary);
    color: white;
}

.builder-steps .step.active .step-circle {
    background: var(--ps-success);
    border-color: var(--ps-success);
    color: white;
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.builder-steps .step .step-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--gray-600);
    margin: 0;
    transition: color var(--transition-base);
}

.builder-steps .step.active .step-label,
.builder-steps .step.completed .step-label {
    color: var(--gray-900);
    font-weight: 600;
}

.builder-step {
    display: none;
    animation: fadeInUp var(--transition-slow);
}

.builder-step.active {
    display: block;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Buttons ===== */
.btn {
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-weight: 500;
    font-size: 0.875rem;
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
}

.btn-primary {
    background: var(--ps-primary);
    border: none;
    color: white;
}

.btn-primary:hover {
    background: var(--ps-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--gray-200);
    border: none;
    color: var(--gray-700);
}

.btn-secondary:hover {
    background: var(--gray-300);
    transform: translateY(-1px);
}

.btn-info {
    background: var(--ps-info);
    border: none;
    color: white;
}

.btn-info:hover {
    background: #138496;
    transform: translateY(-1px);
}

.btn-outline-secondary {
    border: 1px solid var(--gray-400);
    background: transparent;
    color: var(--gray-700);
}

.btn-outline-secondary:hover {
    background: var(--gray-200);
}

.btn-lg {
    padding: var(--space-3) var(--space-5);
    font-size: 1rem;
}

.builder-navigation {
    display: flex;
    justify-content: center;
    gap: var(--space-4);
    margin-top: var(--space-8);
}

.builder-navigation .btn {
    min-width: 150px;
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: var(--space-1);
}

.form-label {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: var(--space-1);
    color: var(--gray-700);
}

.form-select,
.form-control {
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-md);
    padding: var(--space-2) var(--space-3);
    font-size: 0.875rem;
    transition: all var(--transition-base);
}

.form-select:focus,
.form-control:focus {
    border-color: var(--ps-primary);
    box-shadow: var(--shadow-focus);
    outline: none;
}

/* ===== CART CONFIGURATION PANEL - FULLY HORIZONTAL ===== */
.cablebuilder-cart-config-panel {
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    margin-bottom: 0.75rem;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
    width: fit-content;
    min-width: 300px;
}

.cablebuilder-cart-config-panel:hover {
    box-shadow: var(--shadow-md);
}

/* Panel Header */
.cablebuilder-cart-config-panel .panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(135deg, var(--gray-50), white);
    border-bottom: 2px solid var(--ps-primary-light);
    cursor: pointer;
    transition: background var(--transition-base);
}

.cablebuilder-cart-config-panel .panel-header:hover {
    background: linear-gradient(135deg, var(--gray-100), var(--gray-50));
}

.cablebuilder-cart-config-panel .header-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cablebuilder-cart-config-panel .config-icon {
    color: var(--ps-primary);
    font-size: 1.1rem;
}

.cablebuilder-cart-config-panel .config-title {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--gray-800);
}

.cablebuilder-cart-config-panel .config-badge {
    background: var(--ps-primary);
    color: white;
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.6rem;
    font-weight: 600;
}

.cablebuilder-cart-config-panel .header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.cablebuilder-cart-config-panel .config-id {
    background: var(--gray-100);
    color: var(--gray-600);
    padding: 0.15rem 0.5rem;
    border-radius: 20px;
    font-size: 0.6rem;
    font-family: monospace;
}

.cablebuilder-cart-config-panel .btn-toggle-config {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--gray-500);
    transition: all var(--transition-base);
    border-radius: 50%;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cablebuilder-cart-config-panel .btn-toggle-config:hover {
    background: var(--gray-200);
    color: var(--ps-primary);
}

.cablebuilder-cart-config-panel .btn-toggle-config i {
    transition: transform var(--transition-base);
}

.cablebuilder-cart-config-panel.collapsed .btn-toggle-config i {
    transform: rotate(180deg);
}

/* Panel Body */
.cablebuilder-cart-config-panel .panel-body {
    padding: 0.5rem;
    transition: all var(--transition-slow);
}

.cablebuilder-cart-config-panel.collapsed .panel-body {
    display: none;
}

/* Images Row - Horizontal (3 columns) */
.config-images-row {
    display: flex;
    flex-direction: row;
    justify-content: space-evenly;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    padding: 0.5rem;
    background: linear-gradient(135deg, var(--gray-50), white);
    border-radius: var(--radius-md);
    flex-wrap: nowrap;
}

.config-image-item {
    text-align: center;
    flex: 1;
    min-width: 60px;
    position: relative;
}

.config-image-item .badge-img {
    display: inline-block;
    width: 22px;
    height: 22px;
    line-height: 22px;
    background: var(--ps-primary);
    color: white;
    border-radius: 50%;
    font-size: 0.6rem;
    font-weight: bold;
    margin-bottom: 0.25rem;
}

.config-img {
    max-width: 50px;
    max-height: 50px;
    width: auto;
    height: auto;
    object-fit: contain;
    background: white;
    padding: 0.25rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--gray-200);
    transition: all var(--transition-base);
    box-shadow: var(--shadow-xs);
}

.config-img:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
    border-color: var(--ps-primary);
}

.config-img-label {
    display: block;
    font-size: 0.6rem;
    margin-top: 0.25rem;
    font-weight: 600;
    color: var(--gray-700);
}

/* Main Config Grid - 3 columns (Connector A, Cable, Connector B) */
.config-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    overflow-x: auto;
}

.config-item {
    background: var(--gray-50);
    border-radius: var(--radius-md);
    padding: 0.35rem 0.5rem;
    transition: all var(--transition-base);
    border: 1px solid transparent;
    flex: 1;
    min-width: 100px;
}

.config-item:hover {
    background: var(--gray-100);
    transform: translateY(-1px);
    border-color: var(--gray-200);
}

.config-item.full-width {
    flex: 1 1 100%;
}

.item-label {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.6rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--gray-500);
    margin-bottom: 0.25rem;
}

.item-label .connector-badge {
    display: inline-block;
    width: 18px;
    height: 18px;
    line-height: 18px;
    background: var(--ps-primary-light);
    color: var(--ps-primary);
    border-radius: 50%;
    font-size: 0.6rem;
    font-weight: bold;
    text-align: center;
}

.item-label i {
    font-size: 0.75rem;
    color: var(--ps-primary);
}

.item-value {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--gray-800);
    word-break: break-word;
}

.item-value strong {
    font-weight: 700;
    font-size: 0.7rem;
    color: var(--gray-900);
}

/* Label tag */
.label-tag {
    background: var(--ps-primary-light);
    padding: 0.1rem 0.35rem;
    border-radius: var(--radius-sm);
    font-size: 0.55rem;
    color: var(--ps-primary);
    border: none;
    margin-left: 0.25rem;
    font-weight: 500;
}

/* Length indicator */
.length-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.15rem;
    background: white;
    padding: 0.1rem 0.3rem;
    border-radius: 20px;
    font-size: 0.6rem;
    margin-left: 0.25rem;
    color: var(--ps-info);
    border: 1px solid var(--gray-200);
}

.length-indicator i {
    font-size: 0.6rem;
}

/* Color dot */
.color-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-left: 4px;
    border: 1px solid var(--gray-300);
    vertical-align: middle;
    box-shadow: var(--shadow-xs);
}

/* Extended Config Grid - Color, Pinout, Boot (Horizontal) */
.extended-config-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    overflow-x: auto;
}

.extended-config-grid .config-item {
    flex: 1;
    min-width: 80px;
}

.extended-config-grid .item-label {
    justify-content: flex-start;
}

/* Price Summary */
.price-summary {
    background: linear-gradient(135deg, var(--gray-50), white);
    border-radius: var(--radius-md);
    padding: 0.35rem 0.5rem;
    margin-top: 0.35rem;
    border: 1px solid var(--gray-200);
}

.price-row {
    display: flex;
    justify-content: space-between;
    padding: 0.2rem 0;
    font-size: 0.65rem;
    border-bottom: 1px dashed var(--gray-200);
}

.price-row:last-child {
    border-bottom: none;
}

.price-row.total-row {
    border-top: 2px solid var(--ps-primary);
    margin-top: 0.2rem;
    padding-top: 0.3rem;
    font-weight: 700;
    font-size: 0.75rem;
    border-bottom: none;
}

.total-price {
    color: var(--ps-primary);
    font-size: 0.8rem;
    font-weight: 700;
}

.price-detail {
    font-size: 0.55rem;
    color: var(--gray-500);
    margin-left: 0.25rem;
}

/* Quantity badge */
.quantity-badge {
    background: var(--ps-primary-light);
    padding: 0.1rem 0.3rem;
    border-radius: 20px;
    font-size: 0.6rem;
    font-weight: 600;
    color: var(--ps-primary);
}

/* Quantity Info Box */
.config-quantity-info {
    margin-top: 0.35rem;
    padding: 0.25rem 0.5rem;
    background: #e7f3ff;
    border-radius: var(--radius-md);
    font-size: 0.65rem;
    color: #004085;
    border-left: 3px solid var(--ps-primary);
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.config-quantity-info i {
    font-size: 0.75rem;
    color: var(--ps-primary);
}

/* Note Item */
.config-item.note-item {
    flex: 1 1 100%;
    background: #fff9e6;
    border-left: 3px solid var(--ps-warning);
}

.config-item.note-item .item-label i {
    color: var(--ps-warning);
}

/* Specifications Section */
.specifications-section {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--gray-200);
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.65rem;
    font-weight: 600;
    margin-bottom: 0.35rem;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-title i {
    color: var(--ps-primary);
}

.specs-grid {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.spec-item {
    display: flex;
    gap: 0.35rem;
    font-size: 0.65rem;
    padding: 0.2rem 0.4rem;
    background: var(--gray-50);
    border-radius: var(--radius-sm);
    flex: 1;
    min-width: 120px;
}

.spec-name {
    color: var(--gray-500);
    min-width: 60px;
}

.spec-value {
    font-weight: 500;
    color: var(--gray-800);
}

/* ===== Scrollbar for Horizontal Scroll ===== */
@media (max-width: 992px) {
    .config-grid,
    .extended-config-grid {
        overflow-x: auto;
        padding-bottom: 0.25rem;
    }
    
    .config-grid::-webkit-scrollbar,
    .extended-config-grid::-webkit-scrollbar {
        height: 3px;
    }
    
    .config-grid::-webkit-scrollbar-track,
    .extended-config-grid::-webkit-scrollbar-track {
        background: var(--gray-200);
        border-radius: 3px;
    }
    
    .config-grid::-webkit-scrollbar-thumb,
    .extended-config-grid::-webkit-scrollbar-thumb {
        background: var(--ps-primary);
        border-radius: 3px;
    }
}

/* ===== Responsive - Stack Vertically on Mobile ===== */
@media (max-width: 768px) {
    .config-grid,
    .extended-config-grid {
        flex-wrap: wrap;
    }
    
    .config-item {
        min-width: auto;
    }
    
    .extended-config-grid .config-item {
        min-width: auto;
    }
    
    .config-images-row {
        flex-wrap: wrap;
    }
    
    .config-image-item {
        min-width: 60px;
    }
    
    .specs-grid {
        flex-direction: column;
    }
}

/* ===== Enhanced Controls Bar ===== */
.enhanced-controls-bar {
    border-bottom: 1px solid #e9ecef;
    padding-bottom: 10px;
}

.enhanced-controls-bar .btn {
    transition: all 0.2s ease;
}

.enhanced-controls-bar .btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.enhanced-controls-bar .btn-orange {
    background-color: #fd7e14;
    color: white;
}

.enhanced-controls-bar .btn-orange:hover {
    background-color: #e66a00;
}

/* ===== Batch PDF & Loading Overlays ===== */
.batch-pdf-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    padding: 10px 15px;
    display: none;
}

.batch-badge {
    display: flex;
    align-items: center;
    gap: 10px;
}

.batch-progress-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.batch-progress-card {
    background: white;
    border-radius: 12px;
    padding: 30px;
    min-width: 350px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.custom-atten-indicator {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #fd7e14;
    color: white;
    padding: 8px 15px;
    border-radius: 30px;
    font-size: 12px;
    cursor: pointer;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
}

.custom-atten-indicator:hover {
    transform: scale(1.05);
    background: #e66a00;
}

.pdf-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.95);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ===== Save/Load Configuration Buttons ===== */
.save-config-btn {
    margin-top: 10px;
}

.load-config-dropdown {
    position: relative;
    display: inline-block;
}

.load-config-menu {
    display: none;
    position: absolute;
    bottom: 100%;
    right: 0;
    background: white;
    min-width: 300px;
    max-height: 400px;
    overflow-y: auto;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 8px;
    z-index: 1000;
    margin-bottom: 5px;
}

.load-config-menu.show {
    display: block;
}

/* ===== Utility Classes ===== */
.text-muted {
    color: var(--gray-500) !important;
}

.text-primary {
    color: var(--ps-primary) !important;
}

.bg-light {
    background: var(--gray-50) !important;
}

.hidden {
    display: none !important;
}
/* Prevent translation for specific elements */
.notranslate, 
[translate="no"],
.cta-close,
.cta-close *,
.material-icons {
    -webkit-user-select: text !important;
    user-select: text !important;
}

/* Ensure close button text doesn't get translated */
.cta-close span,
.cta-close i {
    unicode-bidi: embed;
    direction: ltr;
}