/* Collection View Styles */

.collection-section {
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

.collection-header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.collection-title {
    margin: 0;
    font-size: 2.5rem;
    background: linear-gradient(45deg, #ff6b6b, #4ecdc4);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.collection-subtitle {
    margin: 10px 0 0 0;
    font-size: 1.2rem;
    color: #bdc3c7;
}

/* Search Container */
.collection-search-container {
    position: relative;
    margin-bottom: 30px;
    width: 100%;
}

.collection-search-input {
    width: 100%;
    padding: 12px 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 25px;
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
    font-size: 14px;
    transition: all 0.3s ease;
}

.collection-search-input:focus {
    outline: none;
    border-color: #4ecdc4;
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 10px rgba(78, 205, 196, 0.3);
}

.collection-search-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

/* Search Results */
.collection-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 8px;
    max-height: 400px;
    overflow-y: auto;
    background: rgba(26, 26, 46, 0.95);
    border: 1px solid rgba(78, 205, 196, 0.3);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.collection-search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    transition: background 0.2s ease;
}

.collection-search-result-item:hover {
    background: rgba(78, 205, 196, 0.15);
}

.collection-search-result-item:last-child {
    border-bottom: none;
}

.collection-search-result-name {
    flex: 1;
    font-weight: 500;
    color: #ffffff;
}

.collection-search-result-type {
    color: #bdc3c7;
    font-size: 0.85rem;
    text-transform: capitalize;
}

/* Collection Cards Container */
.collection-cards-container {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    padding: 20px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    overflow-x: auto;
    overflow-y: visible;
}

.collection-cards-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.collection-loading {
    text-align: center;
    padding: 40px;
    color: #bdc3c7;
    font-size: 1.1rem;
}

.collection-empty {
    text-align: center;
    padding: 60px 20px;
    color: #bdc3c7;
}

.collection-empty-message {
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.collection-empty-hint {
    font-size: 0.9rem;
    color: rgba(255, 255, 255, 0.6);
}

/* Category sections removed - all cards displayed in single table */

/* Collection Category Table */
.collection-category-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.02);
    border-radius: 8px;
    overflow: hidden;
    table-layout: fixed;
    max-width: 100%;
    box-sizing: border-box;
}

.collection-category-table thead {
    background: rgba(78, 205, 196, 0.1);
}

.collection-category-table th {
    padding: 0;
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    color: #4ecdc4;
    border-bottom: 2px solid rgba(78, 205, 196, 0.3);
    user-select: none;
    position: relative;
}

.collection-category-table th .th-content {
    padding: 12px 16px;
}

.collection-category-table th.sortable .th-content {
    cursor: pointer;
    transition: background 0.2s ease;
}

.collection-category-table th.sortable:hover .th-content {
    background: rgba(78, 205, 196, 0.15);
}

.collection-category-table th .sort-indicator {
    color: #4ecdc4;
    font-size: 0.8rem;
    margin-left: 4px;
}

/* Resize handle */
.collection-category-table th.resizable {
    position: relative;
}

.collection-category-table th .resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 4px;
    height: 100%;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
    transition: background 0.2s ease;
}

.collection-category-table th .resize-handle:hover {
    background: rgba(78, 205, 196, 0.5);
}

.collection-category-table th.resizing .resize-handle {
    background: rgba(78, 205, 196, 0.7);
}

.collection-category-table .collection-col-quantity {
    width: 80px;
    text-align: right;
}

.collection-category-table .collection-col-set-number {
    width: 80px;
    text-align: center;
}

.collection-category-table .collection-col-name {
    width: auto;
    min-width: 200px;
}

.collection-category-table .collection-col-type {
    width: 120px;
}

.collection-category-table .collection-col-set {
    width: 250px;
}

.collection-category-table .collection-col-actions {
    /* Room for [−][+][qty input][Set] without clipping (table-layout: fixed) */
    width: 220px;
    min-width: 200px;
    max-width: 280px;
    text-align: center;
}

