/* ===== Gallery App Styles ===== */

.gallery-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 100px 20px 60px;
}

.gallery-hero {
    text-align: center;
    margin-bottom: 40px;
}

.gallery-hero h1 {
    font-size: 2.5rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.gallery-hero p {
    color: var(--text-light);
    font-size: 1.1rem;
}

.gallery-tabs {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 30px;
    flex-wrap: wrap;
}

.gallery-tab {
    padding: 10px 24px;
    border: 2px solid var(--border-color);
    background: white;
    color: var(--text-dark);
    border-radius: 999px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s;
}

.gallery-tab:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.gallery-tab.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.gallery-tab .count {
    background: rgba(255,255,255,0.25);
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 6px;
    font-size: 0.85rem;
}

.gallery-tab:not(.active) .count {
    background: var(--light-bg);
    color: var(--primary-color);
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
}

.gallery-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: transform 0.2s, box-shadow 0.2s;
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
}

.gallery-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--hover-shadow);
}

.gallery-card-cover {
    width: 100%;
    aspect-ratio: 16/10;
    background: linear-gradient(135deg, #fce4ec 0%, #f8bbd9 100%);
    background-size: cover;
    background-position: center;
    position: relative;
}

.gallery-card-cover::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(to bottom, transparent 60%, rgba(0,0,0,0.3));
}

.gallery-card-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    z-index: 1;
    background: white;
    color: var(--text-dark);
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
}

.gallery-card-badge.private {
    background: var(--primary-color);
    color: white;
}

.gallery-card-body {
    padding: 16px 20px 20px;
}

.gallery-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.gallery-card-desc {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-bottom: 10px;
    min-height: 1.2em;
}

.gallery-card-meta {
    color: var(--text-light);
    font-size: 0.85rem;
    display: flex;
    gap: 14px;
}

.gallery-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.gallery-empty h2 {
    color: var(--text-dark);
    margin-bottom: 10px;
}

/* ===== Admin controls ===== */

.admin-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 20px;
    gap: 10px;
}

.btn-primary,
.btn-secondary,
.btn-danger {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-secondary {
    background: white;
    color: var(--text-dark);
    border: 2px solid var(--border-color);
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-primary:hover,
.btn-danger:hover { opacity: 0.9; }
.btn-secondary:hover { border-color: var(--primary-color); color: var(--primary-color); }

.btn-primary:active,
.btn-secondary:active,
.btn-danger:active { transform: translateY(1px); }

/* ===== Gallery View Page ===== */

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.view-header-left { flex: 1; min-width: 250px; }

.view-header h1 {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 4px;
}

.view-header .gallery-type {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    background: var(--light-bg);
    color: var(--primary-color);
    margin-bottom: 8px;
}

.view-header .gallery-type.private {
    background: var(--primary-color);
    color: white;
}

.view-description {
    color: var(--text-light);
    margin-bottom: 8px;
}

.back-link {
    display: inline-block;
    color: var(--primary-color);
    text-decoration: none;
    margin-bottom: 16px;
    font-weight: 500;
}

.back-link:hover { text-decoration: underline; }

.subsection {
    margin-bottom: 40px;
}

.subsection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--border-color);
}

.subsection-title {
    font-size: 1.4rem;
    color: var(--text-dark);
}

.subsection-actions {
    display: flex;
    gap: 8px;
}

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

.image-tile {
    aspect-ratio: 1;
    background: var(--light-bg);
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.15s;
}

.image-tile:hover { transform: scale(1.02); }

.image-tile .tile-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-tile .video-badge {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 2.4rem;
    text-shadow: 0 2px 10px rgba(0,0,0,0.7);
    pointer-events: none;
    z-index: 1;
}

.image-tile-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 10px 8px;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    color: white;
    font-size: 0.8rem;
    line-height: 1.3;
}

.image-tile-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    background: rgba(0,0,0,0.65);
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: none;
    z-index: 2;
}

.image-tile:hover .image-tile-delete { display: block; }

.subsection-empty {
    color: var(--text-light);
    font-style: italic;
    padding: 20px;
    background: var(--light-bg);
    border-radius: 8px;
    text-align: center;
}

/* ===== Lightbox ===== */

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.92);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.lightbox.open { display: flex; }

.lightbox img,
.lightbox video {
    max-width: 100%;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.5);
}

.lightbox-close,
.lightbox-prev,
.lightbox-next {
    position: absolute;
    background: rgba(255,255,255,0.1);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.6rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}

.lightbox-close:hover,
.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255,255,255,0.25);
}

.lightbox-close { top: 20px; right: 20px; }
.lightbox-prev { left: 20px; top: 50%; transform: translateY(-50%); }
.lightbox-next { right: 20px; top: 50%; transform: translateY(-50%); }

