
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #1a1a1a;
    color: #fff;
    min-height: 100vh;
}

.header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 20px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.search-container {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 10px;
}

.search-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #3a3a5c;
    border-radius: 8px;
    background: #252540;
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: border-color 0.3s;
}

.search-input:focus {
    border-color: #00d9ff;
}

.search-input::placeholder {
    color: #888;
}

.page-count-select {
    padding: 12px 16px;
    border: 2px solid #3a3a5c;
    border-radius: 8px;
    background: #252540;
    color: #fff;
    font-size: 16px;
    outline: none;
    cursor: pointer;
    transition: border-color 0.3s;
    min-width: 140px;
}

.page-count-select:hover {
    border-color: #00d9ff;
}

.page-count-select:focus {
    border-color: #00d9ff;
}

.search-btn {
    padding: 12px 24px;
    background: linear-gradient(135deg, #00d9ff 0%, #00a8cc 100%);
    border: none;
    border-radius: 8px;
    color: #000;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.search-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 217, 255, 0.4);
}

.search-btn:active {
    transform: translateY(0);
}

.browse-btn {
    background: linear-gradient(135deg, #ff6b6b 0%, #cc5555 100%);
}

.browse-btn:hover {
    box-shadow: 0 4px 15px rgba(255, 107, 107, 0.4);
}

.gallery-title {
    text-align: center;
    padding: 20px;
    font-size: 24px;
    color: #00d9ff;
}

.gallery-title.hidden {
    display: none;
}

.gallery-info {
    text-align: center;
    padding: 10px 20px;
    color: #888;
    font-size: 14px;
}

.gallery-info.hidden {
    display: none;
}

.gallery-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.tiles-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
}

.tile {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    background: #252540;
    transition: transform 0.3s, box-shadow 0.3s;
}

.tile:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
}

.tile img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.tile:hover img {
    transform: scale(1.1);
}

.tile-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 40px 12px 12px;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    opacity: 0;
    transition: opacity 0.3s;
}

.tile:hover .tile-overlay {
    opacity: 1;
}

.tile-title {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.loading {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid #3a3a5c;
    border-top-color: #00d9ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.error {
    text-align: center;
    padding: 60px 20px;
    color: #ff6b6b;
}

.view-toggle {
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 10px;
}

.view-btn {
    padding: 8px 16px;
    background: #252540;
    border: 2px solid #3a3a5c;
    border-radius: 6px;
    color: #888;
    cursor: pointer;
    transition: all 0.2s;
}

.view-btn.active {
    background: #00d9ff;
    border-color: #00d9ff;
    color: #000;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 1000;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    padding: 20px;
}

.lightbox.active {
    display: flex;
}

.lightbox-image-container {
    position: relative;
    width: 90vw;
    height: 80vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    cursor: grab;
}

.lightbox-image-container.dragging {
    cursor: grabbing;
}

.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5);
    transition: transform 0.1s ease-out;
    transform-origin: center center;
}

.lightbox-image.zoomed {
    cursor: grab;
}

.lightbox-controls {
    position: absolute;
    bottom: 60px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.lightbox-control-btn {
    padding: 8px 12px;
    background: rgba(37, 37, 64, 0.9);
    border: 1px solid #3a3a5c;
    border-radius: 6px;
    color: #fff;
    font-size: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.lightbox-control-btn:hover {
    background: #00d9ff;
    color: #000;
}

.lightbox-control-btn.active {
    background: #00d9ff;
    color: #000;
}

.lightbox-zoom-indicator {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(37, 37, 64, 0.9);
    border-radius: 20px;
    color: #00d9ff;
    font-size: 14px;
    font-weight: 600;
    z-index: 10;
}

.lightbox-hint {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: rgba(37, 37, 64, 0.8);
    border-radius: 4px;
    color: #888;
    font-size: 11px;
    z-index: 10;
    white-space: nowrap;
}

.lightbox-title {
    margin-top: 80px;
    font-size: 18px;
    color: #fff;
    text-align: center;
    padding: 0 20px;
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: #252540;
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transition: background 0.2s;
}

.lightbox-close:hover {
    background: #00d9ff;
    color: #000;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: #252540;
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transition: background 0.2s;
}

.lightbox-nav:hover {
    background: #00d9ff;
    color: #000;
}

.lightbox-nav.prev {
    left: 20px;
}

.lightbox-nav.next {
    right: 20px;
}

.lightbox-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    color: #888;
    font-size: 14px;
}

/* Fullscreen View */
.fullscreen-view {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #000;
    z-index: 1001;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.fullscreen-view.active {
    display: flex;
}

.fullscreen-image-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    cursor: grab;
}

.fullscreen-image-container.dragging {
    cursor: grabbing;
}

.fullscreen-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.1s ease-out;
    transform-origin: center center;
}

.fullscreen-image.zoomed {
    cursor: grab;
}

.fullscreen-controls {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 10px;
    z-index: 10;
}

.fullscreen-zoom-indicator {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(37, 37, 64, 0.9);
    border-radius: 20px;
    color: #00d9ff;
    font-size: 14px;
    font-weight: 600;
    z-index: 10;
}

.fullscreen-hint {
    position: absolute;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 12px;
    background: rgba(37, 37, 64, 0.8);
    border-radius: 4px;
    color: #888;
    font-size: 11px;
    z-index: 10;
    white-space: nowrap;
}

.fullscreen-counter {
    position: absolute;
    bottom: 70px;
    left: 50%;
    transform: translateX(-50%);
    color: #888;
    font-size: 14px;
}

.fullscreen-title {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 8px 16px;
    background: rgba(37, 37, 64, 0.9);
    border-radius: 20px;
    color: #fff;
    font-size: 14px;
    max-width: 80%;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    z-index: 10;
}

.fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(37, 37, 64, 0.9);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 10;
}

.fullscreen-close:hover {
    background: #00d9ff;
    color: #000;
}

.fullscreen-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(37, 37, 64, 0.9);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 10;
}

.fullscreen-nav:hover {
    background: #00d9ff;
    color: #000;
}

.fullscreen-nav.prev {
    left: 20px;
}

.fullscreen-nav.next {
    right: 20px;
}

/* Grid view options */
.tiles-grid.small .tile {
    aspect-ratio: 1;
}

.tiles-grid.medium .tile {
    aspect-ratio: 4/3;
}

.tiles-grid.large .tile {
    aspect-ratio: 16/9;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #888;
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 20px;
}

/* Local file placeholder */
.tile-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, #252540 0%, #1a1a2e 100%);
    color: #00d9ff;
}

.tile-placeholder-icon {
    font-size: 48px;
    margin-bottom: 8px;
}

.tile-placeholder-text {
    font-size: 12px;
    color: #888;
    text-align: center;
    padding: 0 10px;
    word-break: break-all;
}

/* Loading indicator for lazy images */
.tile-loading {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #252540;
}

.tile-loading::after {
    content: '';
    width: 24px;
    height: 24px;
    border: 2px solid #3a3a5c;
    border-top-color: #00d9ff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}
