/* ── Family Archive Files page — nav bar ──────────────────────── */

.family-archive-files-container { display: flex; flex-direction: column; gap: 16px; }

.faf-nav {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    padding: 8px 12px;
    background: var(--rz-panel-background-color, #fff);
    border: 1px solid rgba(0,0,0,0.08); border-radius: 12px;
    min-width: 0;
}
.faf-nav-left {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
    min-width: 0; overflow: hidden;
}
.faf-nav-right {
    display: flex; align-items: center; gap: 8px; flex: 1;
    justify-content: flex-end; min-width: 0;
}

.faf-back-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 5px 12px;
    border: 1px solid rgba(0,0,0,0.12); border-radius: 7px;
    background: transparent; cursor: pointer;
    font-size: 13px; color: var(--rz-text-color, #1a1a1a);
    font-family: inherit;
    transition: background 0.14s, border-color 0.14s, color 0.14s;
    white-space: nowrap;
}
.faf-back-btn:hover { background: rgba(238,112,38,0.07); border-color: #EE7026; color: #C05415; }

.faf-sep { color: var(--rz-text-secondary-color, #aaa); user-select: none; font-size: 14px; }

.faf-breadcrumb {
    font-size: 14px; font-weight: 700; color: var(--rz-text-color, #1a1a1a);
    white-space: nowrap;
}

.faf-search-box {
    flex: 1; min-width: 160px; display: flex; align-items: center; gap: 8px;
    background: rgba(0,0,0,0.03); border: 1px solid rgba(0,0,0,0.09);
    border-radius: 7px; padding: 7px 12px;
    transition: border-color 0.14s;
}
.faf-search-box:focus-within { border-color: #EE7026; }
.faf-search-icon { color: #EE7026; font-size: 18px; flex-shrink: 0; }
.faf-search-input {
    flex: 1; border: none; background: transparent; outline: none;
    font-size: 13px; color: var(--rz-text-color, #1a1a1a); font-family: inherit;
}

.faf-filter-btn {
    display: flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    background: transparent; border: 1px solid rgba(0,0,0,0.12); border-radius: 7px;
    font-size: 13px; font-weight: 500; color: #EE7026;
    cursor: pointer; font-family: inherit; white-space: nowrap;
    transition: background 0.14s, border-color 0.14s;
}
.faf-filter-btn:hover { background: rgba(238,112,38,0.07); border-color: #EE7026; }

/* ── Tagged-user filter banner (arrived via a profile's "View Archive Files") ── */
.faf-tagged-filter-bar {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; margin-bottom: 14px;
    background: rgba(238,112,38,0.08); border: 1px solid rgba(238,112,38,0.3); border-radius: 8px;
    font-size: 13px; color: #C05415;
}
.faf-tagged-filter-bar i { color: #EE7026; }
.faf-tagged-filter-bar span { flex: 1; font-weight: 500; }
.faf-tagged-filter-clear {
    padding: 5px 12px;
    background: #fff; border: 1px solid #EE7026; border-radius: 6px;
    font-size: 12px; font-weight: 600; color: #EE7026;
    cursor: pointer; font-family: inherit; white-space: nowrap;
    transition: background 0.14s;
}
.faf-tagged-filter-clear:hover { background: rgba(238,112,38,0.1); }

/* ── Filter panel ── */
.faf-filter-panel {
    display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end;
    padding: 16px 18px;
    background: var(--rz-panel-background-color, #fff);
    border: 1.5px solid rgba(238,112,38,0.25); border-radius: 10px;
}
.faf-filter-group { display: flex; flex-direction: column; gap: 5px; min-width: 160px; flex: 1; }
.faf-filter-label { font-size: 11px; font-weight: 600; color: #999; text-transform: uppercase; letter-spacing: 0.05em; }
.faf-filter-select {
    padding: 8px 12px; border: 1px solid rgba(0,0,0,0.12); border-radius: 7px;
    font-size: 13px; font-family: inherit;
    background: var(--rz-panel-background-color, #fff); color: var(--rz-text-color, #1a1a1a);
    outline: none;
}
.faf-filter-select:focus { border-color: #EE7026; }
.faf-apply-btn {
    padding: 9px 20px; border: none; border-radius: 7px;
    background: linear-gradient(135deg, #F5832E 0%, #EE7026 55%, #C05415 100%);
    color: #fff; font-size: 13px; font-weight: 600; cursor: pointer; font-family: inherit;
    white-space: nowrap; align-self: flex-end; transition: opacity 0.15s;
}
.faf-apply-btn:hover { opacity: 0.88; }

/* Files Grid */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
    padding-bottom: 40px;
}

.file-thumbnail {
    cursor: pointer;
    border-radius: 10px;
    overflow: hidden;
    transition: box-shadow 0.18s, transform 0.18s;
    border: 1px solid rgba(0,0,0,0.08);
    position: relative;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.07);
}

.file-thumbnail:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 18px rgba(0,0,0,0.13);
    border-color: rgba(238,112,38,0.35);
}

/* Edit icon overlay - positioned at top-right corner */
.edit-icon-overlay {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    background-color: rgba(238, 112, 38, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.edit-icon-overlay:hover {
    background-color: #EE7026;
    transform: scale(1.1);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
}

.edit-icon-overlay .rzi {
    color: white;
    font-size: 20px !important;
}

.thumbnail-image {
    width: 100%;
    height: 170px;
    background-color: #f5f5f5;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    position: relative;
}

.thumbnail-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    user-select: none;
    pointer-events: none;
}

.video-placeholder,
.document-placeholder,
.article-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fdf5f0 0%, #fae8db 100%);
    font-size: 48px;
    color: #EE7026;
}

/* Video thumbnail with play overlay */
.video-thumbnail-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #2c2c2c 0%, #1a1a1a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.video-thumbnail-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
}

.video-play-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 72px;
    overflow: hidden;
    width: 72px;
    height: 72px;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    transition: transform 0.2s ease, color 0.2s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Hide the icon text, show only the icon */
.video-play-overlay .rz-icon {
    font-size: 72px;
    line-height: 1;
}

/* Hide text next to icons in video overlay */
.video-play-overlay .rzi,
.video-play-overlay span:not(.rzi) {
    font-size: 0 !important;
}

.video-play-overlay .rzi::before {
    font-size: 72px !important;
}

.file-thumbnail:hover .video-play-overlay {
    transform: translate(-50%, -50%) scale(1.1);
    color: #EE7026;
}

.file-name-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    color: white;
    padding: 10px;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Filename label below the thumbnail */
.file-name-label {
    background-color: #fff;
    color: #444;
    padding: 7px 10px;
    font-size: 12px;
    font-weight: 500;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border-top: 1px solid rgba(0,0,0,0.06);
}

.file-thumbnail:hover .file-name-label {
    color: #C05415;
}

.no-files {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 20px;
    color: #999;
    font-size: 18px;
}

.loading-indicator {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #EE7026;
}

.loading-indicator p {
    margin-top: 15px;
    font-size: 16px;
    font-weight: 500;
}

.file-count-info {
    text-align: center;
    padding: 20px;
    color: #666;
    font-size: 16px;
    font-weight: 500;
}

/* Archive Viewer Modal */
/* Archive Viewer Dialog Styles */
.archive-viewer-dialog {
    border: 3px solid #EE7026 !important;
    border-radius: 12px !important;
}

.archive-viewer-dialog .rz-dialog-content {
    padding: 0 !important;
}

.archive-viewer-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    background-color: #f9f9f9;
}

.viewer-header h3 {
    margin: 0;
    color: #333;
    font-size: 20px;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.edit-btn {
    background-color: #EE7026;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
}

.edit-btn:hover {
    background-color: #d65a1a;
}

.close-btn {
    background-color: #EE7026;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
}

.close-btn:hover {
    background-color: #d65a1a;
}

.fullscreen-btn {
    background-color: #555;
    color: white;
    border: none;
    border-radius: 50%;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
}

.fullscreen-btn:hover {
    background-color: #333;
}

/* ── Fullscreen mode ──────────────────────────────────────────────────── */
.archive-viewer-content:fullscreen,
.archive-viewer-content:-webkit-full-screen,
.archive-viewer-content:-moz-full-screen,
.archive-viewer-content:-ms-fullscreen {
    background-color: #000;
    display: flex;
    flex-direction: column;
}

/* Dark header bar */
.archive-viewer-content:fullscreen .viewer-header,
.archive-viewer-content:-webkit-full-screen .viewer-header,
.archive-viewer-content:-moz-full-screen .viewer-header,
.archive-viewer-content:-ms-fullscreen .viewer-header {
    background-color: #1a1a1a;
    border-bottom-color: #333;
    flex-shrink: 0;
}

.archive-viewer-content:fullscreen .viewer-header h3,
.archive-viewer-content:-webkit-full-screen .viewer-header h3,
.archive-viewer-content:-moz-full-screen .viewer-header h3,
.archive-viewer-content:-ms-fullscreen .viewer-header h3 {
    color: #fff;
}

/* Content fills remaining height */
.archive-viewer-content:fullscreen .viewer-content,
.archive-viewer-content:-webkit-full-screen .viewer-content,
.archive-viewer-content:-moz-full-screen .viewer-content,
.archive-viewer-content:-ms-fullscreen .viewer-content {
    flex: 1;
    padding: 0;
}

/* Hide metadata strip — maximise viewable area */
.archive-viewer-content:fullscreen .viewer-info,
.archive-viewer-content:-webkit-full-screen .viewer-info,
.archive-viewer-content:-moz-full-screen .viewer-info,
.archive-viewer-content:-ms-fullscreen .viewer-info {
    display: none;
}

/* Images scale to full screen */
.archive-viewer-content:fullscreen .image-viewer img,
.archive-viewer-content:-webkit-full-screen .image-viewer img,
.archive-viewer-content:-moz-full-screen .image-viewer img,
.archive-viewer-content:-ms-fullscreen .image-viewer img {
    max-width: 100vw;
    max-height: 100vh;
}

/* Videos fill the space */
.archive-viewer-content:fullscreen .video-viewer video,
.archive-viewer-content:-webkit-full-screen .video-viewer video,
.archive-viewer-content:-moz-full-screen .video-viewer video,
.archive-viewer-content:-ms-fullscreen .video-viewer video {
    max-height: calc(100vh - 70px); /* subtract header */
}

/* PDF canvas container fills height */
.archive-viewer-content:fullscreen .pdf-viewer-container,
.archive-viewer-content:-webkit-full-screen .pdf-viewer-container,
.archive-viewer-content:-moz-full-screen .pdf-viewer-container,
.archive-viewer-content:-ms-fullscreen .pdf-viewer-container {
    height: calc(100vh - 70px);
}

/* Text viewer scrolls inside fullscreen */
.archive-viewer-content:fullscreen .text-viewer,
.archive-viewer-content:-webkit-full-screen .text-viewer,
.archive-viewer-content:-moz-full-screen .text-viewer,
.archive-viewer-content:-ms-fullscreen .text-viewer {
    height: calc(100vh - 70px);
    overflow-y: auto;
    background-color: #1e1e1e;
    color: #d4d4d4;
    padding: 20px;
    width: 100%;
}

/* Article / news iframe */
.archive-viewer-content:fullscreen .article-viewer iframe,
.archive-viewer-content:-webkit-full-screen .article-viewer iframe,
.archive-viewer-content:-moz-full-screen .article-viewer iframe,
.archive-viewer-content:-ms-fullscreen .article-viewer iframe {
    height: calc(100vh - 70px);
}

/* Edit Archive File Dialog */
.edit-archive-file-dialog {
    padding: 20px;
}

.edit-archive-file-dialog .form-group {
    margin-bottom: 15px;
}

.edit-archive-file-dialog .form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.edit-archive-file-dialog .dialog-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.viewer-content {
    flex: 1;
    overflow: hidden; /* Changed from auto to hidden to prevent scrolling */
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #000;
    padding: 20px;
    min-height: 0; /* Allow flex child to shrink */
}

.video-viewer,
.image-viewer,
.document-viewer,
.article-viewer {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0; /* Allow flex child to shrink */
}

.video-viewer video,
.document-viewer iframe,
.article-viewer iframe {
    width: 100%;
    height: 100%;
    border: none;
    user-select: none;
}

.image-viewer img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain; /* Ensure image fits without cropping */
    user-select: none;
    display: block;
}

/* Document fallback viewer */
.document-viewer-fallback {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    background: linear-gradient(135deg, #f5f5f5 0%, #e8e8e8 100%);
    width: 100%;
    height: 100%;
    min-height: 300px;
}

.document-viewer-fallback .document-icon {
    margin-bottom: 20px;
}

.document-viewer-fallback .document-name {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 10px;
    word-break: break-word;
}

.document-viewer-fallback .document-info {
    font-size: 14px;
    color: #666;
    margin-bottom: 20px;
}

.document-viewer-fallback .document-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background-color: #EE7026;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.2s ease;
}

.document-viewer-fallback .document-download-btn:hover {
    background-color: #d4621f;
    color: white;
    text-decoration: none;
}

/* PDF Viewer */
.pdf-viewer {
    width: 100%;
    height: 100%;
    min-height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #525659;
}

.pdf-viewer embed {
    width: 100%;
    height: 100%;
    min-height: 500px;
}

/* Text file viewer */
.text-viewer {
    width: 100%;
    height: 100%;
    min-height: 300px;
    overflow: auto;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
}

.text-viewer pre {
    padding: 20px;
    margin: 0;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #333;
}

/* Office document viewer (Word, Excel, PowerPoint) */
.office-viewer {
    width: 100%;
    height: 100%;
    min-height: 500px;
    display: flex;
    align-items: stretch;
    justify-content: center;
    background-color: #f0f0f0;
}

.office-viewer iframe {
    width: 100%;
    height: 100%;
    min-height: 500px;
    border: none;
}

.viewer-info {
    padding: 15px 20px;
    background-color: #f9f9f9;
    border-top: 1px solid #eee;
}

.info-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    font-size: 14px;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-label {
    font-weight: 600;
    color: #333;
    min-width: 80px;
    flex-shrink: 0;
}

.description-row {
    flex-wrap: wrap;
}

.description-text {
    flex: 1;
    line-height: 1.5;
}

.info-value {
    color: #666;
    flex: 1;
    word-break: break-word;
}

/* Back to Top Button - positioned via JavaScript within .rz-body */
.back-to-top-btn {
    position: absolute;
    background-color: #EE7026;
    color: white;
    border: none;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 28px;
    box-shadow: 0 4px 12px rgba(238, 112, 38, 0.4);
    z-index: 1000;
    transition: background-color 0.3s ease, transform 0.3s ease;
}

.back-to-top-btn:hover {
    background-color: #d65a1a;
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(238, 112, 38, 0.6);
}

/* Responsive Design */
@media (max-width: 768px) {
    .archive-search-filter {
        flex-direction: column;
    }

    .filter-panel {
        grid-template-columns: 1fr;
    }

    .archive-categories {
        grid-template-columns: repeat(2, 1fr);
    }

    .files-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .archive-viewer-modal {
        max-width: 95vw;
        max-height: 95vh;
    }

    .back-to-top-btn {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }

    .breadcrumbs {
        font-size: 14px;
    }

    .archive-header h2 {
        font-size: 24px;
    }
}

/* Prevent right-click context menu and screenshots */
.image-viewer img,
.video-viewer video {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Disable print functionality */
@media print {
    .archive-viewer-overlay,
    .archive-viewer-modal {
        display: none !important;
    }
}

/* PDF.js Viewer Styles */
.pdf-viewer-container {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: #525659;
    border-radius: 4px;
    overflow: hidden;
}

.pdf-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 10px 15px;
    background-color: #323639;
    color: white;
    flex-shrink: 0;
}

.pdf-btn {
    background-color: #EE7026;
    color: white;
    border: none;
    border-radius: 4px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.pdf-btn:hover {
    background-color: #d35f1b;
}

.pdf-btn:disabled {
    background-color: #666;
    cursor: not-allowed;
}

.pdf-page-info {
    font-size: 14px;
    margin: 0 10px;
}

.pdf-pages-wrapper {
    flex: 1;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

.pdf-canvas {
    max-width: 100%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    background-color: white;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.pdf-loading, .pdf-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: white;
    font-size: 16px;
}

.pdf-error {
    color: #ff6b6b;
}

