/**
 * Snelpen Configurator Styles
 * Modern, clean design for product configuration
 */

/* Variables */
:root {
    --sp-primary: #2563eb;
    --sp-primary-hover: #1d4ed8;
    --sp-success: #16a34a;
    --sp-warning: #ca8a04;
    --sp-error: #dc2626;
    --sp-text: #1f2937;
    --sp-text-muted: #6b7280;
    --sp-border: #e5e7eb;
    --sp-bg: #f9fafb;
    --sp-white: #ffffff;
    --sp-radius: 8px;
    --sp-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --sp-shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Container */
.sp-configurator {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    color: var(--sp-text);
    line-height: 1.5;
    padding: 16px;
    background: var(--sp-white);
    border-radius: var(--sp-radius);
    box-shadow: var(--sp-shadow);
    max-width: 800px;
    margin: 0 auto;
}

.sp-section-title small {
    display: block;
    font-size: 16px;
    color: var(--sp-text);
    margin-top: 4px;
    text-transform: none;
    letter-spacing: normal;
}

/* Sections */
.sp-section {
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--sp-border);
}

.sp-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.sp-section-title {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--sp-text-muted);
    margin: 0 0 12px 0;
}

/* Variant Grid (Color Selection with Images) */
.sp-variant-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 12px;
}

.sp-variant-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    padding: 4px;
    transition: all 0.2s;
}

.sp-variant-item:hover {
    border-color: var(--sp-border);
}

.sp-variant-item.selected {
    border-color: var(--sp-primary);
    box-shadow: 0 0 0 1px var(--sp-primary);
}

.sp-variant-image {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    overflow: hidden;
    background: #fdfdfd;
}

.sp-variant-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sp-variant-name {
    font-size: 11px;
    text-align: center;
    color: var(--sp-text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.sp-variant-item.selected .sp-variant-name {
    color: var(--sp-primary);
    font-weight: 600;
}

/* Stock Info */
.sp-stock {
    margin: -8px 0 16px 0;
    padding: 0;
}

.sp-stock-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 600;
}

.sp-stock-status i {
    font-size: 18px;
}

.sp-stock-status.in-stock {
    color: var(--sp-success);
}

.sp-stock-status.low-stock {
    color: var(--sp-warning);
}

.sp-stock-status.out-of-stock {
    color: var(--sp-error);
}

.sp-delivery {
    display: block;
    font-size: 12px;
    color: var(--sp-text-muted);
    margin-top: 4px;
}

/* Print Options */
/* Print Toggle Cards */
.sp-print-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.sp-toggle-card {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    cursor: pointer;
    transition: all 0.2s;
}

.sp-toggle-card:hover {
    background: #f8fafc;
    border-color: var(--sp-primary);
}

.sp-toggle-card.selected {
    background: #eff6ff;
    border-color: var(--sp-primary);
    box-shadow: 0 0 0 1px var(--sp-primary);
}

.sp-toggle-icon {
    font-size: 24px;
}

.sp-toggle-label {
    font-weight: 600;
    font-size: 14px;
}

/* Print Position Grid */
.sp-sub-title {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin: 12px 0 8px 0;
    color: var(--sp-text);
}

.sp-pos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
}

.sp-pos-card {
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.2s;
}

.sp-pos-card:hover {
    border-color: var(--sp-primary);
}

.sp-pos-card.selected {
    border-color: var(--sp-primary);
    box-shadow: 0 0 0 1px var(--sp-primary);
}

.sp-pos-preview {
    height: 80px;
    background: #fdfdfd;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--sp-border);
    padding: 8px;
}

.sp-pos-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.sp-no-outline {
    font-size: 12px;
    color: var(--sp-text-muted);
}

