/* Modules - Component Styles */

/* Gallery - Base grid fallback */
.gallery {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 1rem;
}

@media (max-width: 1200px) {
    .gallery:not(.masonry-active) { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 900px) {
    .gallery:not(.masonry-active) { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 600px) {
    .gallery:not(.masonry-active) { grid-template-columns: repeat(2, 1fr); }
}

/* Album grid fallback - more columns, 3 on mobile */
.album-grid:not(.masonry-active) { grid-template-columns: repeat(8, 1fr); }

@media (max-width: 1200px) {
    .album-grid:not(.masonry-active) { grid-template-columns: repeat(7, 1fr); }
}

@media (max-width: 900px) {
    .album-grid:not(.masonry-active) { grid-template-columns: repeat(6, 1fr); }
}

@media (max-width: 600px) {
    .album-grid:not(.masonry-active) { grid-template-columns: repeat(3, 1fr); }
}

/* CSS Grid masonry fallback (Safari) */
@supports (grid-template-rows: masonry) {
    .gallery {
        grid-template-rows: masonry;
    }
    .gallery-item {
        aspect-ratio: auto;
    }
}

/* JS masonry active */
.gallery.masonry-active {
    display: block;
    position: relative;
}

.gallery.masonry-active .gallery-item {
    position: absolute;
    aspect-ratio: auto;
    contain: layout style;
    will-change: transform;
}

.gallery-item {
    display: block;
    position: relative;
    background: var(--bg-tertiary);
    border-radius: 4px;
    aspect-ratio: var(--aspect-ratio, 1);
}

.gallery-item:focus-within {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

.gallery-item-placeholder {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    filter: blur(20px);
    transform: scale(1.1);
    transition: opacity 0.3s ease;
}

.gallery-item.is-loaded .gallery-item-placeholder {
    opacity: 0;
}

.gallery-item-img {
    position: relative;
    width: 100%;
    height: auto;
    display: block;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item.is-loaded .gallery-item-img {
    opacity: 1;
}

.gallery-item-link {
    display: block;
    position: relative;
    width: 100%;
    height: 100%;
    overflow: hidden;
    border-radius: 4px;
}

.gallery-item-link:focus-visible {
    outline: none;
}

.gallery-item-pinned {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10;
    color: #fff;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.6));
}

.gallery-item-actions {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem;
    opacity: 0;
    transition: opacity 0.15s ease;
    z-index: 10;
}

.gallery-item:hover .gallery-item-actions,
.gallery-item:focus-within .gallery-item-actions {
    opacity: 1;
}

.gallery-item-actions .btn {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
    border: none;
}

.gallery-item-actions .btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.gallery-item-actions .btn-danger:hover {
    background: var(--danger);
}

.gallery-item-actions .btn-pinned {
    background: var(--accent);
}

.gallery-item-actions form {
    display: contents;
}

.gallery-empty {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    color: var(--text-muted);
    padding: 2rem;
}

.gallery-empty span {
    color: var(--text-primary);
}

.gallery-loader {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.gallery-loader-text {
    display: inline-block;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.gallery-loader.is-loading .gallery-loader-text {
    opacity: 1;
}

/* Album Grid */
.album-card {
    text-decoration: none;
    display: block;
}

.album-card-img {
    border-radius: 4px;
}

.album-card-placeholder {
    width: 100%;
    aspect-ratio: 3/4;
    background: var(--bg-tertiary);
    border-radius: 4px;
}

.album-card-title {
    display: block;
    padding: 0.5rem;
    font-weight: bold;
    text-align: center;
}

/* Photo Detail */
.photo {
    display: flex;
    flex-direction: column;
}

.photo-image-container {
    position: relative;
    background: #000;
    min-height: 50vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.photo-blur {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    filter: blur(30px);
    opacity: 0.5;
}

.photo-img {
    position: relative;
    max-height: 85vh;
    width: auto;
    max-width: 100%;
}

.photo-info {
    padding: 2rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

.photo-title {
    margin-bottom: 0.5rem;
}

.photo-description {
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.photo-credit {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.photo-credit a {
    color: var(--text-secondary);
}

.photo-exif {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem 2rem;
    margin-bottom: 2rem;
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.photo-exif-item {
    display: flex;
    flex-direction: column;
}

.photo-exif-item dt {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.photo-exif-item dd {
    font-weight: 500;
}

.photo-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 2rem;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    position: sticky;
    bottom: 0;
    z-index: 100;
}

.photo-nav-link {
    padding: 0.5rem 0;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.kbd {
    display: inline-block;
    padding: 0.125em 0.5em;
    font-family: monospace;
    font-size: 0.7em;
    font-weight: 400;
    line-height: 1.4;
    color: var(--text-primary);
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 0.25em;
    box-shadow: 0 1px 0 var(--border-color);
    white-space: nowrap;
    vertical-align: middle;
}

@media (max-width: 768px) {
    .kbd {
        display: none;
    }
}

.photo-nav-prev,
.photo-nav-next {
    flex: 0 0 auto;
    min-width: 2.75rem;
}

.photo-nav-prev {
    justify-content: flex-start;
}

.photo-nav-next {
    justify-content: flex-end;
}

.photo-nav-back {
    flex: 1;
    justify-content: center;
    text-align: center;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.photo-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 1rem;
    margin-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.photo-actions form {
    display: contents;
}

.photo-actions .btn-icon {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Login */
.login {
    padding: 2rem 0;
}

.login-title {
    margin-bottom: 2rem;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Admin */
.admin {
    padding: 1rem 0;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.admin-filters {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.admin-filter {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-primary);
    color: var(--text-primary);
    cursor: pointer;
}

.admin-filter:hover {
    border-color: var(--text-muted);
}

.admin-search {
    min-width: 150px;
}

.admin-search:focus {
    outline: none;
    border-color: var(--accent);
}

/* Admin Nav */
.admin-nav {
    display: flex;
    gap: 0;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.admin-nav-item {
    padding: 0.75rem 1.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color 0.15s ease, border-color 0.15s ease;
}

.admin-nav-item:hover {
    color: var(--text-primary);
}

.admin-nav-item.is-active {
    color: var(--text-primary);
    border-bottom-color: var(--accent);
}

/* Admin Grid */
.admin-grid {
    column-count: 4;
    column-gap: 1rem;
    margin-bottom: 2rem;
}

@media (max-width: 1200px) {
    .admin-grid { column-count: 3; }
}

@media (max-width: 900px) {
    .admin-grid { column-count: 2; }
}

.admin-card {
    break-inside: avoid;
    margin-bottom: 1rem;
    position: relative;
    border-radius: 4px;
    overflow: hidden;
}


.admin-card-thumb {
    display: block;
    background: var(--bg-tertiary);
    overflow: hidden;
}

.admin-card-thumb img {
    width: 100%;
    height: auto;
    display: block;
}

.admin-card-processing {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.admin-card-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem 0.75rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    opacity: 0;
    transition: opacity 0.15s ease;
}

.admin-card:hover .admin-card-info,
.admin-card:focus-within .admin-card-info {
    opacity: 1;
}

.admin-card-info strong {
    display: block;
    font-size: 0.75rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-card-actions {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: flex;
    gap: 0.25rem;
    padding: 0.5rem;
    align-items: center;
    background: linear-gradient(rgba(0, 0, 0, 0.5), transparent);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.admin-card:hover .admin-card-actions,
.admin-card:focus-within .admin-card-actions {
    opacity: 1;
}

.admin-card-actions form {
    display: contents;
}

.admin-card-actions .btn {
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
    border: none;
}

.admin-card-actions .btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.admin-card-actions .btn-danger:hover {
    background: var(--danger);
}

.admin-card-actions .btn-pinned {
    background: var(--accent);
}


.admin-card-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    font-size: 0.875rem;
    min-height: 14rem;
}

.admin-card-info small {
    display: block;
    color: var(--text-muted);
    font-size: 0.75rem;
}

.admin-header-actions {
    display: flex;
    gap: 0.5rem;
}

/* Admin Album Cards */
.admin-albums {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
}

.admin-album-card {
    position: relative;
    width: 240px;
    border-radius: 8px;
    overflow: hidden;
    cursor: grab;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.admin-album-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.admin-album-card.is-dragging {
    opacity: 0.5;
    cursor: grabbing;
}

.admin-album-thumb {
    display: block;
}

.admin-album-thumb img {
    width: 100%;
    height: auto;
    display: block;
}

.admin-album-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 3/4;
    background: var(--bg-tertiary);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.admin-album-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.5rem;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    opacity: 0;
    transition: opacity 0.15s ease;
}

.admin-album-card:hover .admin-album-info,
.admin-album-card:focus-within .admin-album-info {
    opacity: 1;
}

.admin-album-info strong {
    display: block;
    font-size: 0.8rem;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-album-info small {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.8);
}

.admin-album-actions {
    position: absolute;
    top: 0;
    left: 0;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.admin-album-card:hover .admin-album-actions,
.admin-album-card:focus-within .admin-album-actions {
    opacity: 1;
}

.admin-album-actions .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.7rem;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
}

.admin-album-actions .btn:hover {
    background: rgba(0, 0, 0, 0.8);
}

.admin-album-actions .btn-danger:hover {
    background: var(--danger);
}

.admin-album-actions form {
    display: contents;
}

/* Cover Picker */
.cover-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.cover-option {
    position: relative;
    width: 60px;
    height: 60px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.15s;
}

.cover-option input {
    position: absolute;
    opacity: 0;
}

.cover-option img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cover-option-auto {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
    font-size: 0.75rem;
    color: var(--text-muted);
}

.cover-option.is-selected {
    border-color: var(--accent);
}

.cover-option.is-selected::after {
    content: '\2713';
    position: absolute;
    top: 2px;
    right: 2px;
    width: 16px;
    height: 16px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
}

/* Album Image Picker */
.album-image-picker {
    column-count: 6;
    column-gap: 0.5rem;
    padding: 0.5rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
}

@media (max-width: 1200px) {
    .album-image-picker { column-count: 5; }
}

@media (max-width: 900px) {
    .album-image-picker { column-count: 4; }
}

@media (max-width: 600px) {
    .album-image-picker { column-count: 3; }
}

.album-image-option {
    position: relative;
    display: block;
    break-inside: avoid;
    margin-bottom: 0.5rem;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    transition: border-color 0.15s;
}

.album-image-option img {
    display: block;
    width: 100%;
    height: auto;
}

.album-image-option input {
    position: absolute;
    opacity: 0;
}

.album-image-option.is-selected {
    border-color: var(--accent);
}

.album-image-option.is-selected::after {
    content: '\2713';
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    background: var(--accent);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

.admin-empty {
    text-align: center;
    color: var(--text-secondary);
    padding: 4rem 2rem;
}

/* Upload / Edit */
.upload,
.edit {
    padding: 2rem 0;
}

.upload-title,
.edit-title {
    margin-bottom: 2rem;
}

.upload-form,
.edit-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.edit-preview {
    margin-bottom: 2rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    overflow: hidden;
}

.edit-preview img {
    max-height: 400px;
    margin: 0 auto;
}

.edit-preview-processing {
    padding: 4rem;
    text-align: center;
    color: var(--text-secondary);
}

.edit-exif {
    padding: 1rem;
    background: var(--bg-secondary);
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

.edit-exif h3 {
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

.edit-exif dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.25rem 1rem;
    font-size: 0.875rem;
}

.edit-exif dt {
    color: var(--text-secondary);
}

/* Forms */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
}

.form-input,
.form-textarea {
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.form-input:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-input::placeholder,
.form-textarea::placeholder {
    color: var(--text-muted);
}

.form-help {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.form-actions {
    display: flex;
    gap: 1rem;
    padding-top: 1rem;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.875rem;
}

.checkbox-label:hover {
    background: var(--bg-elevated);
}

.checkbox-label input[type="checkbox"] {
    accent-color: var(--accent);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: var(--danger-hover);
}

.btn-pinned {
    background: var(--accent);
    color: #fff;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
}

.btn-small {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

/* Alerts */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.alert ul {
    margin-left: 1rem;
    list-style: disc;
}

/* About Page */
.about-page {
    max-width: 700px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.about-content {
    line-height: 1.8;
}

.about-content h1,
.about-content h2,
.about-content h3 {
    margin-top: 2rem;
    margin-bottom: 1rem;
}

.about-content p {
    margin-bottom: 1rem;
}

.about-content a {
    color: var(--accent);
}

.about-empty {
    text-align: center;
    color: var(--text-muted);
}

/* Textarea */
.form-textarea {
    width: 100%;
    padding: 0.75rem;
    font-family: monospace;
    font-size: 0.875rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    resize: vertical;
}

.form-textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.form-help {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

/* Bulk Actions */
.bulk-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

.bulk-select-all {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
}

.bulk-count {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.bulk-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-left: auto;
}

.bulk-form select {
    padding: 0.375rem 0.75rem;
    background: var(--bg-primary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.875rem;
}

/* Card Checkbox */
.admin-card-checkbox {
    position: absolute;
    top: 0.5rem;
    left: 0.5rem;
    z-index: 10;
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease;
}

.admin-card:hover .admin-card-checkbox,
.admin-card:focus-within .admin-card-checkbox,
.admin-card-checkbox:has(input:checked) {
    opacity: 1;
}

.admin-card-checkbox input {
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.admin-card {
    position: relative;
}
