/* Page-specific override */
body {
    padding: 20px;
}

/* Main container — glass-morphism */
.container {
    max-width: 1200px;
    margin: 0 auto;
    background: linear-gradient(135deg, rgba(138,106,58,0.08) 0%, transparent 50%), rgba(28,24,18,0.6);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(138,106,58,0.35);
    border-radius: 2px;
    padding: 30px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    z-index: 2;
    position: relative;
}

/* Header styles */
h1 {
    font-family: 'Cinzel', serif;
    color: #D4A017;
    text-align: center;
    margin-bottom: 10px;
    font-size: clamp(20px, 6vw, 42px);
    letter-spacing: 2px;
}

h2, h3 {
    font-family: 'Cinzel', serif;
    color: #D4A017;
}

p {
    text-align: center;
    color: #bbb;
    margin-bottom: 30px;
}

/* Input section */
.input-section {
    margin-bottom: 30px;
}

.input-section label {
    display: block;
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 16px;
}

.wallet-inputs {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}

.wallet-input {
    font-family: 'Cinzel', serif;
    width: 100%;
    padding: 12px;
    font-size: 16px;
    border: 2px solid #333;
    border-radius: 5px;
    outline: none;
    background: #332c26;
    color: #eee;
}

.wallet-input:focus {
    border-color: #667eea;
}

.wallet-input::placeholder {
    color: #999;
}

input::placeholder {
    color: #888;
}

