/* ==========================================================================
   Thingiverse Wizard – Clean UI
   ========================================================================== */

#wp3d-wizard-app {
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#wp3d-wizard-app * {
    box-sizing: border-box;
}

/* --- Buttons (shared) --- */
.wp3d-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    background: #fff;
    color: #333;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
    min-height: 44px;
    white-space: nowrap;
}

.wp3d-btn:hover {
    background: #f5f5f5;
    border-color: #aaa;
}

.wp3d-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.wp3d-btn-primary {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

.wp3d-btn-primary:hover {
    background: #005f8c;
    border-color: #005f8c;
}

.wp3d-btn-back {
    background: transparent;
    border: 1px solid #ccc;
    color: #555;
    font-size: 13px;
    padding: 10px 16px;
}

.wp3d-btn-back:hover {
    background: #f0f0f0;
}

/* --- Search Bar --- */
.wp3d-search-bar {
    display: flex;
    gap: 10px;
}

#wp3d-search-input {
    flex: 1;
    padding: 14px 16px;
    font-size: 16px;
    border: 2px solid #ddd;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.15s;
}

#wp3d-search-input:focus {
    border-color: #0073aa;
}

#wp3d-search-submit {
    padding: 14px 28px;
    font-size: 16px;
}

/* --- Results Grid --- */
.results-wrapper {
    margin-top: 20px;
}

#wp3d-grid-output {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}

.wp3d-thing-card {
    position: relative;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.wp3d-thing-card:hover {
    border-color: #0073aa;
    box-shadow: 0 2px 8px rgba(0, 115, 170, 0.15);
}

.wp3d-thing-card.wp3d-loading {
    opacity: 0.5;
    pointer-events: none;
}

.wp3d-thing-card.wp3d-no-files {
    opacity: 0.4;
    cursor: default;
    pointer-events: none;
}

.wp3d-thing-card img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.wp3d-thing-card-name {
    display: block;
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wp3d-no-files-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 11px;
    text-align: center;
    padding: 4px 0;
}

.wp3d-no-results {
    text-align: center;
    color: #666;
    padding: 40px 20px;
    font-size: 15px;
}

.wp3d-pagination {
    margin-top: 24px;
    text-align: center;
}

#wp3d-load-more {
    padding: 14px 32px;
    font-size: 15px;
}

/* --- File Selection Panel --- */
#wp3d-file-selection-panel {
    margin-top: 10px;
}

.wp3d-panel-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
}

.wp3d-panel-header h4 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #222;
}

#wp3d-thing-preview-wrap {
    margin-bottom: 16px;
}

#wp3d-thing-preview {
    width: 100%;
    max-height: 180px;
    object-fit: contain;
    border-radius: 8px;
    background: #f5f5f5;
    padding: 8px;
}

#wp3d-bulk-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 12px;
}

.wp3d-select-all-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    margin: 0;
    min-height: 44px;
    padding: 0 8px;
}

.wp3d-select-all-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.wp3d-file-hint {
    margin: 0 0 12px;
    font-size: 13px;
    color: #666;
}

/* --- File List --- */
#wp3d-individual-files-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.wp3d-file-row {
    display: flex;
    align-items: center;
    gap: 0;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
    transition: border-color 0.15s;
}

.wp3d-file-row:hover {
    border-color: #0073aa;
}

.wp3d-file-checkbox-label {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 14px;
    min-height: 52px;
    border-right: 1px solid #e8e8e8;
    cursor: pointer;
    background: #fafafa;
    margin: 0;
}

.wp3d-file-checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.wp3d-file-name {
    flex: 1;
    padding: 14px 16px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    text-align: left;
    background: none;
    border: none;
    border-right: 1px solid #e8e8e8;
    cursor: pointer;
    min-height: 52px;
    display: flex;
    align-items: center;
    transition: background 0.1s;
}

.wp3d-file-name:hover {
    background: #f0f7fc;
    color: #0073aa;
}

