@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,400&display=swap');

:root {
    --bg: #09090b;
    --surface: #111113;
    --surface-2: #18181b;
    --border: rgba(255, 255, 255, 0.06);
    --text: #fafafa;
    --muted: #71717a;
    --card-w: 98px;
    --card-h: 143px;
    --radius: 12px;
    --accent: #a1a1aa;
}

* { box-sizing: border-box; }

body {
    font-family: 'DM Sans', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1.25rem;
    background: rgba(9, 9, 11, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}

.app-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin: 0;
    white-space: nowrap;
}

.app-title span { color: var(--muted); font-weight: 400; }

.app-nav {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.nav-link {
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
    white-space: nowrap;
}

.nav-link:hover {
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.14);
}

.nav-link.active {
    color: var(--text);
    background: var(--surface-2);
    border-color: rgba(255, 255, 255, 0.12);
}

.search-wrap {
    flex: 1;
    max-width: 320px;
    margin-left: auto;
    position: relative;
}

.search-wrap i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 0.85rem;
    pointer-events: none;
}

.search-input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2.25rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
    border-color: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}

.stats {
    font-size: 0.75rem;
    color: var(--muted);
    white-space: nowrap;
}

.main { padding: 0 1.25rem 2rem; max-width: 1400px; margin: 0 auto; }

.cat-bar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 0 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
}

#catPillsWrap {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow-x: auto;
    scrollbar-width: none;
    flex: 1;
    min-width: 0;
}

#catPillsWrap::-webkit-scrollbar { display: none; }

.cat-bar::-webkit-scrollbar { display: none; }

.cat-pill {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cat-pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--pill-color, #6366f1);
}

.cat-pill:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.12); }

.cat-pill.active {
    color: var(--text);
    background: var(--surface-2);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.cat-pill[data-id="0"].active {
    background: rgba(255, 255, 255, 0.08);
}

.cat-pill .count {
    font-size: 0.7rem;
    opacity: 0.6;
}

.cat-btn-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border: 1px dashed var(--border);
    border-radius: 50%;
    background: transparent;
    color: var(--muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.cat-btn-icon:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.2); }

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0 0.75rem;
    flex-wrap: wrap;
}

.drag-hint {
    font-size: 0.72rem;
    color: var(--muted);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.drag-hint.off { opacity: 0.4; }

.tipo-filter details { color: var(--muted); font-size: 0.75rem; }

.tipo-filter summary {
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.tipo-filter summary::-webkit-details-marker { display: none; }

.tipo-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.chip {
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--muted);
    font-size: 0.68rem;
    cursor: pointer;
    transition: all 0.15s;
}

.chip:hover, .chip.active {
    color: var(--text);
    background: var(--surface-2);
    border-color: rgba(255, 255, 255, 0.1);
}

.btn-tcgplayer {
    border-color: rgba(255, 140, 0, 0.35) !important;
    color: #ffb347 !important;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.btn-tcgplayer:hover {
    background: rgba(255, 140, 0, 0.12) !important;
    border-color: rgba(255, 140, 0, 0.55) !important;
    color: #ffc266 !important;
}

.btn-trollandtoad {
    border-color: rgba(34, 197, 94, 0.35) !important;
    color: #4ade80 !important;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.btn-trollandtoad:hover {
    background: rgba(34, 197, 94, 0.12) !important;
    border-color: rgba(34, 197, 94, 0.55) !important;
    color: #86efac !important;
}

.qty-stepper {
    display: flex;
    align-items: stretch;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    overflow: hidden;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.qty-stepper:focus-within {
    border-color: rgba(255, 255, 255, 0.18);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.04);
}

.qty-btn {
    flex-shrink: 0;
    width: 38px;
    border: none;
    background: var(--surface-2);
    color: var(--text);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, opacity 0.15s;
    padding: 0;
}

.qty-btn:first-child {
    border-right: 1px solid var(--border);
}

.qty-btn:last-child {
    border-left: 1px solid var(--border);
}

.qty-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.qty-btn:active:not(:disabled) {
    background: rgba(255, 255, 255, 0.12);
    transform: scale(0.96);
}

.qty-btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.qty-input {
    flex: 1;
    min-width: 0;
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text);
    font-size: 1rem;
    font-weight: 600;
    text-align: center;
    outline: none;
    padding: 0 0.25rem;
    -moz-appearance: textfield;
    appearance: textfield;
}

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