.container button {
    font-family: 'Cinzel', serif;
    padding: 12px 30px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.container button:hover {
    background: #5568d3;
}

.container button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Sort section */
.sort-section {
    background: #332c26;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    cursor: pointer;
    user-select: none;
}

.section-header h3 {
    font-family: 'Cinzel', serif;
    color: #D4A017;
    margin: 0;
    font-size: 20px;
}

.toggle-btn {
    background: transparent;
    color: #667eea;
    border: 2px solid #667eea;
    border-radius: 5px;
    width: 30px;
    height: 30px;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.3s;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toggle-btn:hover {
    background: #667eea;
    color: white;
}

.section-content {
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    opacity: 1;
}

.section-content.collapsed {
    max-height: 0;
    opacity: 0;
}

.sort-controls {
    display: flex;
    align-items: center;
    gap: 10px;
}

.sort-controls label {
    font-family: 'Cinzel', serif;
    color: #bbb;
    font-size: 14px;
}

.sort-controls select {
    font-family: 'Cinzel', serif;
    padding: 10px 15px;
    background: #231e18;
    color: #eee;
    border: 2px solid #333;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    min-width: 200px;
}

.sort-controls select:focus {
    border-color: #667eea;
}

/* Filter section */
.filter-section {
    background: #332c26;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
}

.filter-controls {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 15px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.filter-group label {
    font-family: 'Cinzel', serif;
    font-size: 12px;
    color: #bbb;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.filter-group select {
    font-family: 'Cinzel', serif;
    padding: 8px;
    background: #231e18;
    color: #eee;
    border: 2px solid #333;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
}

.filter-group select:focus {
    border-color: #667eea;
}

.clear-filters-btn {
    font-family: 'Cinzel', serif;
    padding: 10px 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.3s;
}

.clear-filters-btn:hover {
    background: #c82333;
}

.filter-count {
    color: #bbb;
    font-size: 14px;
    margin-top: 10px;
}

/* Quick actions */
.quick-actions {
    margin-bottom: 20px;
    text-align: center;
}

.quick-filters {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.training-filter {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #332c26;
    padding: 10px 15px;
    border-radius: 8px;
    border: 2px solid #333;
}

.training-label {
    color: #eee;
    font-size: 14px;
    font-weight: 600;
}

.training-filter select {
    font-family: 'Cinzel', serif;
    padding: 8px 12px;
    background: #231e18;
    color: #eee;
    border: 2px solid #333;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
    min-width: 140px;
}

.training-filter select:focus {
    border-color: #667eea;
}

.select-all-btn {
    padding: 10px 25px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.3s;
}

.select-all-btn:hover {
    background: #5568d3;
}

.select-all-btn.deselect {
    background: #ff9800;
}

.select-all-btn.deselect:hover {
    background: #f57c00;
}

.drag-hint {
    margin: 10px 0 0 0;
    color: #bbb;
    font-size: 14px;
    font-style: italic;
}

/* Loading and error messages */
.loading, .error {
    text-align: center;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.loading {
    background: #1e3a5f;
    color: #64b5f6;
}

.error {
    background: #3d1f1f;
    color: #ef5350;
}

/* NFT container */
.nft-container {
    margin-top: 30px;
}

/* Collection section */
.collection {
    margin-bottom: 40px;
}

.collection-header {
    background: #332c26;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.collection-name {
    font-family: 'Cinzel', serif;
    font-size: 22px;
    font-weight: bold;
    color: #D4A017;
    letter-spacing: 1px;
}

.collection-count {
    color: #bbb;
    font-size: 14px;
}

/* NFT grid */
.nft-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 20px;
}

/* Mobile: Smaller NFT cards to fit more across */
@media (max-width: 768px) {
    .nft-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 10px;
    }

    .nft-image {
        height: 90px;
    }

    .nft-info {
        padding: 5px;
    }

    .nft-name {
        font-size: 10px;
    }

    .nft-description {
        font-size: 9px;
    }

    .nft-checkbox {
        width: 16px;
        height: 16px;
        top: 4px;
        left: 4px;
    }
}

/* Individual NFT card */
.nft-card {
    border: 2px solid #333;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
    position: relative;
    background: #332c26;
}

.nft-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.nft-image {
    width: 100%;
    height: 130px;
    object-fit: cover;
    background: #f0f0f0;
}

.nft-info {
    padding: 8px;
    background: #332c26;
}

.nft-name {
    font-family: 'Cinzel', serif;
    font-weight: bold;
    color: #eee;
    font-size: 12px;
    letter-spacing: 0.3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px;
    color: #888;
}

/* Selection controls */
.selection-controls {
    background: #332c26;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    justify-content: space-between;
}

.selection-info {
    font-size: 16px;
    font-weight: bold;
    color: #eee;
}

.collage-btn {
    padding: 12px 30px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.collage-btn:hover:not(:disabled) {
    background: #218838;
}

.collage-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.clear-btn {
    padding: 12px 30px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.clear-btn:hover {
    background: #c82333;
}

/* NFT selection checkbox */
.nft-card {
    position: relative;
}

.nft-checkbox {
    position: absolute;
    top: 6px;
    left: 6px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    z-index: 10;
    accent-color: #667eea;
}

.nft-card.selected {
    border: 3px solid #667eea;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
}

/* Arrangement area */
.arrangement-area {
    background: #332c26;
    border: 2px dashed #667eea;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 30px;
}

.arrangement-area h3 {
    color: #eee;
    margin: 0 0 10px 0;
    font-size: 20px;
}

.arrangement-hint {
    color: #bbb;
    font-size: 14px;
    margin: 0 0 20px 0;
}

.arrangement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
    gap: 15px;
    min-height: 100px;
}

/* Mobile: Smaller arrangement items */
@media (max-width: 768px) {
    .arrangement-grid {
        grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
        gap: 10px;
    }

    .arrangement-item img {
        height: 90px;
    }

    .arrangement-item .item-name {
        padding: 5px;
        font-size: 10px;
    }

    .arrangement-item .remove-btn {
        width: 18px;
        height: 18px;
        font-size: 12px;
        line-height: 18px;
    }
}

/* Arrangement item (draggable) */
.arrangement-item {
    position: relative;
    border: 2px solid #333;
    border-radius: 8px;
    overflow: hidden;
    cursor: move;
    transition: all 0.2s;
    background: #231e18;
}

.arrangement-item:hover {
    border-color: #667eea;
    box-shadow: 0 3px 10px rgba(102, 126, 234, 0.3);
}

.arrangement-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.arrangement-item.drag-over {
    border: 3px dashed #667eea;
    background: #1e3a5f;
}

.arrangement-item img {
    width: 100%;
    height: 135px;
    object-fit: cover;
    display: block;
}

.arrangement-item .item-name {
    padding: 8px;
    font-size: 12px;
    font-weight: bold;
    color: #eee;
    text-align: center;
    background: #231e18;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.arrangement-item .remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 20px;
    height: 20px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    line-height: 20px;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.arrangement-item .remove-btn:hover {
    background: #c82333;
}

/* Preview Modal */
.preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.preview-content {
    background: #231e18;
    border-radius: 10px;
    max-width: 95%;
    max-height: 90vh;
    width: fit-content;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.8);
    overflow: hidden;
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #333;
}

.preview-header h2 {
    margin: 0;
    color: #D4A017;
    font-size: 24px;
}

.close-preview-btn {
    background: none;
    border: none;
    font-size: 36px;
    color: #888;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 40px;
    height: 40px;
    transition: color 0.3s;
}

.close-preview-btn:hover {
    color: #eee;
}

/* Layout controls in preview modal */
.layout-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    background: #332c26;
    border-bottom: 1px solid #333;
}

.layout-controls label {
    color: #bbb;
    font-size: 14px;
}

.layout-controls select {
    font-family: 'Cinzel', serif;
    padding: 8px 12px;
    background: #231e18;
    color: #eee;
    border: 2px solid #333;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    outline: none;
}

.layout-controls select:focus {
    border-color: #667eea;
}

.spacing-control {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: 20px;
}

.spacing-control label {
    color: #bbb;
    font-size: 14px;
    white-space: nowrap;
}

.spacing-control input[type="range"] {
    width: 120px;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #333;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.spacing-control input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.spacing-control input[type="range"]::-webkit-slider-thumb:hover {
    background: #5568d3;
}

.spacing-control input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    background: #667eea;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.preview-body {
    padding: 20px;
    overflow: auto;
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
}

.preview-grid {
    display: grid;
    gap: 15px;
    padding: 20px;
    background: #ffffff;
    border-radius: 8px;
    width: fit-content;
    margin: 0 auto;
    max-width: 100%;
    box-sizing: border-box;
}

.preview-grid-item {
    position: relative;
    border: 2px solid #333;
    border-radius: 5px;
    overflow: hidden;
    cursor: move;
    transition: all 0.2s;
    background: #f5f5f5;
}

.preview-grid-item:hover {
    border-color: #667eea;
    box-shadow: 0 0 15px rgba(102, 126, 234, 0.5);
    transform: scale(1.05);
}

.preview-grid-item.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}

.preview-grid-item.drag-over {
    border: 3px dashed #667eea;
    background: #e3f2fd;
}

.preview-grid-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

.preview-grid-item.placeholder-item {
    opacity: 0.85;
}

.preview-grid-item.placeholder-item:hover {
    opacity: 1;
}

.preview-footer {
    padding: 20px;
    border-top: 2px solid #333;
    display: flex;
    gap: 15px;
    justify-content: center;
}

.download-btn {
    padding: 12px 30px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.download-btn:hover {
    background: #218838;
}

.cancel-btn {
    padding: 12px 30px;
    background: #6c757d;
    color: white;
    border: none;
    border-radius: 5px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.cancel-btn:hover {
    background: #5a6268;
}

/* NFT Details Modal */
.nft-details-content {
    max-width: 900px;
    max-height: 85vh;
}

.nft-details-body {
    display: flex;
    gap: 30px;
    padding: 20px;
    overflow-y: auto;
    flex-direction: row;
    align-items: flex-start;
}

.nft-details-image {
    flex-shrink: 0;
    width: 350px;
}

.nft-details-image img {
    width: 100%;
    border-radius: 8px;
    border: 2px solid #ddd;
}

.nft-details-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.nft-details-section h3 {
    margin: 0 0 10px 0;
    color: #D4A017;
    font-size: 18px;
    border-bottom: 2px solid #D4A017;
    padding-bottom: 5px;
}

.nft-details-section p {
    margin: 0;
    color: #bbb;
    line-height: 1.5;
}

.traits-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.trait-item {
    background: #332c26;
    padding: 10px;
    border-radius: 5px;
    border-left: 3px solid #667eea;
}

.trait-type {
    font-size: 12px;
    color: #888;
    text-transform: uppercase;
    margin-bottom: 3px;
}

.trait-value {
    font-size: 14px;
    color: #eee;
    font-weight: bold;
}

.mint-address {
    font-family: monospace;
    font-size: 12px;
    word-break: break-all;
    background: #332c26;
    color: #bbb;
    padding: 10px;
    border-radius: 5px;
}

.no-traits {
    color: #888;
    font-style: italic;
}

/* Responsive for smaller screens */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }

    h1 {
        margin-bottom: 8px;
    }

    p {
        font-size: 14px;
        margin-bottom: 20px;
    }

    .input-section {
        flex-direction: column;
        gap: 8px;
    }

    input, button {
        font-size: 14px;
        padding: 10px;
    }

    .sort-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .sort-controls select {
        width: 100%;
        min-width: 0;
    }

    .section-header h3 {
        font-size: 18px;
    }

    .toggle-btn {
        width: 28px;
        height: 28px;
        font-size: 20px;
    }

    .filter-controls {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 10px;
    }

    .selection-controls {
        flex-wrap: wrap;
        gap: 10px;
    }

    .selection-info {
        font-size: 14px;
        width: 100%;
    }

    .nft-details-body {
        flex-direction: column;
    }

    .nft-details-image {
        width: 100%;
    }

    .traits-grid {
        grid-template-columns: 1fr;
    }

    .preview-content {
        max-width: 98%;
        max-height: 95vh;
    }

    .preview-grid {
        padding: 10px;
        gap: 8px;
    }

    .preview-grid-item {
        border-width: 1px;
    }

    .preview-header {
        padding: 15px;
    }

    .preview-header h2 {
        font-size: clamp(14px, 3vw, 18px);
        line-height: 1.3;
    }

    .preview-body {
        padding: 10px;
    }

    .preview-footer {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
    }

    .preview-footer button {
        width: 100%;
    }
}

@media (max-width: 640px) {
    .container {
        padding: 15px 10px;
    }

    .filter-controls {
        grid-template-columns: repeat(2, 1fr);
    }

    .layout-controls {
        flex-wrap: wrap;
    }

    .spacing-control {
        margin-left: 0;
        width: 100%;
    }
}

@media (max-width: 400px) {
    .nft-grid {
        grid-template-columns: repeat(auto-fill, minmax(75px, 1fr));
        gap: 8px;
    }

    .filter-controls {
        grid-template-columns: 1fr;
    }

    .container button {
        width: 100%;
        min-height: 44px;
    }

    .selection-controls {
        gap: 8px;
    }

    .collage-btn,
    .clear-btn,
    .select-all-btn,
    .clear-filters-btn {
        width: 100%;
        min-height: 44px;
    }
}
