/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #060621;
    background-image: radial-gradient(ellipse at 1957px -27px, #0C0E6B 0%, rgba(17, 17, 42, 0) 100%);
    min-height: 100vh;
    color: #1a202c;
    line-height: 1.6;
}

/* Utility classes */
.hidden {
    display: none !important;
}

/* Login styles */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 48px;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    width: 100%;
    max-width: 420px;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.login-box h2,
.login-title {
    margin-bottom: 10px;
    color: #333;
    font-size: 28px;
    font-weight: 600;
}

.login-card {
    text-align: left;
}

.login-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 24px;
}

.login-mark {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    flex-shrink: 0;
}

.login-name {
    font-size: 14px;
    font-weight: 600;
    color: #444;
    letter-spacing: 0.02em;
}

.login-lede {
    color: #666;
    font-size: 14.5px;
    line-height: 1.5;
    margin: 0 0 20px;
}

.login-lede code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 13px;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    color: #334155;
}

.login-error {
    color: #b91c1c;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 16px;
    font-size: 14px;
    text-align: left;
}

.sso {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
    padding: 12px 18px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: #1e293b;
    background: #fffdf8;
    cursor: pointer;
    text-decoration: none;
    box-sizing: border-box;
    transition: filter 120ms ease, transform 60ms ease;
}

.sso:hover {
    filter: brightness(0.97);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.15);
}

.sso:active {
    transform: translateY(0);
}

.google-btn-host {
    display: flex;
    justify-content: center;
    margin-top: 8px;
}

.login-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 20px 0 16px;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #94a3b8;
}

.login-divider::before,
.login-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}

.login-submit-btn {
    width: 100%;
    margin-top: 4px;
}

.login-foot {
    margin-top: 24px;
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.55;
    text-align: left;
}

.subtitle {
    margin: 0 0 20px 0;
    color: #666;
    text-align: center;
    font-size: 14px;
    font-style: italic;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #555;
}

.form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
}

button:active {
    transform: translateY(0);
}

/* Main container */
.main-container {
    min-height: 100vh;
    background: transparent;
}

