* {
    box-sizing: border-box;
}

#binders-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.binder-book {
    display: flex;
    justify-content: center;
    background: #0d1117;
    padding: 25px;
    border-radius: 12px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8);
    border: 1px solid #21262d;
    max-width: 100%;
    margin-bottom: 25px;
    min-height: 512px;

    perspective: 1500px;
    position: relative;
}

.page-side {
    background: #161b22;
    width: 340px;
    height: 460px;
    padding: 20px;
    box-sizing: border-box;
    position: relative;
    border: 1px solid #30363d;

    backface-visibility: hidden;
    transform-style: preserve-3d;
    transition: transform 0.38s cubic-bezier(0.4, 0.0, 0.2, 1),
        opacity 0.38s cubic-bezier(0.4, 0.0, 0.2, 1);
    opacity: 1;
}

.left-side {
    border-radius: 8px 0 0 8px;
    border-right: 4px solid #090d13;

    transform-origin: right center;
}

.right-side {
    border-radius: 0 8px 8px 0;
    border-left: 4px solid #090d13;

    transform-origin: left center;
}

.page-side:not(.left-side):not(.right-side) {
    transform-origin: left center;
}

.cards-grid-2x2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 15px;
    height: 100%;
    width: 100%;
}

.card-item {
    background: #0d1117;
    border: 1px dashed #484f58;
    border-radius: 6px;
    overflow: hidden;
    aspect-ratio: 2.5 / 3.5;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.card-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    cursor: pointer;
    display: block;
}

.card-item:not(.slot-vacio):hover {
    transform: scale(1.04);
    border-color: #2278e2;
    box-shadow: 0 4px 12px rgba(34, 120, 226, 0.2);
}

.card-item.slot-vacio {
    cursor: default;
    pointer-events: none;
}

.empty-slot {
    width: 100%;
    height: 100%;
    background-color: #090d13;
}

.page-number-indicator {
    position: absolute;
    bottom: 5px;
    color: #8b949e;
    font-size: 11px;
    font-family: monospace;
    left: 50%;
    transform: translateX(-50%);
}

.left-side .page-number-indicator {
    left: 15px;
    transform: none;
}

.right-side .page-number-indicator {
    right: 15px;
    left: auto;
    transform: none;
}

.binder-controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 15px;
    background: #161b22;
    padding: 12px 25px;
    border-radius: 30px;
    border: 1px solid #30363d;
    max-width: 100%;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
}