/* Collection Card Item (Table Row Style) */
.collection-card-item {
    cursor: pointer;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.collection-card-item:last-child {
    border-bottom: none;
}

.collection-card-item:hover {
    background: rgba(78, 205, 196, 0.1);
}

.collection-card-item td {
    padding: 12px 16px;
    vertical-align: middle;
}

.collection-card-quantity {
    font-weight: 600;
    color: #4ecdc4;
    text-align: right;
    font-size: 1rem;
}

.collection-card-set-number {
    font-weight: 500;
    color: #4ecdc4;
    text-align: center;
    font-size: 0.95rem;
}

.collection-card-name {
    font-size: 1rem;
    font-weight: 400;
    color: #ffffff;
}

.collection-card-type {
    color: #bdc3c7;
    font-size: 0.9rem;
    text-transform: capitalize;
}

.collection-card-set {
    color: #bdc3c7;
    font-size: 0.9rem;
}

.collection-card-actions {
    text-align: center;
    overflow: visible;
}

.collection-quantity-control {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    justify-content: center;
}

.collection-quantity-btn {
    box-sizing: border-box;
    background: rgba(78, 205, 196, 0.2);
    border: 1px solid rgba(78, 205, 196, 0.4);
    color: #4ecdc4;
    width: 30px;
    height: 30px;
    min-width: 30px;
    min-height: 30px;
    padding: 0;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.collection-quantity-btn:hover {
    background: rgba(78, 205, 196, 0.3);
    border-color: rgba(78, 205, 196, 0.5);
    transform: translateY(-1px);
}

.collection-quantity-btn:active {
    transform: translateY(0);
}

.collection-quantity-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Fixed "back to top" — match .collection-quantity-btn fill/border; 15% wider than 30px square */
.collection-back-to-top {
    position: fixed;
    bottom: max(1.25rem, env(safe-area-inset-bottom, 0px));
    right: max(1.25rem, env(safe-area-inset-right, 0px));
    z-index: 800;
    box-sizing: border-box;
    width: calc(30px * 1.15);
    height: 30px;
    min-width: calc(30px * 1.15);
    min-height: 30px;
    padding: 0;
    margin: 0;
    border-radius: 4px;
    border: 1px solid rgba(78, 205, 196, 0.4);
    background: rgba(78, 205, 196, 0.2);
    color: #4ecdc4;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.collection-back-to-top:hover {
    background: rgba(78, 205, 196, 0.3);
    border-color: rgba(78, 205, 196, 0.5);
    transform: translateY(-1px);
}

.collection-back-to-top:active {
    transform: translateY(0);
}

.collection-back-to-top:focus {
    outline: none;
}

.collection-back-to-top:focus-visible {
    outline: 2px solid rgba(78, 205, 196, 0.75);
    outline-offset: 2px;
}

.collection-qty-set-group {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    margin-left: 0;
    height: 30px;
}

.collection-qty-set-input {
    width: 3rem;
    min-width: 2.75rem;
    height: 30px;
    padding: 0 4px;
    box-sizing: border-box;
    border: 1px solid rgba(78, 205, 196, 0.45);
    border-right: none;
    border-radius: 4px 0 0 4px;
    background: rgba(0, 0, 0, 0.35);
    color: #e8f4f3;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: center;
    line-height: 1;
    vertical-align: middle;
    -moz-appearance: textfield;
}

.collection-qty-set-input::-webkit-outer-spin-button,
.collection-qty-set-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.collection-qty-set-input:focus {
    outline: none;
    border-color: rgba(78, 205, 196, 0.65);
    box-shadow: 0 0 0 1px rgba(78, 205, 196, 0.25);
}

.collection-qty-set-btn {
    box-sizing: border-box;
    height: 30px;
    min-height: 30px;
    padding: 0 10px;
    border: 1px solid rgba(78, 205, 196, 0.45);
    border-radius: 0 4px 4px 0;
    background: rgba(78, 205, 196, 0.28);
    color: #f0fffd;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.collection-qty-set-btn:hover {
    background: rgba(78, 205, 196, 0.32);
    border-color: rgba(78, 205, 196, 0.55);
}

.collection-qty-set-btn:active {
    background: rgba(78, 205, 196, 0.2);
}

.collection-remove-btn {
    background: rgba(231, 76, 60, 0.2);
    border: 1px solid rgba(231, 76, 60, 0.4);
    color: #e74c3c;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.collection-remove-btn:hover {
    background: rgba(231, 76, 60, 0.3);
    border-color: rgba(231, 76, 60, 0.5);
    transform: translateY(-1px);
}

.collection-remove-btn:active {
    transform: translateY(0);
}

/* Unowned (not-in-collection) card rows */
.collection-card-unowned {
    opacity: 0.3;
    background: rgba(0, 0, 0, 0.4) !important;
    transition: opacity 0.15s ease, background 0.15s ease;
}

.collection-card-unowned:hover {
    opacity: 0.6;
    background: rgba(0, 0, 0, 0.3) !important;
}

/* Add-only button for unowned rows — same footprint as other stepper buttons */
.collection-add-btn {
    min-width: 30px;
    width: 30px;
}

/* Collection controls bar (toggle, filters) */
.collection-controls {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 16px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
}

.collection-toggle-label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}

.collection-toggle-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #4ecdc4;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .collection-card-set {
        min-width: 150px;
    }
}