.lightbox-caption-wrap {
    position: absolute;
    bottom: 20px;
    left: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.lightbox-caption {
    color: white;
    text-align: center;
    font-size: 0.95rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

.lightbox-caption-btn {
    background: rgba(255,255,255,0.12);
    color: white;
    border: 1px solid rgba(255,255,255,0.25);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: background 0.15s;
}

.lightbox-caption-btn:hover { background: rgba(255,255,255,0.25); }

.lightbox-caption-editor {
    display: flex;
    gap: 8px;
    align-items: center;
    width: min(560px, 100%);
    background: rgba(0,0,0,0.55);
    padding: 10px;
    border-radius: 10px;
}

.lightbox-caption-editor input {
    flex: 1;
    padding: 9px 12px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.95);
    font-size: 0.9rem;
}

.lightbox-caption-editor .btn-primary,
.lightbox-caption-editor .btn-secondary {
    padding: 8px 14px;
    font-size: 0.85rem;
    white-space: nowrap;
}

/* ===== Modal ===== */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
    background: white;
    border-radius: 12px;
    max-width: 560px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 28px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.modal h2 {
    color: var(--primary-color);
    margin-bottom: 18px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-dark);
}

.form-group input[type="text"],
.form-group input[type="email"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
}

.form-group textarea { min-height: 80px; resize: vertical; }

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.radio-row {
    display: flex;
    gap: 16px;
    margin-top: 6px;
}

.radio-row label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
    cursor: pointer;
}

/* Allowlist picker */
.user-picker {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    max-height: 250px;
    overflow-y: auto;
}

.user-picker-search {
    width: 100%;
    padding: 8px 12px;
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: var(--light-bg);
    font-size: 0.9rem;
}

.user-picker-search:focus { outline: none; }

.user-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f1f5f9;
}

.user-row:last-child { border-bottom: none; }
.user-row:hover { background: var(--light-bg); }

.user-row input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

.user-row-info { flex: 1; min-width: 0; }
.user-row-name { font-weight: 500; color: var(--text-dark); font-size: 0.95rem; }
.user-row-email { color: var(--text-light); font-size: 0.8rem; }

.subsection-list {
    border: 2px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.subsection-row {
    display: flex;
    gap: 8px;
    padding: 8px 10px;
    border-bottom: 1px solid #f1f5f9;
    align-items: center;
}

.subsection-row:last-child { border-bottom: none; }

.subsection-row input[type="text"] {
    flex: 1;
    border: 1px solid var(--border-color);
    padding: 6px 10px;
    border-radius: 6px;
}

.subsection-row .btn-remove {
    background: transparent;
    color: #ef4444;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    padding: 4px 8px;
}

.add-subsection {
    background: var(--light-bg);
    border: none;
    width: 100%;
    padding: 10px;
    cursor: pointer;
    color: var(--primary-color);
    font-weight: 500;
}

.add-subsection:hover { background: var(--border-color); }

/* Upload progress */
.upload-progress {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: white;
    color: var(--text-dark);
    padding: 14px 20px;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.18);
    z-index: 10001;
    min-width: 280px;
    border: 2px solid var(--primary-color);
}

.upload-progress-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    font-size: 0.95rem;
    font-weight: 500;
}

.upload-progress-row .spinner-small {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    flex-shrink: 0;
}

.upload-progress-bar {
    height: 6px;
    background: var(--light-bg);
    border-radius: 999px;
    overflow: hidden;
}

.upload-progress-fill {
    height: 100%;
    background: var(--primary-color);
    transition: width 0.2s;
}

.upload-progress-detail {
    margin-top: 6px;
    font-size: 0.8rem;
    color: var(--text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-dark);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
    z-index: 10000;
    font-size: 0.95rem;
    animation: toast-in 0.2s ease-out;
}

.toast.error { background: #ef4444; }
.toast.success { background: #10b981; }

@keyframes toast-in {
    from { transform: translate(-50%, 20px); opacity: 0; }
    to { transform: translate(-50%, 0); opacity: 1; }
}

/* Auth states */
.auth-message {
    text-align: center;
    padding: 60px 20px;
}

.auth-message h2 {
    color: var(--primary-color);
    margin-bottom: 12px;
}

.auth-message p { color: var(--text-light); margin-bottom: 6px; }

.loading-state {
    text-align: center;
    padding: 80px 20px;
}

.spinner-large {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    margin: 0 auto 16px;
    animation: spin 0.8s linear infinite;
}

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

@media (max-width: 600px) {
    .gallery-hero h1 { font-size: 2rem; }
    .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
    .image-grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
    .modal { padding: 20px; }
}
