/* CardVerse — modal Agregar a colección */
.cv-collection-modal {
    --cv-purple: #7c3aed;
    --cv-purple-dark: #6d28d9;
    --cv-purple-soft: #f5f3ff;
    --cv-purple-border: #ede9fe;
    --cv-purple-glow: rgba(124, 58, 237, 0.22);
    --cv-text: #0f172a;
    --cv-muted: #64748b;
    --cv-border: #e2e8f0;
    --cv-surface: #f8fafc;
}

.cv-collection-dialog {
    max-width: 620px;
    width: 94%;
    margin-left: auto;
    margin-right: auto;
}

.cv-collection-content {
    background: #fff;
    border: none;
    border-radius: 22px;
    box-shadow:
        0 24px 48px rgba(15, 23, 42, 0.12),
        0 8px 20px rgba(124, 58, 237, 0.08);
    overflow: hidden;
    position: relative;
}

.cv-collection-modal.show .cv-collection-content {
    animation: cvCollectionModalIn 0.32s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cvCollectionModalIn {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cv-collection-header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    border: none;
    padding: 1.25rem 1.5rem 0.75rem;
}

.cv-collection-title {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--cv-text);
    margin: 0;
}

.cv-collection-close {
    display: inline-flex;
    flex-shrink: 0;
    margin-left: auto;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: 12px;
    background: var(--cv-surface);
    color: var(--cv-muted);
    transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.cv-collection-close:hover {
    background: #eef2ff;
    color: var(--cv-purple);
}

.cv-collection-close:focus-visible {
    outline: 2px solid var(--cv-purple);
    outline-offset: 2px;
}

.cv-collection-body {
    padding: 0 1.5rem 1rem;
    overflow-x: hidden;
}

.cv-collection-card-preview {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 16px;
    margin-bottom: 1rem;
    background: var(--cv-surface);
    border-radius: 14px;
    border: 1px solid var(--cv-border);
}

.cv-collection-card-img {
    flex-shrink: 0;
    width: 64px;
    height: 88px;
    object-fit: cover;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.12);
    background: #fff;
}

.cv-collection-card-info {
    min-width: 0;
    flex: 1;
    padding-top: 2px;
}

.cv-collection-card-name {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    color: var(--cv-text);
    margin: 0 0 6px;
    word-break: break-word;
}

.cv-collection-card-meta {
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--cv-muted);
    margin: 0;
}

.cv-collection-summary {
    font-size: 0.875rem;
    color: var(--cv-muted);
    margin: 0 0 0.75rem;
    line-height: 1.45;
}

.cv-collection-summary.is-active {
    color: var(--cv-purple-dark);
    font-weight: 600;
}

.cv-collection-hint {
    font-size: 0.8125rem;
    color: #b45309;
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 0.5rem 0.75rem;
    margin: 0 0 0.75rem;
    display: none;
}

.cv-collection-hint.is-visible {
    display: block;
}

.cv-category-search-wrap {
    position: relative;
    margin-bottom: 0.875rem;
}

.cv-category-search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cv-muted);
    font-size: 0.9rem;
    pointer-events: none;
}

.cv-category-search {
    width: 100%;
    height: 44px;
    padding: 0 14px 0 40px;
    border: 1px solid var(--cv-border);
    border-radius: 12px;
    font-size: 0.9375rem;
    color: var(--cv-text);
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.cv-category-search::placeholder {
    color: #94a3b8;
}

.cv-category-search:focus {
    outline: none;
    border-color: var(--cv-purple);
    box-shadow: 0 0 0 3px var(--cv-purple-glow);
}

.collection-category-grid,
.cv-category-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 0.875rem;
}

@media (max-width: 576px) {
    .collection-category-grid,
    .cv-category-grid {
        grid-template-columns: 1fr;
    }
}

.cv-category-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 12px 10px;
    background: #fff;
    border: 1.5px solid var(--cv-border);
    border-radius: 14px;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
    min-width: 0;
}

.cv-category-card:hover {
    border-color: #cbd5e1;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
}

