/* ==================== ORIGINAL CSS FULL RESTORATION ==================== */
:root {
    --primary: #1d1c1c;
    --secondary: #2d2d2d;
    --tertiary: #272727;
    --quaternary: #222222;
    --accent: #bebfc0;
    --accent-blue: #74a7da;
    --accent-blue2: #4a93dd;
    --accent-green: #8ae79e;
    --accent-green2: #3cd65d;
    --accent-green3: #3d5f4c;
    --light: #ebe8e8;
    --dark: #161616;
    --surface: #333333;
    --border: rgba(255,255,255,0.1);
    --radius-sm: 2px;
    --radius-md: 4px;
    --radius-lg: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, sans-serif;
}

body {
   /*  background-color: var(--primary); */
    background-color: var(--quaternary);
    color: var(--light);
    min-height: 100vh;
    line-height: 1.6;
    padding-top: 64px; /* Offset for fixed navbar */
    display: flex;
    flex-direction: column;
}

body, html {
    margin: 0;
    padding: 0;
}

html {
    scroll-padding-top: 64px; /* Prevent navbar overlap */
}

a {
    color: var(--light);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--accent);
}

/* styles.css - Cleaned card section */
.scan-card {
    background: var(--primary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    width: 360px !important;
    height: 360px !important;
    min-width: 360px !important;
    margin: 0 !important;
    transform: none !important;
    flex-shrink: 0;
    position: relative !important; /* Changed from absolute */
    grid-row: span 1;
    transition: all 0.2s ease;
}

.scan-card:hover {
    background: var(--secondary);
    border: 2px solid var(--border);
    animation: bounce 0.3s ease;
}

/* Define the bounce animation */
@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-64px);
    }
}

.scan-card .scan-info {
    display: none !important;
}

/* Square Cards */
.scan-card.square {
    aspect-ratio: 1/1;
    grid-column: span 1;
}

/* Wide Cards */
.scan-card.wide {
    width: 720px !important;
    height: 360px !important;
    grid-column: span 2;
    grid-row: span 1;
}

.scan-image {
    width: 100%;
    height: 100%;
}

.scan-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Grid Layout */
/* .recently-added .square-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    gap: 1.5rem;
    justify-content: start;
    padding: 0;
    margin: 0;
    width: 100%;
}
 */

 .recently-added .square-grid {
    grid-template-columns: repeat(auto-fill, 360px) !important;
    grid-auto-flow: dense !important;
    justify-content: start !important; /* Pack grid to left edge */
    margin: 0 auto !important;
    padding-left: 0 !important; /* Remove internal grid padding */
    margin-left: 0 !important;
    padding: 0 4px !important;
    width: calc(100% - 32px) !important;
}

.square-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)) !important;
    gap: 8px !important;
    padding: 8px !important;
    width: calc(100vw - 280px - 32px) !important;
    position: relative !important;
    grid-auto-flow: dense !important;
    align-items: start;
}

.form-wrapper {
    background: var(--secondary);
    padding: 2rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

#form-container form {
    display: grid;
    gap: 1.5rem;
}

#form-container label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

#form-container input,
#form-container select,
#form-container textarea {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--light);
}

.main-content {
    grid-column: 2;
    max-width: none;
    margin-left: 8px !important;
    padding-left: 0 !important; /* REMOVED left padding */
    padding-right: 16px !important; /* Keep existing right padding */
    width: calc(100% - 8px) !important; /* Account for right padding */
    overflow: visible !important;
}

.navbar {
    padding: 1rem 2rem;
    background-color: var(--dark);
    display: flex;
    align-items: center;
    gap: 2rem;
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    z-index: 1000;
}

#search-bar {
    background-color: var(--dark);
    position: relative;
    flex-grow: 1;
    max-width: 600px;
}

#search-bar input {
    background-color: var(--dark);
    color: var(--light);
    width: 100%;
    padding: 0.5rem 1rem;
    border: 1px solid #4d4d4d;
    border-radius: 20px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#search-bar input:focus {
    border-color: #007BFF;
}

/* Credits Display */
.credits-display {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    color: var(--light);
    font-weight: 500;
    background-color: var(--secondary);
    padding: 0.1rem 0.1rem;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.95rem;
}

@media (max-width: 768px) {
    .credits-display {
        display: none;
    }
}

.logo {
    height: 36px;
    transition: opacity 0.2s;
}

.logo:hover {
    opacity: 0.8;
}

.library-container {
    display: grid;
    grid-template-columns: 280px 1fr; /* Sidebar + main */
    gap: 0;
    margin-left: 0;
    padding: 120px 0 0 0; /* Reset padding */
    width: 100vw;
    max-width: 100%;
}

