/* ===========================================
   Viewer Page — PDF iframe + DOCX rendered preview
   =========================================== */

.viewer-body {
    margin: 0;
    background: var(--bg-light);
    font-family: 'Roboto', sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header --- */

.viewer-header {
    background: var(--primary-blue);
    color: var(--text-light);
    padding: 16px 32px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 24px;
    box-shadow: var(--shadow);
    flex-wrap: wrap;
    position: sticky;
    top: 0;
    z-index: 10;
}

.viewer-header-left {
    display: flex;
    align-items: center;
    gap: 20px;
    flex: 1;
    min-width: 0;
}

.viewer-title-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.viewer-title {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-light);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.viewer-type-badge {
    display: inline-block;
    width: fit-content;
    padding: 2px 10px;
    background: var(--secondary-gold);
    color: var(--primary-blue);
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 0.5px;
}

/* --- Buttons --- */

.btn-back,
.btn-download,
.btn-back-mini {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.85rem;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-back {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.btn-back:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-download {
    background: var(--secondary-gold);
    color: var(--primary-blue);
}

.btn-download:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(254, 180, 1, 0.4);
}

.btn-back-mini {
    background: var(--primary-blue);
    color: var(--text-light);
    margin-top: 12px;
}

.btn-back-mini:hover {
    background: #001e35;
}

/* --- Content area --- */

.viewer-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #525659;
    min-height: calc(100vh - 80px);
    position: relative;
}

.viewer-pdf-frame {
    flex: 1;
    width: 100%;
    border: none;
    min-height: calc(100vh - 80px);
}

.viewer-docx-content {
    background: white;
    margin: 24px auto;
    padding: 60px 80px;
    max-width: 900px;
    width: calc(100% - 48px);
    box-sizing: border-box;
    box-shadow: var(--shadow);
    border-radius: 4px;
    overflow-x: auto;
    color: var(--text-dark);
    line-height: 1.6;
    font-family: 'Roboto', sans-serif;
}

/* docx-preview injects its own structure; override its defaults gently. */
.viewer-docx-content .docx-wrapper {
    background: transparent !important;
    padding: 0 !important;
}

.viewer-docx-content .docx {
    box-shadow: none !important;
    margin: 0 !important;
}

/* --- States --- */

.viewer-loading,
.viewer-error {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    color: var(--text-light);
    font-size: 1rem;
    font-weight: 600;
    padding: 60px 20px;
    text-align: center;
}

.viewer-loading i {
    font-size: 3rem;
    color: var(--secondary-gold);
}

.viewer-error i {
    font-size: 3rem;
    color: #ef4444;
}

/* --- Download Progress Bar --- */

.viewer-progress-bar {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 5;
    overflow: hidden;
}

.viewer-progress-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--secondary-gold), #ffd54f);
    border-radius: 0 2px 2px 0;
    transition: width 0.2s ease-out;
}

/* --- Responsive --- */

@media (max-width: 640px) {
    .viewer-header {
        padding: 12px 16px;
        gap: 12px;
    }

    .viewer-header-left {
        gap: 12px;
    }

    .viewer-title {
        font-size: 0.95rem;
    }

    .viewer-docx-content {
        padding: 24px;
        margin: 12px;
        width: calc(100% - 24px);
    }

    .btn-back,
    .btn-download {
        padding: 8px 14px;
        font-size: 0.8rem;
    }
}
