@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
    --ps-primary: #ff6b81;
    --ps-primary-dark: #e55a6e;
    --ps-bg: #ffffff;
    --ps-surface: #f8fafc;
    --ps-border: #e2e8f0;
    --ps-text: #1e293b;
    --ps-muted: #64748b;
    --ps-success: #10b981;
    --ps-radius: 14px;
    --ps-shadow: 0 4px 24px rgba(0, 0, 0, .08);
}

#ps-configurator,
#ps-configurator * {
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

/* Hide default WC elements when PS is active */
.ps-standalone-cart .quantity,
.ps-standalone-cart .single_add_to_cart_button:not(#ps-real-atc-btn) {
    display: none !important;
}

.ps-standalone-cart #ps-real-atc-btn {
    display: none !important;
}

#ps-configurator {
    background: var(--ps-bg);
    border: 1px solid var(--ps-border);
    border-radius: var(--ps-radius);
    box-shadow: var(--ps-shadow);
    overflow: hidden;
    margin: 0 auto 32px auto;
    max-width: 100%;
}

.ps-steps-nav {
    display: flex;
    background: var(--ps-surface);
    border-bottom: 1px solid var(--ps-border);
}

.ps-step-tab {
    flex: 1;
    padding: 16px 12px;
    text-align: center;
    font-size: .8rem;
    font-weight: 600;
    color: var(--ps-muted);
    letter-spacing: .04em;
    text-transform: uppercase;
    position: relative;
    transition: color .2s;
    cursor: default;
    user-select: none;
}

.ps-step-tab.is-active {
    color: var(--ps-primary);
}

.ps-step-tab.is-active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--ps-primary);
    border-radius: 3px 3px 0 0;
}

.ps-step-tab.is-done {
    color: var(--ps-success);
}

.ps-step-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--ps-border);
    color: var(--ps-muted);
    font-size: .75rem;
    margin-right: 6px;
    transition: background .2s, color .2s;
}

.ps-step-tab.is-active .ps-step-number {
    background: var(--ps-primary);
    color: #fff;
}

.ps-step-tab.is-done .ps-step-number {
    background: var(--ps-success);
    color: #fff;
}

.ps-step-panel {
    display: none;
    padding: 32px;
    animation: ps-fade-in .25s ease;
}

@media (max-width: 768px) {
    .ps-step-panel {
        padding: 20px 16px;
    }
}

.ps-step-panel.is-active {
    display: block;
}

@keyframes ps-fade-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ps-upload-zone {
    border: 2px dashed var(--ps-border);
    border-radius: var(--ps-radius);
    padding: 48px 24px;
    text-align: center;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    position: relative;
    background: var(--ps-surface);
}

.ps-upload-zone:hover,
.ps-upload-zone.is-over {
    border-color: var(--ps-primary);
    background: rgba(255, 107, 129, .04);
}

.ps-upload-zone input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    width: 100%;
    height: 100%;
}

.ps-upload-icon {
    font-size: 2.5rem;
    color: var(--ps-primary);
    margin-bottom: 12px;
}

.ps-upload-label {
    display: block;
    font-size: 1rem;
    font-weight: 600;
    color: var(--ps-text);
    margin-bottom: 4px;
}

.ps-upload-sub {
    font-size: .85rem;
    color: var(--ps-muted);
}

/* Files List */
.ps-files-list {
    margin: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ps-file-item {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1px solid var(--ps-border);
    padding: 10px;
    border-radius: 12px;
    gap: 12px;
    position: relative;
    animation: psFadeIn 0.3s ease;
}

.ps-file-thumb {
    width: 44px;
    height: 56px;
    object-fit: cover;
    border-radius: 4px;
    background: #eee;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ps-file-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ps-file-info strong {
    font-size: 0.9rem;
    color: var(--ps-text);
    display: block;
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ps-file-info span {
    font-size: 0.8rem;
    color: var(--ps-primary);
    font-weight: 600;
}

.ps-remove-file {
    background: #fff;
    border: 1px solid var(--ps-border);
    color: #ff4d4d;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
    transition: all 0.2s;
    padding: 0;
}

.ps-remove-file:hover {
    background: #ff4d4d;
    color: #fff;
    border-color: #ff4d4d;
}

@keyframes psFadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ps-pdf-preview {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-top: 20px;
    padding: 16px;
    background: var(--ps-surface);
    border: 1px solid var(--ps-border);
    border-radius: var(--ps-radius);
}

.ps-pdf-preview canvas {
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
    max-width: 120px;
    height: auto;
    flex-shrink: 0;
}

.ps-pdf-info {
    flex: 1;
}

.ps-pdf-info strong {
    display: block;
    font-size: .95rem;
    color: var(--ps-text);
    margin-bottom: 6px;
    word-break: break-all;
}

.ps-pdf-pages {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #e0fdf4;
    color: var(--ps-success);
    font-weight: 700;
    font-size: .85rem;
    padding: 4px 12px;
    border-radius: 999px;
}

.ps-status-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--ps-radius);
    font-size: .88rem;
    font-weight: 500;
    margin-top: 16px;
}