.view-mode-container,
.album-select-container {
    color: #c9d1d9;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.view-mode-container select,
.album-select-container select {
    background: #0d1117;
    color: white;
    border: 1px solid #30363d;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
}

.nav-buttons-container {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
}

.nav-btn {
    background: #2278e2;
    color: white;
    border: none;
    padding: 8px 18px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
    transition: background 0.15s, transform 0.1s;
}

.nav-btn:hover {
    background: #1661bc;
}

.nav-btn:active {
    transform: scale(0.97);
}

.page-select-container {
    color: #c9d1d9;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-select-container input {
    background: #0d1117;
    color: #c9d1d9;
    border: 1px solid #30363d;
    padding: 8px 12px;
    border-radius: 6px;
    min-width: 50px;
    max-width: 70px;
    text-align: center;
    font-weight: bold;
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.modal-content {
    background: #161b22;
    border: 1px solid #30363d;
    color: #c9d1d9;
    padding: 25px;
    border-radius: 12px;
    width: 90%;
    max-width: 750px;
    position: relative;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.modal-grid {
    display: grid;
    grid-template-columns: 1fr 1.3fr;
    gap: 25px;
    align-items: center;
    overflow-y: auto;
    min-height: 0;
    padding-right: 5px;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 26px;
    cursor: pointer;
    color: #8b949e;
}

.close-btn:hover {
    color: white;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.info-grid p {
    margin: 0;
    padding-bottom: 4px;
    border-bottom: 1px solid #21262d;
    font-size: 14px;
}

.price-tag {
    color: #58a6ff;
    font-weight: bold;
}

.cards-grid-3x3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 10px;
    margin-top: 15px;
    height: calc(100% - 35px);
    box-sizing: border-box;
}

.cards-grid-3x3 .card-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.cards-grid-jumbo {
    display: block;
    width: 100%;
    height: calc(100% - 35px);
    margin-top: 15px;
    box-sizing: border-box;
}

.card-item.jumbo-item {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.card-item.jumbo-item img {
    width: auto;
    height: 100%;
    max-width: 100%;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.right-side.cover-page {
    border-radius: 0 8px 8px 0;
    border-left: none;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #0b0e14 !important;
}

.modal-info {
    min-width: 0;
    width: 100%;
}

.no-trade-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background-color: rgba(220, 20, 60, 0.95);
    color: white;
    font-size: 10px;
    font-family: Arial, sans-serif;
    font-weight: bold;
    padding: 4px 6px;
    border-radius: 4px;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    letter-spacing: 0.5px;
}

.btn-disponibles {
    margin-top: 15px;
    padding: 10px 15px;
    background-color: #2ea043;
    color: white;
    border: 1px solid rgba(240, 246, 252, 0.1);
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.2s;
}

.btn-disponibles:hover {
    background-color: #2c974b;
}

.btn-disponibles.btn-active {
    background-color: #21262d;
    border-color: #30363d;
}

.available-list {
    margin-top: 15px;
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 10px;
}

.table-responsive {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.available-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    color: #c9d1d9;
    text-align: left;
}

.available-table th {
    background-color: #161b22;
    color: #8b949e;
    padding: 8px;
    border-bottom: 1px solid #30363d;
    font-weight: 600;
}

.available-table td {
    padding: 8px;
    border-bottom: 1px solid #21262d;
    vertical-align: middle;
}

.available-table tbody tr:last-child td {
    border-bottom: none;
}

.available-table tbody tr:hover {
    background-color: rgba(110, 118, 129, 0.1);
}

.cm-table-btn {
    display: inline-block;
    padding: 3px 8px;
    background-color: #007bff;
    color: white !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.cm-table-btn:hover {
    background-color: #0056b3;
}

.reserved-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background-color: rgba(243, 156, 18, 0.95);
    color: white;
    font-size: 10px;
    font-family: Arial, sans-serif;
    font-weight: bold;
    padding: 4px 6px;
    border-radius: 4px;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    letter-spacing: 0.5px;
}

.right-side.flip-to-left {
    transform: rotateY(-120deg);
    opacity: 0;
    z-index: 10;
}

.left-side.flip-to-right {
    transform: rotateY(120deg);
    opacity: 0;
    z-index: 10;
}

.page-side.flip-single-next {
    transform: rotateY(-90deg);
    opacity: 0;
    z-index: 10;
}

.page-side.flip-single-prev {
    transform: rotateY(90deg);
    opacity: 0;
    z-index: 10;
}

.page-side.fade-in-start {
    opacity: 0 !important;
    transform: scale(0.98);
    transition: none !important;
}

.nav-btn:disabled,
#page-input:disabled {
    cursor: not-allowed !important;
    opacity: 0.6;
}

.disabled-controls,
.disabled-controls * {
    cursor: not-allowed !important;
}

#modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

#modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    pointer-events: none;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.modal-overlay .modal-content,
.modal-overlay .editor-modal-content {
    transform: translateY(-15px) scale(0.95);
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.active .modal-content,
.modal-overlay.active .editor-modal-content {
    transform: translateY(0) scale(1);
}

.editor-modal-content {
    background: #151a21;
    border: 1px solid #282e38;
    border-radius: 12px;
    width: 95%;
    max-width: 680px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    color: #e6edf3;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
}

.editor-modal-header {
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #21262d;
    position: relative;
}

.editor-modal-header h2 {
    margin: 0;
    font-size: 18px;
    color: #fff;
}

.editor-modal-body {
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.editor-section-title {
    font-weight: bold;
    font-size: 14px;
    color: #fff;
}

.editor-section {
    background: #0d1117;
    border: 1px solid #21262d;
    border-radius: 8px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.form-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 130px;
}

.form-group label {
    font-size: 12px;
    color: #8b949e;
}

.editor-input {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 6px;
    color: #fff;
    padding: 8px 10px;
    font-size: 13px;
    outline: none;
}

.editor-input:focus {
    border-color: #388bfd;
}

.checkbox-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px 16px;
}

.editor-checkbox {
    font-size: 13px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    white-space: nowrap;
}

.checkbox-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.filter-tag {
    background: #21262d;
    border: 1px solid #30363d;
    color: #58a6ff;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-tag .remove-tag {
    cursor: pointer;
    color: #8b949e;
    font-weight: bold;
}

.filter-tag .remove-tag:hover {
    color: #f85149;
}

.editor-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #21262d;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.btn-editor-primary {
    background: #1f6feb;
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}

.btn-editor-primary:hover {
    background: #388bfd;
}

.btn-editor-danger {
    background: #da3633;
    color: #fff;
    border: none;
    padding: 8px 18px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}

.btn-editor-danger:hover {
    background: #f85149;
}

.close-btn-editor {
    font-size: 22px;
    cursor: pointer;
    color: #8b949e;
    line-height: 1;
}

.close-btn-editor:hover {
    color: #fff;
}

.search-results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
}

.search-result-card {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 6px;
    padding: 5px;
    cursor: pointer;
    text-align: center;
    position: relative;
    transition: transform 0.2s, border-color 0.2s;
    animation: fadeInResult 0.3s ease-in-out;
}

.search-result-card:hover {
    transform: scale(1.04);
    border-color: #388bfd;
}

.search-result-card img {
    width: 100%;
    aspect-ratio: 2.5 / 3.5;
    object-fit: contain;
    border-radius: 4px;
    display: block;
}

.search-result-card .card-pos {
    font-size: 10px;
    color: #8b949e;
    margin-top: 4px;
}

@keyframes fadeInResult {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.badge-stack {
    position: absolute;
    top: 6px;
    left: 6px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    align-items: flex-start;
    z-index: 10;
    pointer-events: none;
}

.card-badge {
    color: white;
    font-size: 10px;
    font-family: Arial, sans-serif;
    font-weight: bold;
    padding: 4px 6px;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1;
    display: inline-block;
}

.badge-notrade {
    background-color: rgba(220, 20, 60, 0.95);
}

.badge-reserved {
    background-color: rgba(18, 115, 243, 0.95);
}

.badge-sold {
    background-color: rgba(46, 57, 160, 0.95);
}

.badge-traded {
    background-color: rgba(46, 160, 52, 0.95);
}

.badge-unavailable {
    background-color: rgba(137, 87, 229, 0.95);
}

.badge-conseguida {
    background-color: rgba(228, 240, 65, 0.95);
}

.card-status-dot {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    border-radius: 100%;
    z-index: 10;
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

@media (max-width: 768px) {
    .binder-book,
    .page-side {
        perspective: none !important;
        transform-style: flat !important;
        transform: none !important;
        -webkit-font-smoothing: antialiased;
        image-rendering: -webkit-optimize-contrast;
    }

    #binders-container {
        padding: 10px;
        width: 100%;
        margin: 0 auto;
    }

    .binder-book {
        padding: 0;
        background: transparent;
        border: none;
        box-shadow: none;
        width: 100%;
        max-width: 340px;
        margin: 0 auto 20px auto;
        min-height: auto;
    }

    .page-side {
        width: 100%;
        height: auto;
        min-height: 400px;
        border-radius: 8px !important;
        border: 1px solid #30363d !important;
        margin: 0 auto;
    }

    #view-mode-container {
        display: none;
    }

    .binder-controls {
        flex-direction: column;
        width: 100%;
        max-width: 340px;
        padding: 15px;
        border-radius: 12px;
        gap: 12px;
        margin: 0 auto;
    }

    .album-select-container {
        width: 100%;
        justify-content: space-between;
        box-sizing: border-box;
    }

    .album-select-container select {
        flex: 1;
        min-width: 0;
        max-width: 100%;
        text-overflow: ellipsis;
    }

    .modal-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .nav-buttons-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-areas:
            "pager pager"
            "prev next";
        gap: 10px;
        width: 100%;
    }

    .nav-btn {
        padding: 8px 12px;
        font-size: 12px;
        flex-grow: 1;
    }

    .page-select-container {
        grid-area: pager;
        justify-content: center;
        margin-bottom: 4px;
    }

    #prev-btn {
        grid-area: prev;
        width: 100%;
        padding: 10px;
        font-size: 13px;
        text-align: center;
    }

    #next-btn {
        grid-area: next;
        width: 100%;
        padding: 10px;
        font-size: 13px;
        text-align: center;
    }

    .modal-img img {
        max-height: 45vh;
        width: auto !important;
        margin: 0 auto;
        display: block;
    }

    #binder-book {
        min-height: 420px;
        scroll-margin: 0;
    }

    .checkbox-row {
        gap: 10px 14px;
    }
}