.cv-category-card.active {
    border-color: var(--cv-purple);
    background: var(--cv-purple-soft);
    box-shadow: 0 4px 14px var(--cv-purple-glow);
}

.cv-category-card.is-hidden {
    display: none;
}

.cv-category-card:focus-within {
    outline: 2px solid var(--cv-purple);
    outline-offset: 2px;
}

.cv-category-card .coleccion-add-cat {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.cv-category-card-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    margin: 0;
    min-height: 44px;
    user-select: none;
}

.cv-category-check {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    margin-top: 1px;
    border-radius: 7px;
    border: 1.5px solid #cbd5e1;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.cv-category-check::before {
    content: '';
    width: 6px;
    height: 10px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) scale(0);
    margin-top: -2px;
    transition: transform 0.15s ease;
}

.cv-category-card.active .cv-category-check {
    border-color: var(--cv-purple);
    background: var(--cv-purple);
}

.cv-category-card.active .cv-category-check::before {
    transform: rotate(45deg) scale(1);
}

.cv-category-title {
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--cv-text);
    line-height: 1.35;
    word-break: break-word;
    padding-right: 4px;
}

.cv-category-card.active .cv-category-title {
    color: var(--cv-purple-dark);
}

.cv-category-counter {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding-top: 2px;
}

.cv-category-card.active .cv-category-counter {
    display: flex;
}

.cv-counter-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    min-width: 42px;
    height: 42px;
    padding: 0;
    border: 1px solid var(--cv-border);
    border-radius: 10px;
    background: #fff;
    color: var(--cv-text);
    font-size: 1.125rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.cv-category-card.active .cv-counter-btn {
    border-color: var(--cv-purple-border);
    background: #fff;
}

.cv-counter-btn:hover {
    border-color: var(--cv-purple);
    color: var(--cv-purple);
}

.cv-counter-btn:focus-visible {
    outline: 2px solid var(--cv-purple);
    outline-offset: 2px;
}

.cv-counter-input {
    width: 52px;
    min-height: 42px;
    height: 42px;
    padding: 0 4px;
    border: 1px solid var(--cv-border);
    border-radius: 10px;
    text-align: center;
    font-size: 1rem;
    font-weight: 700;
    color: var(--cv-text);
    background: #fff;
    -moz-appearance: textfield;
}

.cv-counter-input::-webkit-outer-spin-button,
.cv-counter-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cv-counter-input:focus {
    outline: none;
    border-color: var(--cv-purple);
    box-shadow: 0 0 0 3px var(--cv-purple-glow);
}

.cv-category-empty {
    grid-column: 1 / -1;
    font-size: 0.875rem;
    color: var(--cv-muted);
    text-align: center;
    padding: 1rem 0.5rem;
    margin: 0;
}

.cv-collection-new-cat {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    padding: 0 1rem;
    border: 1.5px solid var(--cv-purple);
    border-radius: 12px;
    background: transparent;
    color: var(--cv-purple);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.cv-collection-new-cat:hover {
    background: var(--cv-purple-soft);
    box-shadow: 0 2px 10px var(--cv-purple-glow);
}

.cv-collection-new-cat:focus-visible {
    outline: 2px solid var(--cv-purple);
    outline-offset: 2px;
}

.cv-collection-new-cat-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 0.5rem;
}

.cv-collection-new-cat-form.d-none {
    display: none;
}

.cv-collection-new-cat-input {
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    border: 1px solid var(--cv-border);
    border-radius: 12px;
    font-size: 0.9375rem;
    color: var(--cv-text);
    background: #fff;
}

.cv-collection-new-cat-input:focus {
    outline: none;
    border-color: var(--cv-purple);
    box-shadow: 0 0 0 3px var(--cv-purple-glow);
}

.cv-collection-new-cat-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

@media (min-width: 577px) {
    .cv-collection-new-cat {
        width: auto;
    }
}

.cv-collection-footer {
    border: none;
    padding: 0.75rem 1.5rem 1.25rem;
    gap: 10px;
    flex-wrap: wrap;
}