.filter-group {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.filter-title {
    color: var(--accent);
    font-size: 1.1rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.filter-items {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-item {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-item:hover {
    background: var(--surface);
}

.count {
    background: var(--primary);
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-feature-settings: 'tnum';
}

/* Collapsible Locations */
.filter-header {
    padding: 1rem 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: background 0.2s;
}

.filter-header:hover {
    background: rgba(255,255,255,0.05);
}

.locations-list {
    padding: 0 1.5rem;
}

.filter-group.collapsible {
    border-bottom: none;
    margin-bottom: 0;
}

.meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    margin: 0.75rem 0;
}

.credits {
    color: var(--accent);
    font-weight: 500;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.85);
    backdrop-filter: blur(1px);
    z-index: 2000;
    padding: 2rem;
    overflow-y: auto;
    display: none;
}

.modal-content {
    background: var(--secondary);
    border-radius: 12px;
    max-width: 1600px;
    margin: 2rem auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    border: 1px solid var(--border);
}


.modern-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(255,255,255,0.1);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--light);
    z-index: 100;
}

.modern-close:hover {
    background: rgba(255,255,255,0.2);
    transform: rotate(90deg);
}

.modal-images-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    padding: 2rem;
}

.modal-image-item {
    width: 100%;
    height: 400px;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
    background: var(--primary);
}


.modal-image-item:hover {
    transform: scale(1.02);
}

.modal-info {
    padding: 2rem;
    border-top: 1px solid var(--border);
}

.specs-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    margin: 2rem 0;
}

.spec-item {
    display: flex;
    flex-direction: column;
    padding: 1rem;
    background: var(--primary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.spec-label {
    font-size: 0.9rem;
    color: rgba(255,255,255,0.7);
    margin-bottom: 0.5rem;
}

/* Purchase/Download Buttons */
.modern-download-btn {
    background: var(--accent-green) !important;
    color: white !important;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: none;
    width: 100%;
    cursor: pointer;
    transition: opacity 0.2s;
}

.modern-purchase-btn {
    background: #10b981 !important;
    color: white !important;
    padding: 1rem;
    border-radius: var(--radius-md);
    border: none;
    width: 100%;
    cursor: pointer;
    transition: opacity 0.2s;
}

.modern-purchase-btn:disabled {
    background: #64748b !important;
    cursor: not-allowed;
    opacity: 0.7;
}

.modal-info h2 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.modal-images {
    width: 80%;
    margin: 0 auto;
}

.main-modal-image {
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    cursor: zoom-in;
    transition: transform 0.2s;
}

.main-modal-image:hover {
    transform: scale(1.01);
}

.specs p {
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.97);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.lightbox-image {
    max-width: 90vw;
    max-height: 90vh;
    object-fit: contain;
    border-radius: var(--radius-md);
    box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

.lightbox-close {
    top: 1.5rem;
    right: 1.5rem;
    background: rgba(255,255,255,0.1);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.lightbox-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    font-size: 2rem;
    background: rgba(255,255,255,0.1);
    border: none;
    color: white;
    padding: 1rem 1.5rem;
    cursor: pointer;
    border-radius: var(--radius-md);
    transition: background 0.2s;
}

.lightbox-arrow:hover {
    background: rgba(255,255,255,0.2);
}

.lightbox-arrow.left {
    left: 2rem;
}

.lightbox-arrow.right {
    right: 2rem;
}

/* HTMX Loading States */
.count.htmx-request {
    opacity: 0.5;
    position: relative;
}

.count.htmx-request::after {
    content: "";
    display: block;
    width: 1rem;
    height: 1rem;
    border: 2px solid var(--accent);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    position: absolute;
    right: -1.5rem;
    top: 50%;
    transform: translateY(-50%);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Skeleton Loader */
@keyframes shimmer {
    0% { background-position: -1000px 0 }
    100% { background-position: 1000px 0 }
}

.skeleton-loader {
    width: 40px;
    height: 1rem;
    background: linear-gradient(90deg, #2d2d2d 25%, #333 50%, #2d2d2d 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

/* Unique ID Section */
.unique-id-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    background: var(--primary);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    width: fit-content;
}

.copy-id-btn {
    background: none;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--light);
    transition: all 0.2s;
    border-radius: var(--radius-sm);
}

.copy-id-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--accent-green);
}

.unique-id-field {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: var(--light);
    user-select: all;
}

.unique-id-field span {
    opacity: 0.9;
    letter-spacing: 0.5px;
}

/* Clipboard Icon Styling */
.clipboard-icon {
    width: 20px;
    height: 20px;
    filter: invert(0%) sepia(3%) saturate(157%) hue-rotate(0deg) brightness(100%) contrast(100%);
    transition: all 0.2s;
}

.copy-id-btn:hover .clipboard-icon {
    filter: invert(56%) sepia(98%) saturate(7498%) hue-rotate(200deg) brightness(100%) contrast(105%);
}

/* Maintain existing logo styles */
.logo {
    height: 36px;
    transition: opacity 0.2s;
    position: relative;
}

.logo-link {
    position: relative;
    display: inline-block;
}

/* Add to existing form styles */
#credit-container form {
    display: grid;
    gap: 1.5rem;
    padding: 1.5rem;
}

#credit-container label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--accent);
}

