/* ============================================
   FOTOS PAGE STYLES
   ============================================ */

/* Header */
.photo-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: rgba(253, 252, 250, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--color-border);
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: var(--color-text-light);
    transition: color 0.3s ease;
}

.back-link:hover {
    color: var(--color-accent-dark);
}

.header-title {
    text-align: center;
    flex: 1;
}

.header-title h1 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 300;
    font-style: italic;
    color: var(--color-text);
    margin: 0;
}

.header-subtitle {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    letter-spacing: 0.1em;
    margin-top: 0.25rem;
}

/* Upload Section – card design below fixed header */
.upload-section {
    padding: calc(90px + 2rem) var(--space-md) 2rem;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.upload-card {
    background: #ffffff;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: var(--space-md);
    max-width: 650px;
    margin: 0 auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.02);
    text-align: center;
    transition: all 0.3s ease;
}

.upload-card-header {
    margin-bottom: var(--space-md);
}

.upload-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background: var(--color-blue-bg);
    color: var(--color-accent);
    border-radius: 50%;
    margin-bottom: var(--space-xs);
}

.upload-card-header h2 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-weight: 300;
    color: var(--color-text);
    margin: 0.5rem 0 0.25rem;
}

.upload-card-subtitle {
    font-size: 0.88rem;
    color: var(--color-text-muted);
}

/* Upload Dropzone */
.upload-dropzone {
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: var(--space-md);
    background: #fafaf9;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.upload-dropzone:hover {
    border-color: var(--color-accent);
    background: rgba(138, 149, 114, 0.02);
}

.dropzone-prompt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-xs);
}

.dropzone-limit-hint {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    max-width: 450px;
    line-height: 1.4;
}

.btn-pick {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.6rem 1.4rem;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.2s ease;
}

.btn-pick:hover {
    background: var(--color-accent-dark);
}

.btn-pick-more {
    font-size: 0.82rem;
    padding: 0.5rem 1.25rem;
    margin-top: 1rem;
}

/* Expanded area shown after files are picked */
.upload-expanded {
    max-width: 650px;
    margin: 0.5rem auto 0;
    text-align: left;
}

.preview-header {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--color-text-light);
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 0.5rem;
}

.preview-grid-wrapper {
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: var(--space-xs);
    background: #fafaf9;
    margin-bottom: var(--space-sm);
}

.upload-form-inline {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

.btn-cancel-upload {
    background: transparent;
    border: none;
    font-family: var(--font-body);
    font-size: 0.85rem;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    transition: all 0.2s ease;
}

.btn-cancel-upload:hover {
    color: var(--color-text);
    background: rgba(0, 0, 0, 0.03);
}

/* Success state */
.upload-success {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-sm) 0;
}

.success-icon-wrapper {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: rgba(138, 149, 114, 0.1);
    color: var(--color-accent);
    border-radius: 50%;
    margin-bottom: var(--space-sm);
}

.upload-success h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 300;
    margin-bottom: var(--space-xs);
    color: var(--color-text);
}

.success-hint {
    font-size: 0.88rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-xs);
}

/* Scroll down hint */
.gallery-scroll-hint {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    margin-top: 1.5rem;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: color 0.3s ease;
}

.gallery-scroll-hint:hover {
    color: var(--color-accent-dark);
}

.gallery-scroll-hint svg {
    color: var(--color-accent);
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(6px);
    }
    60% {
        transform: translateY(3px);
    }
}



/* Preview Grid */
.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 0.75rem;
    margin-bottom: var(--space-md);
}

.preview-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 6px;
    overflow: hidden;
}

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

.preview-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.85; /* Always visible on touch screens */
    transition: background 0.2s ease;
}

@media (hover: hover) {
    .preview-remove {
        opacity: 0;
    }
    .preview-item:hover .preview-remove {
        opacity: 0.85;
    }
}

.preview-item:hover .preview-remove {
    opacity: 0.85;
}