.cv-collection-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 1.25rem;
    border-radius: 12px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.cv-collection-btn--cancel {
    border: 1.5px solid var(--cv-border);
    background: #fff;
    color: var(--cv-muted);
}

.cv-collection-btn--cancel:hover {
    border-color: #cbd5e1;
    color: var(--cv-text);
    background: var(--cv-surface);
}

.cv-collection-btn--save {
    border: none;
    background: linear-gradient(135deg, var(--cv-purple) 0%, var(--cv-purple-dark) 100%);
    color: #fff;
    box-shadow: 0 4px 14px var(--cv-purple-glow);
}

.cv-collection-btn--save:hover:not(:disabled) {
    box-shadow: 0 6px 18px rgba(124, 58, 237, 0.35);
    transform: translateY(-1px);
}

.cv-collection-btn--save:disabled {
    opacity: 0.45;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.cv-collection-btn:focus-visible {
    outline: 2px solid var(--cv-purple);
    outline-offset: 2px;
}

@media (max-width: 576px) {
    .cv-collection-footer {
        flex-direction: column;
    }

    .cv-collection-btn {
        width: 100%;
    }
}

.cv-collection-toast {
    position: fixed;
    left: 50%;
    bottom: 1.5rem;
    transform: translateX(-50%) translateY(12px);
    max-width: min(420px, calc(100vw - 2rem));
    padding: 0.65rem 1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 600;
    color: #fff;
    background: #0f172a;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.2);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    z-index: 1090;
    text-align: center;
}

.cv-collection-toast.is-visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.cv-collection-toast.is-success {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.cv-collection-toast.is-error {
    background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%);
}

.cv-collection-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    padding: 1.5rem 1rem;
    text-align: center;
}

.cv-collection-loading-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--cv-purple-border);
    border-top-color: var(--cv-purple);
    border-radius: 50%;
    animation: cvCollectionSpin 0.75s linear infinite;
}

@keyframes cvCollectionSpin {
    to { transform: rotate(360deg); }
}

.cv-collection-loading-text {
    margin: 0;
    font-size: 0.85rem;
    color: var(--cv-muted);
}

.cv-collection-mode-chooser {
    margin-top: 0.5rem;
}

.cv-collection-mode-lead {
    margin: 0 0 0.85rem;
    font-size: 0.88rem;
    color: var(--cv-muted);
    text-align: center;
}

.cv-collection-mode-actions {
    display: grid;
    gap: 0.65rem;
}

.cv-collection-mode-btn {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    width: 100%;
    padding: 0.85rem 1rem;
    border: 1px solid var(--cv-border);
    border-radius: 14px;
    background: #fff;
    text-align: left;
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}

.cv-collection-mode-btn i {
    font-size: 1.1rem;
    color: var(--cv-purple);
    margin-bottom: 0.15rem;
}

.cv-collection-mode-btn:hover {
    border-color: var(--cv-purple);
    box-shadow: 0 4px 14px var(--cv-purple-glow);
    transform: translateY(-1px);
}

.cv-collection-mode-btn-title {
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--cv-text);
}

.cv-collection-mode-btn-sub {
    font-size: 0.78rem;
    color: var(--cv-muted);
}

.cv-collection-back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-bottom: 0.65rem;
    padding: 0;
    border: none;
    background: none;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--cv-purple);
}

.cv-collection-deck-panel .cv-collection-field-label,
.cv-collection-field-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--cv-muted);
    margin-bottom: 0.35rem;
}

.cv-collection-deck-select {
    margin-bottom: 0.85rem;
    border-radius: 10px;
}

.cv-collection-deck-qty {
    margin-bottom: 0.5rem;
}

.cv-collection-deck-qty .cv-category-counter {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding-top: 0;
}

.cv-offer-collection-btn.is-loading,
.cv-offer-btn.is-loading {
    opacity: 0.65;
    pointer-events: none;
    position: relative;
}

.cv-offer-collection-btn.is-loading::after,
.cv-offer-btn.is-loading::after {
    content: '';
    position: absolute;
    inset: auto;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: cvCollectionSpin 0.65s linear infinite;
}