.sp-pos-info {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sp-pos-name {
    display: block;
    font-size: 13px;
    font-weight: 600;
}

.sp-pos-size {
    display: block;
    font-size: 11px;
    color: var(--sp-text-muted);
    margin-top: 2px;
}

/* Color Grid (Pills) */
.sp-color-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.sp-color-opt {
    padding: 8px 16px;
    border: 1px solid var(--sp-border);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.sp-color-opt:hover {
    background: #f8fafc;
}

.sp-color-opt.selected {
    background: var(--sp-primary);
    color: var(--sp-white);
    border-color: var(--sp-primary);
}

.sp-full-color-badge {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--sp-radius);
    color: #1e40af;
    font-size: 14px;
    font-weight: 600;
    margin: 4px 0 12px 0;
}

.sp-full-color-badge i {
    font-size: 20px !important;
    color: #2563eb;
    margin-right: -2px;
}

.sp-radio {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.sp-radio input {
    width: 18px;
    height: 18px;
    accent-color: var(--sp-primary);
}

.sp-print-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sp-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sp-form-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--sp-text-muted);
}

.sp-select {
    padding: 10px 12px;
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    font-size: 14px;
    background: var(--sp-white);
    cursor: pointer;
    transition: border-color 0.2s;
}

.sp-select:focus {
    outline: none;
    border-color: var(--sp-primary);
}

/* Quantity Selector */
/* Quantity Table */
.sp-qty-table {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sp-qty-row {
    display: flex;
    align-items: center;
    padding: 14px 16px;
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    cursor: pointer;
    transition: all 0.2s;
}

.sp-qty-row:hover {
    background: #f8fafc;
}

.sp-qty-row.selected {
    background: #1f2937;
    color: white;
    border-color: #1f2937;
}

.sp-qty-radio {
    width: 20px;
    height: 20px;
    border: 2px solid #cbd5e1;
    border-radius: 50%;
    margin-right: 16px;
    position: relative;
    flex-shrink: 0;
}

.sp-qty-row.selected .sp-qty-radio {
    border-color: white;
}

.sp-qty-row.selected .sp-qty-radio::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 10px;
    height: 10px;
    background: white;
    border-radius: 50%;
}