.wp3d-download-btn {
    min-height: 52px;
    border: none;
    border-radius: 0;
    padding: 14px 18px;
    font-size: 13px;
}

/* --- Slicer Workspace --- */
#wp3d-slicer-workspace,
#wp3d-bulk-slicer-workspace {
    margin-top: 10px;
}

#slicer-status-message,
#slicer-status-bulk {
    font-weight: 600;
    font-size: 14px;
    color: #0073aa;
}

/* --- Responsive --- */
@media (max-width: 600px) {
    #wp3d-grid-output {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
    }

    .wp3d-search-bar {
        flex-direction: column;
    }

    #wp3d-search-submit {
        width: 100%;
    }

    #wp3d-bulk-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .wp3d-file-name {
        font-size: 13px;
        padding: 12px;
    }
}

/* ==========================================================================
   Cassel Thing Popup (P3) - quote popup for search results
   ========================================================================== */

.cassel-rp-print-btn {
    display: inline-block;
    margin: 14px 0 6px;
    padding: 13px 26px;
    background: #E5B700;
    color: #154a87;
    border: none;
    border-radius: 999px;
    font-weight: 800;
    font-size: 15px;
    line-height: 1.2;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.cassel-rp-print-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 22px rgba(21, 74, 135, 0.22);
}

body.cassel-popup-open {
    overflow: hidden;
}

.cassel-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 99990;
    background: rgba(9, 16, 34, 0.74);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    font-family: inherit;
}

.cassel-popup {
    background: #fff;
    width: 880px;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
}

.cassel-popup-header {
    background: #154a87;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    flex: 0 0 auto;
}

.cassel-popup-thumb {
    width: 54px;
    height: 54px;
    object-fit: cover;
    border-radius: 10px;
    background: #0d2c52;
    flex: 0 0 auto;
}

.cassel-popup-title {
    color: #fff;
    margin: 0;
    font-size: 19px;
    font-weight: 800;
    line-height: 1.25;
    flex: 1 1 auto;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.cassel-popup-close {
    background: rgba(255, 255, 255, 0.14);
    border: none;
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
}

.cassel-popup-close:hover {
    background: rgba(255, 255, 255, 0.28);
}

/* The minimize button docks the quote (slicing continues in the
   background); it mirrors the close button beside it. */
.cassel-popup-minimize {
    background: rgba(255, 255, 255, 0.14);
    border: none;
    color: #fff;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    flex: 0 0 auto;
}

.cassel-popup-minimize:hover {
    background: rgba(255, 255, 255, 0.28);
}

.cassel-popup-confirm-msg {
    font-size: 17px;
    font-weight: 800;
    color: #12233f;
}

.cassel-popup-body {
    padding: 18px;
    overflow-y: auto;
    flex: 1 1 auto;
}

.cassel-popup-spinner {
    width: 44px;
    height: 44px;
    margin: 26px auto 14px;
    border-radius: 50%;
    border: 5px solid #dbe4f2;
    border-top-color: #E5B700;
    animation: cassel-spin 0.9s linear infinite;
}

@keyframes cassel-spin {
    to { transform: rotate(360deg); }
}

.cassel-popup-status {
    text-align: center;
    font-size: 17px;
    font-weight: 700;
    color: #16294d;
    margin: 0 0 6px;
}

.cassel-popup-substatus {
    text-align: center;
    font-size: 14px;
    color: #5a6a86;
    margin: 0 0 22px;
}

.cassel-viewer-wrap {
    margin-bottom: 14px;
}

.cassel-viewer {
    width: 100%;
    height: 380px;
    border-radius: 12px;
    overflow: hidden;
    background: #f2f4f8;
}

.cassel-viewer canvas {
    display: block;
}

.cassel-viewer-loading {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: #5a6a86;
    font-size: 14px;
    font-weight: 600;
}

.cassel-viewer-loading p {
    margin: 0;
}

.cassel-viewer-spinner {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 4px solid #dbe4f2;
    border-top-color: #E5B700;
    animation: cassel-spin 0.9s linear infinite;
}


.cassel-viewer-note {
    font-size: 13px;
    color: #5a6a86;
    margin: 8px 0 0;
}

.cassel-progress-note {
    font-size: 13.5px;
    color: #5a6a86;
    text-align: center;
    margin: 0 0 12px;
}

.cassel-part-rows {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 6px;
}

.cassel-part-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 8px 7px 13px;
    border: 2px solid #d5dce8;
    border-radius: 12px;
    background: #f4f6fa;
    color: #16294d;
    cursor: pointer;
    min-height: 48px;
}