@media (max-width: 900px) {
    .collection-card-item {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .collection-card-set {
        min-width: 100%;
        margin-right: 0;
    }
    
    .collection-card-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

/* Guest Sandbox Banner (details/summary: MV compact row, DTV full text always) */
details.guest-sandbox-banner {
    background: linear-gradient(135deg, #2d1f3d 0%, #1a1a2e 100%);
    border: 1px solid #6c5ce7;
    border-radius: 8px;
}

details.guest-sandbox-banner .sandbox-icon {
    flex-shrink: 0;
}

/* Subtle outline warning (replaces emoji); muted lavender stroke, not alarm yellow */
details.guest-sandbox-banner .guest-sandbox-warning-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 0;
    color: rgba(162, 155, 254, 0.68);
}

details.guest-sandbox-banner .guest-sandbox-warning-svg {
    display: block;
    width: 1em;
    height: 1em;
    flex-shrink: 0;
    opacity: 0.95;
}

details.guest-sandbox-banner .sandbox-text {
    color: #b8b8d1;
    font-size: 0.9em;
    line-height: 1.4;
}

details.guest-sandbox-banner a {
    color: #a29bfe;
    text-decoration: underline;
}

details.guest-sandbox-banner a:hover {
    color: #6c5ce7;
}

/* Desktop / layout-desktop: same visual as original — icon + full message, summary does not collapse */
html:not(.layout-mobile) details.guest-sandbox-banner {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 16px;
}

html:not(.layout-mobile) details.guest-sandbox-banner .sandbox-icon {
    font-size: 1.65em;
}

html:not(.layout-mobile) .guest-sandbox-summary {
    list-style: none;
    display: block;
    cursor: default;
}

html:not(.layout-mobile) .guest-sandbox-summary::-webkit-details-marker,
html:not(.layout-mobile) .guest-sandbox-summary::marker {
    display: none;
}

html:not(.layout-mobile) .guest-sandbox-mobile-one-line {
    display: none;
}

html:not(.layout-mobile) .guest-sandbox-expanded {
    flex: 1;
    min-width: 0;
}

/* Mobile: one-line summary + chevron; tap expands for full copy + signup link */
html.layout-mobile details.guest-sandbox-banner {
    padding: 4px 14px;
    margin-bottom: 10px;
}

html.layout-mobile .guest-sandbox-summary {
    list-style: none;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    min-height: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

html.layout-mobile .guest-sandbox-summary::-webkit-details-marker,
html.layout-mobile .guest-sandbox-summary::marker {
    display: none;
}

html.layout-mobile .guest-sandbox-summary::after {
    content: '';
    display: block;
    width: 7px;
    height: 7px;
    margin-left: auto;
    flex-shrink: 0;
    border-right: 2px solid #a29bfe;
    border-bottom: 2px solid #a29bfe;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
}

html.layout-mobile details.guest-sandbox-banner[open] .guest-sandbox-summary::after {
    transform: rotate(225deg);
    margin-top: 4px;
}

html.layout-mobile details.guest-sandbox-banner .sandbox-icon {
    font-size: var(--icon-md);
    line-height: 1;
}

html.layout-mobile .guest-sandbox-mobile-one-line {
    flex: 1;
    min-width: 0;
    font-size: var(--font-xs);
    line-height: 1.25;
    color: #d4d4e8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

html.layout-mobile .guest-sandbox-expanded {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px solid rgba(108, 92, 231, 0.4);
}

html.layout-mobile .guest-sandbox-expanded .sandbox-text {
    font-size: var(--font-sm);
    line-height: 1.35;
}

/* ─── Collection view mobile (list + detail from collection-view.js) ─── */
/* Detail host is always in DOM under #collection-view; keep out of layout on desktop. */
#collectionMobileDetail {
    display: none;
}

html.layout-mobile .collection-cards-container {
    overflow-x: hidden;
}

/* Align search field with inner content of .collection-cards-container (same 20px inset as panel padding). */
html.layout-mobile #collection-view .collection-search-container {
    margin-left: 20px;
    margin-right: 20px;
    width: auto;
    max-width: 100%;
    box-sizing: border-box;
}

html.layout-mobile #collection-view .collection-search-input {
    box-sizing: border-box;
    max-width: 100%;
}

html.layout-mobile .collection-mobile-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

html.layout-mobile .collection-mobile-row {
    display: grid;
    grid-template-columns: 56px minmax(0, 1fr) auto;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    cursor: pointer;
}

html.layout-mobile .collection-mobile-row:focus {
    outline: 2px solid rgba(78, 205, 196, 0.7);
    outline-offset: 2px;
}

html.layout-mobile .collection-mobile-row-thumb {
    width: 56px;
    height: 56px;
    object-fit: cover;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.35);
    flex-shrink: 0;
}