.ps-status-bar.is-analysing {
    background: #fff7ed;
    color: #c2410c;
}

.ps-status-bar.is-ready {
    background: #f0fdf4;
    color: #15803d;
}

.ps-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: ps-spin .7s linear infinite;
    flex-shrink: 0;
}

@keyframes ps-spin {
    to {
        transform: rotate(360deg);
    }
}

.ps-groups-grid {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ps-group {
    border: 1px solid var(--ps-border);
    border-radius: var(--ps-radius);
    overflow: hidden;
}

.ps-group-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 18px;
    background: var(--ps-surface);
    font-weight: 600;
    font-size: .92rem;
    color: var(--ps-text);
    border-bottom: 1px solid var(--ps-border);
}

.ps-group-header .dashicons,
#ps-configurator .dashicons {
    font-family: dashicons !important;
    font-size: 1.2rem;
    color: var(--ps-primary);
    width: auto;
    height: auto;
    vertical-align: middle;
}

.ps-choices {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 16px;
}

.ps-choice-btn {
    display: flex;
    flex-direction: row;
    /* Horizontal layout for descriptions */
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 12px 16px;
    border: 2px solid var(--ps-border);
    border-radius: 12px;
    background: #fff;
    cursor: pointer;
    transition: border-color .18s, box-shadow .18s, transform .15s;
    text-align: left;
    position: relative;
    user-select: none;
}

.ps-choice-btn:hover {
    border-color: var(--ps-primary);
    box-shadow: 0 0 0 4px rgba(255, 107, 129, .1);
    transform: translateY(-1px);
}

.ps-choice-btn.is-selected {
    border-color: var(--ps-primary);
    background: rgba(255, 107, 129, .06);
    box-shadow: 0 0 0 4px rgba(255, 107, 129, .15);
}

.ps-choice-btn.is-selected::after {
    content: '✓';
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: .7rem;
    background: var(--ps-primary);
    color: #fff;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

.ps-choice-icon {
    font-size: 1.5rem;
    color: var(--ps-primary);
    flex-shrink: 0;
}

.ps-choice-text {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.ps-choice-label {
    font-size: .82rem;
    font-weight: 600;
    color: var(--ps-text);
    line-height: 1.3;
}

.ps-choice-price {
    font-size: .78rem;
    color: var(--ps-muted);
}

.ps-summary-card {
    background: #ffffff;
    border: 1px solid var(--ps-border);
    border-radius: 16px;
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.ps-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
    font-size: 0.95rem;
}

.ps-summary-row:last-child {
    border-bottom: none;
}

.ps-summary-key {
    color: #475569;
    font-weight: 600;
}

.ps-summary-val {
    font-weight: 700;
    color: #1e293b;
    text-align: right;
}

.ps-summary-detail {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    font-weight: 400;
    margin-top: 2px;
}

.ps-copies-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.ps-copies-label {
    font-weight: 600;
    color: var(--ps-text);
}

.ps-copies-input {
    width: 80px;
    padding: 8px 12px;
    border: 2px solid var(--ps-border);
    border-radius: 8px;
    font-size: 1rem;
    text-align: center;
    transition: border-color .2s;
    outline: none;
}

.ps-copies-input:focus {
    border-color: var(--ps-primary);
}

/* Choice Buttons - Overflow Proof & Premium */
.ps-choice-btn {
    display: flex !important;
    align-items: center;
    width: 100%;
    padding: 14px 18px;
    border: 1px solid #e5e7eb;
    background: #ffffff;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    gap: 12px;
    margin-bottom: 10px;
    position: relative;
    overflow: hidden;
}

.ps-choice-btn:hover {
    border-color: var(--ps-primary);
    background: #fffafa;
    transform: translateY(-1px);
}

.ps-choice-btn.is-selected {
    border-color: var(--ps-primary);
    background: #fff;
    box-shadow: 0 0 0 2px var(--ps-primary);
}

.ps-choice-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    object-fit: contain;
}

.ps-choice-text {
    flex-grow: 1;
    min-width: 0;
    /* Critical for truncation */
    display: flex;
    flex-direction: column;
}

.ps-choice-label {
    font-weight: 600;
    font-size: 0.95rem;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ps-choice-desc {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 2px;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ps-choice-price {
    flex-shrink: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ps-primary);
    background: #fdf2f2;
    padding: 4px 8px;
    border-radius: 6px;
    white-space: nowrap;
}

/* Total Bar - Subtle & Premium */
.ps-total-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 20px;
    background: #f9fafb;
    border: 1px solid #f3f4f6;
    border-radius: 16px;
    color: #111827;
    margin-bottom: 12px;
    margin-top: 20px;
}

.ps-total-label {
    font-size: 1rem;
    font-weight: 600;
    color: #4b5563;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.ps-total-amount {
    font-size: 1.75rem;
    font-weight: 800;
    color: #111827;
}

/* Toast Notification */
.ps-toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: #111827;
    color: #fff;
    padding: 12px 28px;
    border-radius: 50px;
    font-weight: 600;
    box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    pointer-events: none;
}