.grid-cartas {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 0.5rem 0 1rem;
    min-height: 120px;
}

.carta-item, .slot-add {
    width: var(--card-w);
    height: var(--card-h);
    border-radius: var(--radius);
    position: relative;
    flex-shrink: 0;
}

.carta-item {
    cursor: grab;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s;
}

.carta-item:active { cursor: grabbing; }

.carta-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    z-index: 2;
}

.carta-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: block;
    pointer-events: none;
}

.carta-item .grip {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.7);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.carta-item:hover .grip { opacity: 1; }

.badge-qty {
    position: absolute;
    top: -5px;
    right: -5px;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 999px;
    background: #fff;
    color: #09090b;
    font-size: 0.7rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3;
}

.carta-nombre {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 14px 6px 5px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.88));
    border-radius: 0 0 var(--radius) var(--radius);
    font-size: 0.52rem;
    color: rgba(255, 255, 255, 0.9);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.slot-add {
    border: 1px dashed rgba(255, 255, 255, 0.12);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 300;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s;
}

.slot-add:hover {
    border-color: rgba(255, 255, 255, 0.25);
    color: var(--text);
    background: var(--surface);
}

.empty-msg {
    width: 100%;
    text-align: center;
    padding: 3rem 1rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.sortable-ghost {
    opacity: 0.35;
    border: 1px dashed rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    background: var(--surface-2);
}

.sortable-ghost img { opacity: 0; }

.sortable-chosen { transform: scale(1.04) rotate(1deg); z-index: 10; }

.sortable-drag { opacity: 1 !important; box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6); }

.dropzone {
    border: 1px dashed rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
    background: var(--surface);
    cursor: pointer;
    min-height: 140px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    outline: none;
    transition: border-color 0.2s;
}

.dropzone:hover, .dropzone:focus { border-color: rgba(255, 255, 255, 0.2); }
.dropzone.dragover { border-color: rgba(255, 255, 255, 0.3); background: var(--surface-2); }
.dropzone.has-image { cursor: default; }
.dropzone img { max-height: 160px; border-radius: 8px; }
.dropzone p { margin: 0; font-size: 0.8rem; color: var(--muted); }

.modal-content {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    border-radius: 16px !important;
}

.modal-header, .modal-footer { border-color: var(--border) !important; }

.form-control, .form-select {
    background: var(--bg) !important;
    border-color: var(--border) !important;
    color: var(--text) !important;
}

.form-control:focus, .form-select:focus {
    border-color: rgba(255, 255, 255, 0.2) !important;
    box-shadow: none !important;
}

.form-text { color: var(--muted) !important; }

.cat-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0;
    border-bottom: 1px solid var(--border);
}

.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    padding: 0;
}

.cat-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.cat-check {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
    background: var(--surface);
}

.cat-check input { display: none; }