/* Upload Button (compact, inside inline form) */
.btn-upload {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 1.4rem;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.btn-upload:hover:not(:disabled) {
    background: var(--color-accent-dark);
}

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

.btn-upload.loading .btn-text {
    display: none;
}

.btn-upload .btn-loading {
    display: none;
}

.btn-upload.loading .btn-loading {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Spinner */
.spinner {
    width: 18px;
    height: 18px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Gallery Section */
.gallery-section {
    padding: var(--space-md) var(--space-md) var(--space-xl);
    background: var(--color-bg-alt);
    min-height: 60vh;
}

.gallery-section .container {
    max-width: 1200px;
}

/* Compact title/intro for fotos page gallery */
.gallery-section .section-title {
    font-size: 1.3rem;
    margin-bottom: 0.25rem;
}

.gallery-intro {
    text-align: center;
    color: var(--color-text-light);
    font-size: 0.85rem;
    margin-top: 0;
    margin-bottom: var(--space-md);
}

.gallery-loading,
.gallery-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: var(--space-xl);
    color: var(--color-text-muted);
}

.gallery-empty svg {
    opacity: 0.3;
}

.gallery-empty h3 {
    font-family: var(--font-display);
    font-size: 1.5rem;
    font-weight: 300;
    font-style: italic;
    color: var(--color-text-light);
    margin: 0;
}

/* Toolbar */
.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-sm);
    justify-content: space-between;
    padding: 0.75rem var(--space-sm);
    margin-bottom: var(--space-md);
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 10px;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

#photo-count {
    font-size: 0.9rem;
    color: var(--color-text-light);
}

.text-btn {
    border: none;
    background: transparent;
    color: var(--color-accent-dark);
    font-family: var(--font-body);
    font-size: 0.82rem;
    cursor: pointer;
    padding: 0.4rem 0.5rem;
    border-radius: 6px;
    transition: background 0.2s ease;
}

.text-btn:hover {
    background: rgba(138, 149, 114, 0.12);
}

/* Gallery Grid */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-sm);
}

.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    background: var(--color-bg);
    transition: box-shadow 0.3s ease;
}

.gallery-item:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: transform 0.5s ease;
}

.gallery-item:hover img {
    transform: scale(1.05);
}

.gallery-item.selected {
    outline: 3px solid var(--color-accent);
    outline-offset: -3px;
}

/* Video thumbnail overlay */
.gallery-item-video-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 44px;
    height: 44px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(4px);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    pointer-events: none;
    transition: all 0.3s ease;
    border: 1.5px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

.gallery-item:hover .gallery-item-video-overlay {
    background: rgba(0, 0, 0, 0.6);
    transform: translate(-50%, -50%) scale(1.1);
}

.gallery-item-video-overlay svg {
    margin-left: 2px; /* Visual centering of play triangle */
}

/* Per-tile action buttons */
.g-select,
.g-download {
    position: absolute;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.g-select svg,
.g-download svg {
    width: 18px;
    height: 18px;
}

.g-select {
    top: 8px;
    left: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: transparent;
    border: 2px solid rgba(255, 255, 255, 0.95);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.g-select:hover {
    background: white;
}

.gallery-item.selected .g-select {
    background: var(--color-accent);
    border-color: var(--color-accent);
    color: white;
}

.g-download {
    top: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.45);
    color: white;
    opacity: 0;
}

.gallery-item:hover .g-download {
    opacity: 1;
}

.g-download:hover {
    background: var(--color-accent-dark);
}

/* Sticky selection bar */
.selection-bar {
    position: fixed;
    left: 50%;
    bottom: -100px;
    transform: translateX(-50%);
    z-index: 90;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 0.75rem 1.25rem;
    background: var(--color-text);
    color: white;
    border-radius: 999px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    transition: bottom 0.35s var(--ease);
    max-width: calc(100vw - 2rem);
}

.selection-bar.visible {
    bottom: var(--space-md);
}

#selection-count {
    font-size: 0.9rem;
    white-space: nowrap;
}