/* Header */
.header {
    background: transparent;
    padding: 24px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.header-title {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.header h1 {
    color: white;
    font-size: 28px;
    font-weight: 600;
    margin: 0;
}

.alpha-notice {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    font-style: italic;
    margin: 0;
    font-weight: 400;
}

.search-container {
    display: flex;
    gap: 12px;
    flex: 1;
    max-width: 700px;
    margin-left: 20px; /* Move container to the right */
}

.search-container input {
    flex: 1;
    min-width: 350px; /* Expand search input */
    padding: 12px 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.2s ease;
    background: rgba(255, 255, 255, 0.9);
    color: #1a202c;
}

.search-container input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.search-container button:not(.browse-all-btn) {
    padding: 12px 24px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.search-container button:not(.browse-all-btn):hover {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.logout-btn {
    background: #dc3545;
    padding: 12px 20px;
}

.logout-btn:hover {
    background: #c82333;
    box-shadow: 0 8px 20px rgba(220, 53, 69, 0.3);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.wonder-logo {
    height: 32px;
    width: auto;
    filter: brightness(0) invert(1);
}

/* Main content */
.main-content {
    padding: 30px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px 20px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading p {
    color: #666;
    font-size: 16px;
}

/* Results info */
.results-info {
    margin-bottom: 30px;
    padding: 15px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.results-info p {
    color: white;
    font-size: 16px;
    margin: 0;
}

/* Assets grid */
.assets-grid {
    display: flex;
    flex-direction: column;
    gap: 32px;
    margin-bottom: 24px;
    padding: 0 32px;
}

/* Title groups */
.title-group {
    background: #060621;
    background-image: radial-gradient(ellipse at 1957px -27px, #0C0E6B 0%, rgba(17, 17, 42, 0) 100%);
    padding: 24px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    margin-bottom: 24px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.group-title-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.5);
    padding-bottom: 8px;
}

.group-title {
    color: white;
    font-size: 20px;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.group-types {
    color: #666;
    font-size: 14px;
    margin: 0;
}

.group-content-type,
.group-studio,
.group-ref-id,
.group-season {
    color: white;
    font-size: 14px;
    margin: 8px 0 0 0;
}

/* IMDB link button */
.imdb-link-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.imdb-label {
    font-style: italic;
    color: white;
    font-size: 14px;
}

.imdb-link-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5c518;
    color: #000;
    text-decoration: none;
    padding: 6px 8px;
    border-radius: 6px;
    font-size: 0;
    font-weight: 600;
    transition: all 0.2s ease;
    flex-shrink: 0;
    white-space: nowrap;
    width: 32px;
    height: 32px;
    min-width: 32px;
    min-height: 32px;
}

.imdb-link-btn:hover {
    background: #f7d047;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(245, 197, 24, 0.4);
}

.imdb-link-btn svg {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
}

.group-assets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
    position: relative;
}

.asset-card-with-url {
    display: flex;
    flex-direction: column;
}

.asset-url-wrapper {
    margin-top: 8px;
    padding: 8px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.asset-url-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: #60a5fa;
    text-decoration: none;
    font-size: 11px;
    word-break: break-all;
    transition: color 0.2s;
}

.asset-url-link:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.asset-url-link svg {
    flex-shrink: 0;
    color: #60a5fa;
}

.asset-url-text {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.asset-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    transition: all 0.2s ease;
    cursor: pointer;
    border: 1px solid #e2e8f0;
    position: relative;
}

.asset-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    border-color: #3b82f6;
}

.asset-image-container {
    position: relative;
    width: 100%;
    height: 120px;
    background: #f8f9fa;
}

.asset-image-container.logo-background {
    background-image: 
        linear-gradient(45deg, #b0b0b0 25%, transparent 25%),
        linear-gradient(-45deg, #b0b0b0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #b0b0b0 75%),
        linear-gradient(-45deg, transparent 75%, #b0b0b0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #ffffff;
}

.asset-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.asset-download-btn {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s ease, background 0.2s ease;
    z-index: 10;
    padding: 0;
}

.asset-card:hover .asset-download-btn {
    opacity: 1;
}

.asset-download-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.asset-download-btn svg {
    width: 18px;
    height: 18px;
}

.asset-info {
    padding: 8px;
}

.asset-title {
    font-size: 12px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.asset-content-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.asset-type {
    font-size: 13px;
    color: #667eea;
    font-weight: 600;
    margin-bottom: 2px;
    background: #f0f2ff;
    padding: 2px 6px;
    border-radius: 3px;
    display: inline-block;
}

.image-type-tag {
    display: inline-block;
    padding: 2px 6px;
    margin-right: 4px;
    background: #f0f2ff;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 600;
    color: #667eea;
}

.asset-season-episode {
    font-size: 11px;
    color: #666;
    margin-bottom: 4px;
    font-weight: 500;
}

.asset-dimensions {
    font-size: 9px;
    color: #999;
}

/* Asset card wrapper for positioning button */
.asset-card-wrapper {
    display: contents;
}

/* Related images button - circular icon button */
.related-images-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    align-self: center;
    justify-self: center;
    margin: 0;
    padding: 0;
}

.related-images-btn svg {
    flex-shrink: 0;
    transition: transform 0.2s ease;
}

.related-images-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.related-images-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
}

.related-images-btn:hover:not(:disabled) .related-images-tooltip {
    opacity: 1;
}

.related-images-btn:hover:not(:disabled) {
    transform: translateY(-2px) scale(1.05);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.related-images-btn:hover:not(:disabled) svg {
    transform: translateX(2px);
}

.related-images-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    margin-top: 20px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.pagination-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.pagination-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.page-info {
    font-size: 14px;
    color: white;
    font-weight: 500;
}

/* No results */
.no-results {
    text-align: center;
    padding: 80px 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.no-results h3 {
    color: white;
    font-size: 24px;
    margin-bottom: 16px;
}

.no-results p {
    color: rgba(255, 255, 255, 0.8);
    font-size: 16px;
}

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

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 90vw;
    max-height: 90vh;
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
}

.close {
    position: absolute;
    top: 15px;
    right: 20px;
    color: white;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1001;
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.close:hover {
    background: rgba(0, 0, 0, 0.8);
}

#modal-image {
    max-width: 100%;
    max-height: 70vh;
    object-fit: contain;
    background: #f8f9fa;
    position: relative;
}

/* Modal navigation buttons */
.modal-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1002;
    transition: all 0.2s ease;
    color: white;
    padding: 0;
}

.modal-nav-btn:hover {
    background: rgba(0, 0, 0, 0.8);
    border-color: white;
    transform: translateY(-50%) scale(1.1);
}

.modal-nav-btn:active {
    transform: translateY(-50%) scale(0.95);
}

.modal-nav-btn svg {
    width: 24px;
    height: 24px;
    stroke: white;
    stroke-width: 2.5;
}

.modal-nav-prev {
    left: 20px;
}

.modal-nav-next {
    right: 20px;
}

#modal-image.logo-background {
    background-image: 
        linear-gradient(45deg, #b0b0b0 25%, transparent 25%),
        linear-gradient(-45deg, #b0b0b0 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #b0b0b0 75%),
        linear-gradient(-45deg, transparent 75%, #b0b0b0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #ffffff;
}

.image-info {
    padding: 20px;
    background: white;
    border-top: 1px solid #e1e5e9;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
}

.image-details {
    flex: 1;
}

.image-info h3 {
    margin-bottom: 10px;
    color: #333;
    font-size: 20px;
}

.image-info p {
    margin-bottom: 4px;
    color: #666;
    font-size: 14px;
    line-height: 1.4;
}

#download-btn {
    background: #28a745;
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

#download-btn:hover {
    background: #218838;
    box-shadow: 0 8px 20px rgba(40, 167, 69, 0.3);
    transform: translateY(-1px);
}

/* Responsive design */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        align-items: stretch;
    }

    .search-container {
        max-width: none;
    }

    .assets-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
    }

    .main-content {
        padding: 20px;
    }

    .modal-content {
        max-width: 95vw;
        max-height: 95vh;
    }

    .image-info {
        flex-direction: column;
        align-items: stretch;
        gap: 15px;
    }

    #download-btn {
        align-self: center;
        width: 100%;
        max-width: 200px;
    }
}

@media (max-width: 480px) {
    .assets-grid {
        grid-template-columns: 1fr;
    }

    .search-container {
        flex-direction: column;
    }

    .search-container button {
        width: 100%;
    }
}

/* Footer */
.footer {
    background-color: #f8f9fa;
    border-top: 1px solid #e9ecef;
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 20px;
    margin-top: auto;
}

.footer-left {
    flex: 1;
    min-width: 300px;
}

.footer-right {
    flex-shrink: 0;
}

.footer p {
    color: #6c757d;
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
}

.footer-left p {
    font-style: normal;
    text-align: left;
}

.footer-right p {
    font-style: italic;
    text-align: right;
}

@media (max-width: 768px) {
    .footer {
        flex-direction: column;
        text-align: center;
        padding: 20px;
    }
    
    .footer-left {
        min-width: auto;
    }
    
    .footer-left p,
    .footer-right p {
        text-align: center;
    }
}

/* Browse All - Haystack Styles */
.browse-all-btn,
#browse-all-btn,
.search-container .browse-all-btn,
.search-container #browse-all-btn {
    background: linear-gradient(135deg, #7c3aed 0%, #a855f7 50%, #9333ea 100%) !important;
    color: white !important;
    border: none !important;
    padding: 12px 24px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    font-size: 16px !important;
    font-weight: 600 !important;
    transition: all 0.2s !important;
    margin-left: 8px !important;
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4) !important;
    white-space: nowrap !important;
}

.browse-all-sort {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    outline: none;
    margin-left: 12px;
    min-width: 220px;
}

.browse-all-sort:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.browse-all-sort option {
    background: #1a1a2e;
    color: white;
}

.image-type-filter {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 10px 15px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    outline: none;
    margin-left: auto;
    min-width: 200px;
}

.image-type-filter:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.4);
}

.image-type-filter option {
    background: #1a1a2e;
    color: white;
}

.results-info .image-type-filter + .browse-all-sort {
    margin-left: 12px;
}

.browse-all-btn:hover,
#browse-all-btn:hover,
.search-container .browse-all-btn:hover,
.search-container #browse-all-btn:hover {
    transform: translateY(-1px) !important;
    box-shadow: 0 6px 16px rgba(124, 58, 237, 0.5) !important;
    background: linear-gradient(135deg, #6d28d9 0%, #9333ea 50%, #7c3aed 100%) !important;
}

.browse-all-btn:active,
#browse-all-btn:active,
.search-container .browse-all-btn:active,
.search-container #browse-all-btn:active {
    transform: translateY(0) !important;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.4) !important;
}

