/* === Theme Variables - Single Source === */
:root {
    --bg-primary: #ffffff;
    --bg-secondary: #fafafa;
    --bg-tertiary: #f3f4f6;
    --text-primary: #1f2937;
    --text-secondary: #4b5563;
    --text-muted: #9ca3af;
    --border-color: #e5e7eb;
    --accent-color: #3b82f6;
    --gallery-text-bg: #fafafa;
    --gallery-text-color: #1f2937;
}

[data-theme="dark"] {
    --bg-primary: #111827;
    --bg-secondary: #1f2937;
    --bg-tertiary: #374151;
    --text-primary: #f9fafb;
    --text-secondary: #d1d5db;
    --text-muted: #6b7280;
    --border-color: #374151;
    --accent-color: #60a5fa;
    --gallery-text-bg: #1f2937;
    --gallery-text-color: #f9fafb;
}

/* === Base === */
body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: system-ui, -apple-system, sans-serif;
}

/* === Photo Grid === */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 4px;
}

.photo-grid .photo-item {
    aspect-ratio: 1 / 1;
    overflow: hidden;
    cursor: pointer;
    position: relative;
}

.photo-grid .photo-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.2s ease;
}

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

@media (max-width: 768px) {
    .photo-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* === Video Thumbnails === */
.video-indicator {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(0,0,0,0.6);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

.video-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #374151 0%, #1f2937 100%);
    width: 100%;
    height: 100%;
}

.video-placeholder .play-icon {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-placeholder .play-icon svg {
    width: 20px;
    height: 20px;
    fill: #1f2937;
    margin-left: 3px;
}

/* === Text Thumbnails === */
.text-thumbnail {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    width: 100%;
    height: 100%;
    padding: 16px;
    transition: transform 0.2s ease;
}

.photo-item:hover .text-thumbnail {
    transform: scale(1.05);
}

.text-thumbnail .text-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    pointer-events: none;
}

/* === Segmented Control === */
.segmented-control {
    display: inline-flex;
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 4px;
    flex-wrap: wrap;
    width: fit-content;
}

.segmented-control button {
    padding: 8px 16px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s;
    white-space: nowrap;
    color: var(--text-secondary);
}

.segmented-control button.active {
    background: var(--bg-primary);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    color: var(--text-primary);
}

/* === Expandable Search === */
.search-container {
    display: flex;
    align-items: center;
    background: var(--bg-tertiary);
    border-radius: 8px;
    padding: 4px;
    transition: all 0.3s ease;
    overflow: hidden;
    width: 44px;
}

.search-container.expanded {
    width: 200px;
}

.search-container input {
    width: 0;
    padding: 8px 0;
    border: none;
    background: transparent;
    color: var(--text-primary);
    outline: none;
    transition: width 0.3s ease, padding 0.3s ease;
}

.search-container.expanded input {
    width: 160px;
    padding: 8px;
}

.search-container input::placeholder {
    color: var(--text-muted);
}

.search-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    cursor: pointer;
    color: var(--text-secondary);
    border-radius: 6px;
    transition: background 0.2s;
    flex-shrink: 0;
}

.search-toggle:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

/* === Link Chips === */
.link-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    margin: 2px 4px;
    background: var(--accent-color);
    color: white !important;
    border-radius: 16px;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.link-chip:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.link-chip.link-external {
    background: var(--surface-elevated);
    border: 1px solid var(--accent-color);
}

.link-chip.link-external::after {
    content: '↗';
    margin-left: 6px;
    font-size: 0.75em;
    opacity: 0.7;
}

.link-chip.link-internal {
    background: var(--accent-color);
    border: 1px solid var(--accent-color);
}

/* === Text Modal === */
.text-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.text-modal.active {
    display: flex;
}

.text-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
}

.text-modal-content {
    position: relative;
    width: 90%;
    max-width: 800px;
    height: 80vh;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .text-modal-content {
    background: #1f2937;
}

.text-modal-close {
    position: absolute;
    top: 10px;
    right: 15px;
    background: none;
    border: none;
    color: #fff;
    font-size: 32px;
    cursor: pointer;
    z-index: 10;
    line-height: 1;
}

.text-modal-iframe {
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
}

/* === Skeleton Loader === */
@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.skeleton {
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
}

.photo-grid.skeleton-loading .photo-item {
    background: var(--bg-tertiary);
}

.photo-grid.skeleton-loading .photo-item::after {
    content: '';
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

/* === Empty State === */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    margin-bottom: 20px;
    color: var(--text-muted);
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state-text {
    font-size: 1rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.empty-state-text a {
    color: var(--accent-color);
    text-decoration: none;
}

.empty-state-text a:hover {
    text-decoration: underline;
}

/* === Metadata Overlay on Hover === */
.photo-item .media-meta {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(transparent, rgba(0,0,0,0.7));
    color: #fff;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.2s ease;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
}

.photo-item:hover .media-meta {
    opacity: 1;
}

.media-meta-date {
    font-weight: 500;
}


/* Filtered-out items (tag filter / search) */
.photo-item.is-filtered-out {
    display: none;
}

/* Hide metadata overlay for text items - they have their own theming */
.photo-item.is-text .media-meta,
.photo-item.is-text .media-meta-date {
    display: none !important;
}