.cassel-part-row.is-selected {
    border-color: #E5B700;
    background: #fdf6dd;
}

.cassel-part-row-main {
    flex: 1 1 auto;
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

.cassel-part-row-name {
    font-size: 13.5px;
    font-weight: 800;
    white-space: nowrap;
}

.cassel-part-row-file {
    font-size: 13px;
    color: #5a6a86;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cassel-part-row-state {
    font-size: 12.5px;
    font-weight: 700;
    color: #8a94a6;
    white-space: nowrap;
}

.cassel-part-row-price {
    font-size: 14px;
    font-weight: 800;
    color: #154a87;
    white-space: nowrap;
}

.cassel-part-row-price.is-pending {
    font-size: 13px;
    font-weight: 600;
    color: #8a94a6;
}

.cassel-part-remove {
    width: 34px;
    height: 34px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 50%;
    background: rgba(179, 38, 30, 0.08);
    color: #b3261e;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.cassel-part-remove:hover {
    background: rgba(179, 38, 30, 0.18);
}

.cassel-part-remove:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.cassel-part-row.is-removed,
.cassel-part-row.is-error {
    background: #fbfcfd;
    border-color: #e3e8f0;
    cursor: default;
}

.cassel-part-row.is-removed .cassel-part-row-name,
.cassel-part-row.is-removed .cassel-part-row-file,
.cassel-part-row.is-error .cassel-part-row-name,
.cassel-part-row.is-error .cassel-part-row-file {
    color: #8a94a6;
}

.cassel-part-row.is-error .cassel-part-row-state {
    color: #b3261e;
}

.cassel-part-undo {
    flex: 0 0 auto;
    border: 2px solid #154a87;
    background: transparent;
    color: #154a87;
    font-size: 13px;
    font-weight: 800;
    border-radius: 999px;
    padding: 7px 14px;
    min-height: 34px;
    cursor: pointer;
}

.cassel-chip-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid rgba(0, 0, 0, 0.25);
    flex: 0 0 auto;
}