/* Haystack grid layout */
.assets-grid.haystack-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding: 0 32px;
}

/* Haystack tile */
.haystack-tile {
    background: #060621;
    background-image: radial-gradient(ellipse at 1957px -27px, #0C0E6B 0%, rgba(17, 17, 42, 0) 100%);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.haystack-tile:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

/* Haystack card stack */
.haystack-card-stack {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 aspect ratio */
    background: #1a1a1a;
    overflow: visible; /* Allow stacked cards to be visible */
    margin-bottom: 16px;
    border-radius: 8px;
}

.haystack-card-stack-item {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 85%;
    height: 85%;
    transform: translate(-50%, -50%);
    transform-origin: center center;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    background: #1a1a1a;
    transition: box-shadow 0.2s;
}

.haystack-card-stack-item:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.6);
}

.haystack-poster-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: #1a1a1a;
    overflow: hidden;
}

.haystack-poster-image {
    width: 100%;
    height: 100%;
    object-fit: contain; /* Don't scale/zoom - show full image */
    display: block;
}

.haystack-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10; /* Above stacked cards */
    border-radius: 8px;
    pointer-events: none; /* Allow clicks to pass through overlay to button */
}

.haystack-tile:hover .haystack-overlay {
    opacity: 1;
}

.haystack-overlay .haystack-expand-btn {
    pointer-events: auto; /* Enable clicks on button */
}