#credit-container input {
    width: 100%;
    padding: 0.75rem;
    background: var(--primary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--light);
}

.collections-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
    padding: 1.5rem;
}

.collection-card {
    background: var(--secondary);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: transform 0.2s;
    cursor: pointer;
}
.collection-card:hover {
    transform: translateY(-3px);
}

.meta {
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

@media (max-width: 768px) {
    .collections-grid { grid-template-columns: 1fr; }
}

.modal-wide {
    width: 80%;
    max-width: 1200px;
}

/* Add to styles.css */
.collection-thumbs-grid {
    display: grid;
    gap: 1rem;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    margin-bottom: 2rem;
}

.thumb-aspect-2-1 {
    grid-column: span 2;
    aspect-ratio: 2/1;
}

.thumb-aspect-1-2 {
    grid-row: span 2;
    aspect-ratio: 1/2;
}

.thumb-aspect-2-2 {
    grid-column: span 2;
    grid-row: span 2;
    aspect-ratio: 1/1;
}

.collection-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.collection-meta {
    padding: 1.5rem;
    background: var(--secondary);
    border-radius: var(--radius-md);
    margin-bottom: 2rem;
}

.stats {
    display: flex;
    gap: 1.5rem;
    margin-top: 1rem;
    color: rgba(255,255,255,0.7);
    font-size: 0.9rem;
}

.curator {
    font-size: 0.95rem;
    margin-bottom: 0.5rem;
}

.description {
    line-height: 1.6;
}

/* Loading Indicator */
.loading-indicator {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    display: none;
}

/* View Controls */
.view-controls {
    margin-left: auto;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.view-toggle {
    background-color: var(--quaternary);
    padding: 0.1rem 0.1rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.view-toggle.active {
    background-color: var(--accent-green3);
    color: white;
    padding: 0rem 0.4rem;
    border-radius: var(--radius-md);
}

/* Ensure filter bar is visible */
.filter-bar {
    position: fixed;
    top: 82px;
    left: 272px;
    right: 0;
    background-color: var(--quaternary);
    padding: 1rem calc((100% - 280px - 2280px) / 2 + 16px); /* Align with content */
    width: calc(100% - 280px); /* Remaining space */
    display: flex;
    gap: 1.5rem;
    align-items: center;
    z-index: 998;
    height: 32px;
}

/* ==================== RESPONSIVE FIXES ==================== */
@media (max-width: 1600px) {
    .recently-added .square-grid {
        grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
    }
}

@media (max-width: 768px) {
    .library-container {
        grid-template-columns: 1fr;
        padding-top: 64px;
    }
    
    .main-content {
        grid-column: 1;
        width: 100vw;
        margin-left: 0 !important;
        padding: 0 8px !important; /* Balanced mobile padding */
    }
    
    .scan-card, .scan-card.wide {
        width: 100% !important;
        height: 360px !important;
        grid-column: span 1 !important;
        margin-left: 0 !important;
    }
}

/* ==================== TAB NAVIGATION ==================== */
.tab-nav {
    display: flex;
    gap: 1.5rem;
    padding: 1.5rem 16px;
    justify-content: center;
    background: transparent;
    border: none;
    position: sticky;
    top: 120px;
    z-index: 997;
}

.tab-link {
    padding: 0.75rem 2rem;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    transition: all 0.2s;
    text-decoration: none;
    color: var(--light);
    border: 1px solid var(--border);
    backdrop-filter: blur(4px);
}

.tab-link:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.tab-link.active {
    background: rgba(74, 156, 255, 0.15); /* Accent color with transparency */
    border-color: var(--accent);
    color: var(--accent);
}

/* Adjust main content spacing */
.main-content {
    margin-top: 40px !important;
}

.favorite-btn {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0,0,0,0.5);
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s;
}

.favorite-btn.active {
    color: #ff4081;
    background: rgba(255,64,129,0.2);
}

.success-banner {
    padding: 1rem;
    background: #10b981;
    color: white;
    border-radius: var(--radius-md);
    margin: 1rem 0;
    animation: slide-in 0.3s ease;
}

.error-banner {
    padding: 1rem;
    background: #dc2626;
    color: white;
    border-radius: var(--radius-md);
    margin: 1rem 0;
    animation: slide-in 0.3s ease;
}

@keyframes slide-in {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* Pagination */

.pagination {
    grid-column: 1 / -1;
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    padding: 2rem 0;
    width: 100%;
}

.page-item {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--quaternary);
    color: var(--light);
    cursor: pointer;
    transition: all 0.2s;
}

.page-item:hover {
    background: var(--accent-green2);
}

.page-item.active {
    background: var(--accent-green3);
    border-color: var(--accent-green3);
    color: white;
}

[htmx-indicator] {
    display: none;
}
[htmx-indicator].htmx-request {
    display: block;
}