html.layout-mobile .collection-mobile-row-main {
    min-width: 0;
}

html.layout-mobile .collection-mobile-row-title {
    font-size: var(--font-md);
    font-weight: 500;
    color: #ffffff;
    line-height: 1.25;
}

html.layout-mobile .collection-mobile-row-subtitle {
    margin-top: 4px;
    font-size: var(--font-xs);
    color: #bdc3c7;
    line-height: 1.3;
    overflow: hidden;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

html.layout-mobile .collection-mobile-row-actions {
    flex-shrink: 0;
    min-width: 0;
}

html.layout-mobile .collection-mobile-row .collection-quantity-control {
    gap: 6px;
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
}

html.layout-mobile .collection-mobile-row .collection-quantity-btn {
    /* Prior baseline 29×29; 10% smaller */
    min-width: calc(29px * 0.9);
    min-height: calc(29px * 0.9);
    width: calc(29px * 0.9);
    height: calc(29px * 0.9);
    font-size: var(--font-2xs);
}

html.layout-mobile .collection-mobile-row .collection-qty-set-group {
    height: calc(29px * 0.9);
}

html.layout-mobile .collection-mobile-row .collection-qty-set-input {
    height: calc(29px * 0.9);
}

html.layout-mobile .collection-mobile-row .collection-qty-set-btn {
    height: calc(29px * 0.9);
    min-height: calc(29px * 0.9);
}

html.layout-mobile .collection-mobile-row-qty {
    min-width: 19px;
    text-align: center;
    font-weight: 600;
    color: #4ecdc4;
    font-size: var(--font-md);
}

html.layout-mobile #collectionMobileDetail {
    position: fixed;
    inset: 0;
    z-index: 10000;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none;
}