.haystack-expand-btn {
    background: rgba(0, 0, 0, 0.8); /* Darker background for better contrast */
    border: 2px solid rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
    position: relative;
    z-index: 11; /* Above overlay */
    min-width: 50px;
    min-height: 50px;
}

.haystack-expand-btn:hover {
    background: rgba(0, 0, 0, 0.6);
    border-color: rgba(255, 255, 255, 0.9);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
}

.haystack-expand-btn .expand-icon {
    color: white;
    font-size: 20px;
    font-weight: bold;
    line-height: 1;
    display: block;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.8);
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.9));
}

.haystack-expand-btn .expand-icon.up {
    font-size: 20px;
}

/* Haystack info */
.haystack-info {
    padding: 16px;
    color: white;
}

.haystack-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: white;
}

.haystack-studio {
    font-size: 13px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 4px;
}

.haystack-ref-id {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 4px;
    font-family: monospace;
}

.haystack-image-type {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.75);
    margin-bottom: 4px;
    font-style: italic;
}

.haystack-count {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
    margin-top: 8px;
}

/* Expanded haystack group (replaces tile in grid) */
.expanded-haystack-group {
    width: 100%;
    grid-column: 1 / -1; /* Span all columns */
    margin-bottom: 24px;
    animation: expandFadeIn 0.3s ease-out;
}

@keyframes expandFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.expanded-haystack-group .group-title-container {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}

.haystack-close-btn {
    background: rgba(255, 255, 255, 0.15);
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    color: white;
    flex-shrink: 0;
    padding: 0;
    margin: 0;
}

.haystack-close-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
    transform: scale(1.1);
}

.haystack-close-btn svg {
    width: 18px;
    height: 18px;
    stroke: white;
    stroke-width: 2.5;
}

.expanded-haystack-group .title-group {
    margin-bottom: 16px;
}

.expanded-haystack-group .group-assets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
}