.cassel-chip-dot-multi {
    background: conic-gradient(#d8262c, #f2c200, #1f9d4d, #2057c9, #d8262c);
}

.cassel-field-label {
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #16294d;
    margin: 14px 0 8px;
}

.cassel-palette {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
}

.cassel-swatch {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 2px solid rgba(0, 0, 0, 0.18);
    cursor: pointer;
    padding: 0;
}

.cassel-swatch.is-selected {
    border-color: #E5B700;
    box-shadow: 0 0 0 3px #E5B700;
}

.cassel-painted-note,
.cassel-multi-note {
    font-size: 13px;
    color: #5a6a86;
    margin: 8px 0 0;
}

.cassel-tiers {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.cassel-tier {
    text-align: left;
    border: 2px solid #d5dce8;
    background: #f8fafc;
    border-radius: 12px;
    padding: 12px 13px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-height: 44px;
}

.cassel-tier.is-selected {
    border-color: #E5B700;
    background: #fdf6dd;
}

.cassel-tier.is-disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.cassel-tier-name {
    font-size: 15px;
    font-weight: 800;
    color: #16294d;
}

.cassel-tier-desc {
    font-size: 12px;
    color: #5a6a86;
    line-height: 1.35;
}

.cassel-tier-price {
    font-size: 15px;
    font-weight: 800;
    color: #154a87;
    margin-top: 4px;
}

.cassel-quote-note {
    font-size: 13px;
    color: #8a6d00;
    background: #fdf6dd;
    border-radius: 8px;
    padding: 9px 12px;
    margin: 14px 0 0;
}

.cassel-popup-error-msg,
.cassel-popup-added-msg {
    font-size: 16px;
    font-weight: 600;
    color: #16294d;
    margin: 6px 0 10px;
}

.cassel-popup-added-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.cassel-popup-footer {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 18px;
    border-top: 1px solid #e3e8f0;
    background: #f8fafc;
}

.cassel-popup-price {
    font-size: 18px;
    font-weight: 800;
    color: #16294d;
    flex: 1 1 auto;
}

.cassel-popup-add-error {
    font-size: 13px;
    color: #b3261e;
    flex: 1 1 auto;
}

.cassel-popup-add-error + .cassel-popup-add {
    flex: 0 0 auto;
}

.cassel-popup-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 13px 24px;
    font-size: 15px;
    font-weight: 800;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    text-decoration: none;
    min-height: 48px;
    white-space: nowrap;
}

.cassel-popup-btn-gold {
    background: #E5B700;
    color: #16294d;
}

.cassel-popup-btn-gold:hover {
    background: #cfa600;
    color: #16294d;
}

.cassel-popup-btn-gold:disabled {
    opacity: 0.55;
    cursor: wait;
}

.cassel-popup-btn-ghost {
    background: transparent;
    border: 2px solid #154a87;
    color: #154a87;
}

@media (max-width: 640px) {
    .cassel-popup-overlay {
        padding: 8px;
    }

    .cassel-popup {
        max-height: 96vh;
        border-radius: 12px;
    }

    .cassel-popup-body {
        padding: 14px;
    }

    .cassel-viewer {
        height: 300px;
    }

    .cassel-tiers {
        grid-template-columns: 1fr;
    }

    .cassel-popup-footer {
        flex-wrap: wrap;
    }

    .cassel-popup-price {
        flex: 1 1 100%;
    }

    .cassel-popup-add {
        width: 100%;
    }
}

/* Quote progress strip (p4d): pinned above the popup footer while
   parts slice, carrying the original gold spinner language, a live
   status line and a progress bar. Visibility is class-driven from
   cassel-thing-popup.js (is-on / is-complete / is-collapsed). */
.cassel-progress-strip {
    display: none;
    align-items: center;
    gap: 10px;
    padding: 9px 18px;
    background: #fbf6dd;
    border-top: 1px solid #eadfae;
    overflow: hidden;
    max-height: 60px;
    transition: max-height 0.35s ease, opacity 0.35s ease, padding 0.35s ease;
}
.cassel-progress-strip.is-on { display: flex; }
.cassel-progress-strip.is-collapsed {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
}
.cassel-progress-spinner {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid #dbe4f2;
    border-top-color: #E5B700;
    animation: cassel-spin 0.8s linear infinite;
}
.cassel-progress-check {
    flex: 0 0 auto;
    color: #a8860a;
    font-size: 15px;
    font-weight: 900;
    line-height: 1;
}
.cassel-progress-text {
    font-size: 13.5px;
    font-weight: 700;
    color: #33393f;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cassel-progress-bar {
    flex: 1 1 auto;
    min-width: 36px;
    height: 5px;
    border-radius: 3px;
    background: #e9e2c4;
    overflow: hidden;
}
.cassel-progress-bar-fill {
    display: block;
    height: 100%;
    width: 0;
    background: #E5B700;
    border-radius: 3px;
    transition: width 0.45s ease;
}
.cassel-part-row-spinner {
    display: inline-block;
    width: 11px;
    height: 11px;
    margin-right: 6px;
    vertical-align: -1px;
    border-radius: 50%;
    border: 2px solid #dbe4f2;
    border-top-color: #E5B700;
    animation: cassel-spin 0.8s linear infinite;
}