.sp-qty-amount {
    flex: 1;
    font-weight: 600;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sp-savings {
    font-size: 12px;
    font-weight: 500;
    color: #10b981;
}

.sp-qty-row.selected .sp-savings {
    color: #34d399;
}

.sp-qty-price {
    font-weight: 700;
    font-size: 16px;
}

.sp-qty-price small {
    font-weight: 400;
    font-size: 11px;
    opacity: 0.8;
}

.sp-qty-custom {
    margin-top: 12px;
    padding: 12px 16px;
    background: #f8fafc;
    border-radius: var(--sp-radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sp-qty-custom label {
    font-size: 13px;
    font-weight: 600;
}

.sp-qty-input-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.sp-qty-input {
    width: 80px;
    padding: 6px 10px;
    border: 1px solid var(--sp-border);
    border-radius: 4px;
    text-align: center;
    font-weight: 600;
}

.sp-qty-unit {
    font-size: 12px;
    color: var(--sp-text-muted);
}

.sp-tiers {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.sp-tiers-label {
    font-size: 13px;
    color: var(--sp-text-muted);
}

.sp-tier-badge {
    padding: 6px 14px;
    background: var(--sp-white);
    border: 2px solid var(--sp-border);
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

.sp-tier-badge:hover {
    border-color: var(--sp-primary);
    color: var(--sp-primary);
}

/* Current bracket (you're in this price tier) */
.sp-tier-badge.current {
    border-color: var(--sp-primary);
    color: var(--sp-primary);
    background: rgba(37, 99, 235, 0.05);
}

/* Exact match (selected this exact qty) */
.sp-tier-badge.selected {
    background: var(--sp-primary);
    color: var(--sp-white);
    border-color: var(--sp-primary);
    transform: scale(1.05);
}

.sp-moq-note {
    font-size: 12px;
    color: var(--sp-text-muted);
    margin: 8px 0 0 0;
}

/* Pricing Display */
.sp-pricing-summary {
    background: #f8fafc;
    border-radius: var(--sp-radius);
    padding: 16px;
    border: 1px solid var(--sp-border);
}

.sp-price-summary-selection {
    font-size: 13px;
    padding-bottom: 15px;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--sp-border);
    color: var(--sp-text);
}

.sp-price-summary-selection strong {
    color: var(--sp-text-muted);
    font-weight: 500;
    margin-right: 4px;
}

.sp-price-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.sp-price-label {
    color: var(--sp-text-muted);
    font-size: 14px;
}

.sp-price-value {
    font-weight: 600;
    font-size: 16px;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    text-align: right;
    line-height: 1.2;
}

.sp-price-value small {
    font-weight: 400;
    color: var(--sp-text-muted);
    font-size: 11px;
    margin-top: 2px;
}

.sp-price-total {
    border-top: 1px solid var(--sp-border);
    margin-top: 8px;
    padding-top: 15px;
}

.sp-price-total .sp-price-label {
    font-size: 16px;
    font-weight: 700;
    color: var(--sp-text);
}

.sp-price-total .sp-price-total-value {
    font-size: 24px;
    font-weight: 800;
    color: var(--sp-text);
}

.sp-price-incl {
    padding-top: 0;
    color: var(--sp-text-muted);
}

.sp-price-incl .sp-price-label {
    font-size: 12px;
}

.sp-price-incl .sp-price-value {
    font-size: 14px;
}

.sp-price-extras {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 16px;
}

.sp-extra-badge {
    font-size: 12px;
    color: var(--sp-success);
    font-weight: 500;
}

.sp-price-loading {
    text-align: center;
    color: var(--sp-text-muted);
    padding: 20px;
}


/* Add to Cart Button */
.sp-actions {
    border-bottom: none;
    padding-bottom: 0;
    margin-top: 30px;
}

.sp-btn {
    padding: 14px 28px;
    border: none;
    border-radius: var(--sp-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.sp-btn-primary {
    width: 100%;
    background: var(--sp-primary);
    color: var(--sp-white);
}

.sp-btn-primary:hover {
    background: var(--sp-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--sp-shadow-lg);
}

.sp-btn-primary:disabled {
    background: var(--sp-text-muted);
    cursor: not-allowed;
    transform: none;
}

/* Loading & Error States */
.sp-loading,
.sp-error {
    text-align: center;
    padding: 40px 20px;
    color: var(--sp-text-muted);
}

.sp-error {
    color: var(--sp-error);
}

/* Notifications */
.sp-notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 16px 24px;
    border-radius: var(--sp-radius);
    background: var(--sp-text);
    color: var(--sp-white);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--sp-shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    z-index: 9999;
}

.sp-notification.visible {
    transform: translateY(0);
    opacity: 1;
}

.sp-notification-success {
    background: var(--sp-success);
}

.sp-notification-error {
    background: var(--sp-error);
}

/* Responsive */
@media (max-width: 600px) {
    .sp-configurator {
        padding: 16px;
    }

    .sp-variant-grid {
        grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
        gap: 8px;
    }

    .sp-variant-image {
        width: 50px;
        height: 50px;
    }

    .sp-print-details {
        grid-template-columns: 1fr;
    }

    .sp-price-extras {
        flex-direction: column;
        gap: 8px;
    }
}

/* Logo Upload */
.sp-logo-upload-wrapper {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px dashed var(--sp-border);
}

.sp-logo-upload-wrapper label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--sp-text-muted);
    margin-bottom: 10px;
}

.sp-logo-dropzone {
    border: 2px dashed var(--sp-border);
    border-radius: var(--sp-radius);
    padding: 24px;
    text-align: center;
    background: var(--sp-bg);
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sp-logo-dropzone:hover,
.sp-logo-dropzone.dragover {
    border-color: var(--sp-primary);
    background: rgba(37, 99, 235, 0.05);
}

.sp-logo-dropzone.has-file {
    border-style: solid;
    border-color: var(--sp-success);
    background: rgba(22, 163, 74, 0.05);
}

.sp-logo-dropzone.uploading {
    cursor: wait;
    opacity: 0.7;
}

.sp-drop-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--sp-text-muted);
}

.sp-drop-prompt i {
    font-size: 24px;
    height: 24px;
    width: 24px;
}

.sp-drop-prompt span {
    font-size: 14px;
    font-weight: 500;
}

.sp-drop-prompt small {
    font-size: 11px;
}

.sp-file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
}

.sp-file-info i {
    font-size: 24px;
    height: 24px;
    width: 24px;
    color: var(--sp-success);
}

.sp-file-name {
    flex: 1;
    font-size: 14px;
    font-weight: 600;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sp-remove-btn {
    background: none;
    border: none;
    color: var(--sp-error);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    padding: 0 4px;
}

.sp-remove-btn:hover {
    transform: scale(1.2);
}

/* Calculating States */
.sp-qty-table {
    position: relative;
    transition: opacity 0.2s;
}

.sp-qty-table.calculating {
    opacity: 0.6;
    pointer-events: none;
}

.sp-table-loading-overlay {
    display: none;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 12px 24px;
    border-radius: 20px;
    box-shadow: var(--sp-shadow-lg);
    font-weight: 600;
    font-size: 14px;
    color: var(--sp-primary);
    z-index: 10;
}

.sp-qty-table.calculating .sp-table-loading-overlay {
    display: block;
}

#sp-active-setup-label {
    margin-left: 8px;
    color: var(--sp-primary);
    background: rgba(37, 99, 235, 0.1);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 500;
}


/* Stock Validation & Quantity UI */
.sp-qty-custom-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.sp-select-max-stock {
    font-size: 11px;
    color: var(--sp-primary);
    text-decoration: none;
    font-weight: 500;
}

.sp-select-max-stock:hover {
    text-decoration: underline;
}

.sp-qty-feedback {
    margin-top: 10px;
    font-size: 13px;
    padding: 8px 12px;
    border-radius: 4px;
    display: none;
    line-height: 1.4;
}

.sp-qty-feedback.error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.sp-qty-feedback.warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.sp-qty-feedback.success {
    background: #f0fdf4;
    color: #166534;
    border: 1px solid #bbf7d0;
}

.sp-qty-feedback a {
    color: inherit;
    text-decoration: underline;
    font-weight: 600;
}

.sp-moq-wrapper {
    margin-top: 8px;
    padding-left: 2px;
}

.sp-moq-note {
    font-size: 11px;
    color: var(--sp-text-muted);
    font-style: italic;
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
}

/* Modal Styles */
.sp-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

.sp-modal-overlay.visible {
    opacity: 1;
}

.sp-modal {
    background: #fff;
    width: 90%;
    max-width: 480px;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    overflow: hidden;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    animation: sp-slide-up 0.3s forwards;
}

@keyframes sp-slide-up {
    to {
        transform: translateY(0);
    }
}

.sp-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
}

.sp-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #111827;
}

.sp-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
}

.sp-modal-close:hover {
    color: #4b5563;
}

.sp-modal-body {
    padding: 20px;
    font-size: 15px;
    line-height: 1.6;
    color: #374151;
}

.sp-modal-body p {
    margin-bottom: 12px;
}

.sp-modal-body p:last-child {
    margin-bottom: 0;
}

.sp-modal-actions {
    padding: 20px;
    background: #f9fafb;
    border-top: 1px solid #f3f4f6;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sp-modal-actions .sp-btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 14px;
}

.sp-modal-footer {
    padding: 0 20px 20px;
    background: #f9fafb;
    text-align: center;
}

.sp-modal-dismiss {
    font-size: 13px;
    color: #6b7280;
    text-decoration: underline;
}

.sp-modal-dismiss:hover {
    color: #374151;
}