.btn-download-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1.2rem;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: 999px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.25s ease;
    white-space: nowrap;
}

.btn-download-primary:hover:not(:disabled) {
    background: var(--color-accent-dark);
}

.btn-download-primary:disabled {
    opacity: 0.85;
    cursor: progress;
}

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

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: white;
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.8s linear infinite;
}

/* Size choice dialog */
.size-dialog-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    padding: var(--space-md);
}

.size-dialog-backdrop.visible {
    display: flex;
}

.size-dialog {
    position: relative;
    width: 100%;
    max-width: 380px;
    background: var(--color-bg);
    border-radius: 16px;
    padding: var(--space-md);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: dialog-in 0.25s var(--ease);
}

@keyframes dialog-in {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.size-dialog-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
}

.size-dialog-close:hover {
    background: var(--color-bg-alt);
}

.size-dialog h3 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    font-style: italic;
    font-weight: 300;
    margin-bottom: 0.25rem;
    padding-right: 2rem;
}

.size-dialog-sub {
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: var(--space-sm);
}

.size-choice {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.9rem 1rem;
    margin-bottom: 0.6rem;
    border: 1.5px solid var(--color-border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.2s ease, background 0.2s ease;
}

.size-choice:hover {
    border-color: var(--color-accent-light);
}

.size-choice input {
    margin-top: 0.2rem;
    width: 18px;
    height: 18px;
    accent-color: var(--color-accent);
    flex-shrink: 0;
}

.size-choice:has(input:checked) {
    border-color: var(--color-accent);
    background: rgba(138, 149, 114, 0.07);
}

.size-choice-text {
    display: flex;
    flex-direction: column;
}

.size-choice-main {
    font-size: 0.95rem;
    color: var(--color-text);
}

.size-choice-hint {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    line-height: 1.4;
}

.size-dialog-confirm {
    width: 100%;
    margin-top: var(--space-xs);
    padding: 0.8rem;
    font-size: 0.9rem;
    border-radius: 10px;
}

body.has-selection-bar {
    padding-bottom: 5rem;
}

/* Uploader name overlay */
.gallery-item-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.5), transparent);
    color: white;
    font-size: 0.72rem;
    padding: 1.5rem 0.5rem 0.4rem;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gallery-item:hover .gallery-item-info {
    opacity: 1;
}

/* Lightbox */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.95);
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-close {
    position: absolute;
    top: var(--space-md);
    right: var(--space-md);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.lightbox-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s ease;
}

.lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.2);
}

.lightbox-prev {
    left: var(--space-md);
}

.lightbox-next {
    right: var(--space-md);
}

.lightbox-content {
    max-width: 90vw;
    max-height: 75vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 75vh;
    object-fit: contain;
    border-radius: 4px;
}

.lightbox-footer {
    position: absolute;
    bottom: var(--space-md);
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    color: white;
}

.lightbox-filename {
    font-size: 0.85rem;
    opacity: 0.7;
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-download {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: 6px;
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-download:hover {
    background: var(--color-accent-dark);
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 768px) {
    .photo-header {
        padding: var(--space-sm);
    }

    .header-title h1 {
        font-size: 1.25rem;
    }

    .upload-section {
        padding: calc(90px + 0.75rem) var(--space-sm) 0.75rem;
    }

    .upload-strip {
        gap: 0.5rem;
    }

    .upload-strip-label {
        font-size: 0.82rem;
    }

    .upload-hint {
        font-size: 0.76rem;
    }

    .toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-group {
        justify-content: space-between;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-xs);
    }

    /* Always show per-photo download button on touch devices */
    .g-download { opacity: 1; }

    .lightbox-nav {
        width: 40px;
        height: 40px;
    }

    .lightbox-prev {
        left: var(--space-xs);
    }

    .lightbox-next {
        right: var(--space-xs);
    }

    .lightbox-footer {
        flex-direction: column;
        gap: var(--space-sm);
    }
}

@media (max-width: 480px) {
    .preview-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}