html.layout-mobile #collectionMobileDetail.is-open {
    display: flex;
    pointer-events: auto;
}

html.layout-mobile .collection-mobile-detail-scrim {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
}

html.layout-mobile .collection-mobile-detail-panel {
    position: relative;
    max-height: min(92vh, 100%);
    overflow-y: auto;
    background: linear-gradient(180deg, #252540 0%, #1a1a2e 100%);
    border: 1px solid rgba(78, 205, 196, 0.25);
    border-bottom: none;
    border-radius: 16px 16px 0 0;
    padding: 12px 16px 24px;
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.45);
}

html.layout-mobile .collection-mobile-detail-header {
    margin-bottom: 8px;
}

html.layout-mobile .collection-mobile-detail-back {
    min-height: 44px;
    padding: 0 16px;
    border-radius: 8px;
    border: 1px solid rgba(78, 205, 196, 0.45);
    background: rgba(78, 205, 196, 0.15);
    color: #4ecdc4;
    font-size: var(--font-sm);
    font-weight: 600;
    cursor: pointer;
}

html.layout-mobile .collection-mobile-detail-image {
    display: block;
    max-width: 100%;
    max-height: 42vh;
    width: auto;
    height: auto;
    margin: 0 auto 12px;
    object-fit: contain;
    border-radius: 8px;
}

html.layout-mobile .collection-mobile-detail-heading {
    margin: 0 0 10px;
    font-size: var(--font-md);
    font-weight: 600;
    color: #ffffff;
    line-height: 1.3;
}

html.layout-mobile .collection-mobile-detail-lines {
    margin-bottom: 16px;
}

html.layout-mobile .collection-mobile-detail-line {
    margin: 0 0 6px;
    font-size: var(--font-sm);
    color: #bdc3c7;
    line-height: 1.4;
}

html.layout-mobile .collection-mobile-detail-k {
    color: rgba(255, 255, 255, 0.55);
    margin-right: 6px;
}

html.layout-mobile .collection-mobile-detail-stepper {
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

html.layout-mobile .collection-mobile-detail-stepper .collection-qty-set-group {
    margin-left: 0;
    margin-top: 4px;
    width: 100%;
    justify-content: center;
}

html.layout-mobile .collection-mobile-detail-stepper .collection-qty-set-input {
    flex: 1 1 auto;
    max-width: 5rem;
}

html.layout-mobile .collection-mobile-detail-stepper .collection-qty-set-btn {
    flex-shrink: 0;
    height: calc(32px * 0.9);
    min-height: calc(32px * 0.9);
}

html.layout-mobile .collection-mobile-detail-stepper .collection-qty-set-group {
    height: calc(32px * 0.9);
}

html.layout-mobile .collection-mobile-detail-stepper .collection-qty-set-input {
    height: calc(32px * 0.9);
}

html.layout-mobile .collection-mobile-detail-stepper .collection-quantity-btn {
    /* Prior baseline 32×32; 10% smaller */
    min-width: calc(32px * 0.9);
    min-height: calc(32px * 0.9);
    width: calc(32px * 0.9);
    height: calc(32px * 0.9);
    font-size: var(--font-2xs);
}

html.layout-mobile .collection-mobile-detail-qty-num {
    min-width: 24px;
    text-align: center;
    font-size: var(--font-sm);
    font-weight: 700;
    color: #4ecdc4;
}

html.layout-mobile .collection-search-result-item {
    min-height: 48px;
    padding: 14px 16px;
}

/* Mobile-scoped overrides for the shared collection title, subtitle, and search input */
html.layout-mobile .collection-title {
    font-size: var(--font-2xl);
}

html.layout-mobile .collection-subtitle {
    font-size: var(--font-lg);
}

html.layout-mobile .collection-search-input {
    font-size: var(--font-sm);
}