.ps-toast.is-visible {
    transform: translateX(-50%) translateY(0);
}

.ps-nav-buttons {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
}

.ps-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 10px;
    font-size: .95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: transform .15s, box-shadow .15s, opacity .2s;
}

.ps-btn:active {
    transform: scale(.97);
}

.ps-btn-primary {
    background: linear-gradient(135deg, var(--ps-primary), var(--ps-primary-dark));
    color: #fff;
    box-shadow: 0 4px 14px rgba(255, 107, 129, .4);
}

.ps-btn-primary:hover {
    box-shadow: 0 6px 20px rgba(255, 107, 129, .5);
    transform: translateY(-1px);
}

.ps-btn-secondary {
    background: var(--ps-surface);
    color: var(--ps-text);
    border: 1px solid var(--ps-border);
}

.ps-btn-secondary:hover {
    background: var(--ps-border);
}

.ps-btn:disabled {
    opacity: .45;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Edit link in cart visibility */
.ps-edit-cart-item-link {
    display: inline-flex !important;
    align-items: center;
    margin-top: 10px;
    padding: 6px 14px;
    background: #fff;
    border: 1.5px solid var(--ps-primary);
    color: var(--ps-primary) !important;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    text-decoration: none !important;
    transition: all 0.2s ease;
}

.ps-edit-cart-item-link:hover {
    background: var(--ps-primary);
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(255, 107, 129, 0.3);
    transform: translateY(-1px);
}

.ps-edit-cart-item-link:active {
    transform: translateY(0);
}

@media (max-width: 600px) {
    .ps-step-tab span.ps-step-text {
        display: none;
    }

    .ps-choices {
        grid-template-columns: 1fr;
    }

    .ps-file-info strong {
        max-width: 140px;
    }

    .ps-pdf-preview {
        flex-direction: column;
    }
}

/* Animations & Premium Touches */
.ps-step-panel {
    display: none;
    animation: psStepIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.ps-step-panel.is-active {
    display: block;
}

@keyframes psStepIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ps-final-buy-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.ps-final-buy-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(255, 107, 129, 0.4);
    filter: brightness(1.1);
}

.ps-final-buy-btn:active {
    transform: translateY(0);
}

/* Hide standard WC elements when PrintSolution is active on home/shortcode */
.ps-standalone-cart+.product,
.ps-standalone-cart~div[id^="product-"],
.ps-standalone-cart~.product,
.ps-standalone-cart~.summary,
.ps-standalone-cart~.woocommerce-tabs,
.ps-standalone-cart~.related,
.ps-standalone-cart~.upsells {
    display: none !important;
}

/* If inside a standard product page summary */
.summary.entry-summary .cart:not(.ps-standalone-cart),
.summary.entry-summary .price,
.summary.entry-summary .product_meta {
    display: none !important;
}