.cat-check .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
    background: color-mix(in srgb, var(--pill-color, #6366f1) 55%, var(--muted));
    opacity: 0.7;
}

.cat-check-name {
    white-space: nowrap;
}

.cat-check .cat-qty {
    margin-left: 0.15rem;
}

.cat-check:has(input:checked),
.cat-check.is-active {
    color: #fff;
    background: color-mix(in srgb, var(--pill-color, #6366f1) 28%, #18181b);
    border-color: var(--pill-color, #6366f1);
    box-shadow: 0 0 0 1px color-mix(in srgb, var(--pill-color, #6366f1) 70%, transparent),
                0 0 14px color-mix(in srgb, var(--pill-color, #6366f1) 35%, transparent);
}

.cat-check:has(input:checked) .dot,
.cat-check.is-active .dot {
    background: var(--pill-color, #6366f1);
    opacity: 1;
    box-shadow: 0 0 8px var(--pill-color, #6366f1);
}

.qty-stepper-sm {
    height: 28px;
    min-width: 5.5rem;
    flex-shrink: 0;
    border-radius: 8px;
    border-color: color-mix(in srgb, var(--pill-color, #6366f1) 45%, var(--border));
    background: rgba(0, 0, 0, 0.35);
}

.qty-stepper-sm .qty-btn {
    width: 24px;
    flex-shrink: 0;
    font-size: 0.75rem;
    color: #fff;
    background: color-mix(in srgb, var(--pill-color, #6366f1) 22%, var(--surface-2));
}

.qty-stepper-sm .qty-value {
    flex: 0 0 1.75rem;
    min-width: 1.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
    color: #fff;
    line-height: 1;
    user-select: none;
    pointer-events: none;
}

.qty-stepper-sm .qty-input {
    display: none;
}

.app-loader {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(9, 9, 11, 0.72);
    backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.app-loader.is-active {
    opacity: 1;
    visibility: visible;
    pointer-events: all;
}

.app-loader-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.85rem;
    padding: 1.25rem 1.5rem;
    border-radius: 14px;
    background: rgba(24, 24, 27, 0.95);
    border: 1px solid var(--border);
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}

.app-loader-spinner {
    width: 36px;
    height: 36px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: #fafafa;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.app-loader-text {
    margin: 0;
    font-size: 0.82rem;
    color: var(--muted);
    letter-spacing: 0.02em;
}

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

.grid-cartas.is-loading {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.15s;
}

/* ——— Página Decks ——— */
.page-decks {
    --deck-w: min(100%, 300px);
    --deck-h: 168px;
}

.grid-decks {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 0.5rem 0 1rem;
    min-height: 120px;
}

.deck-item, .deck-slot-add {
    width: var(--deck-w);
    max-width: 340px;
    height: var(--deck-h);
    border-radius: var(--radius);
    position: relative;
    flex-shrink: 0;
}

.deck-item {
    cursor: grab;
    transition: transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), box-shadow 0.2s;
}

.deck-item:active { cursor: grabbing; }

.deck-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    z-index: 2;
}

.deck-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center top;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #0c0c0e;
    display: block;
    pointer-events: none;
}

.deck-item .grip {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 20px;
    height: 20px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.55rem;
    color: rgba(255, 255, 255, 0.7);
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
    z-index: 2;
}

.deck-item:hover .grip { opacity: 1; }

.badge-fmt {
    position: absolute;
    top: 6px;
    right: 6px;
    padding: 0.15rem 0.45rem;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    font-size: 0.58rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #fff;
    border-left: 3px solid var(--pill-color, #6366f1);
    z-index: 2;
    pointer-events: none;
}

.deck-nombre {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 18px 8px 6px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.9));
    border-radius: 0 0 var(--radius) var(--radius);
    font-size: 0.72rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.95);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

.dropzone-deck img { max-height: 220px; max-width: 100%; }

.deck-preview-wrap {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #0c0c0e;
    overflow: auto;
    max-height: 70vh;
}

.deck-preview-wrap img {
    width: 100%;
    height: auto;
    display: block;
}

.fmt-radios {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.fmt-radio {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.75rem;
    border-radius: 999px;
    border: 1px solid var(--border);
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.15s;
    user-select: none;
}

.fmt-radio input { display: none; }

.fmt-radio .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--pill-color);
}

.fmt-radio:has(input:checked) {
    color: var(--text);
    background: var(--surface-2);
    border-color: rgba(255, 255, 255, 0.14);
}

.grid-decks.is-loading {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.15s;
}

.deck-hint { font-size: 0.72rem; }

@media (min-width: 768px) {
    :root { --card-w: 112px; --card-h: 164px; }
    .page-decks { --deck-w: 320px; --deck-h: 180px; }
}

@media (min-width: 1200px) {
    .page-decks { --deck-w: 360px; --deck-h: 200px; }
}
