/*
 * Custom PDF Viewer Styles
 * Overrides PDF.js default toolbar to hide download/print/save buttons
 * and apply secure viewer branding.
 */

/* ── Reset & Full Page ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    background: #1a1a2e;
    font-family: "Poppins", "Segoe UI", Arial, sans-serif;
    overflow: hidden;
}

/* ── Top Viewer Bar ──────────────────────────────────────────── */
#cpv-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    height: 56px;
    background: #0f172a;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.25rem;
    gap: 1rem;
    user-select: none;
    -webkit-user-select: none;
}

.cpv-header-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #f8fafc;
    font-weight: 700;
    font-size: 0.95rem;
    flex-shrink: 0;
}

.cpv-header-brand i {
    color: #dc2626;
    font-size: 1.2rem;
}

.cpv-header-title {
    color: #94a3b8;
    font-size: 0.82rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 300px;
}

/* ── Toolbar Controls ────────────────────────────────────────── */
.cpv-toolbar {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.cpv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    white-space: nowrap;
}

.cpv-btn:hover {
    background: rgba(255,255,255,0.14);
    border-color: rgba(255,255,255,0.22);
    color: #fff;
}

.cpv-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.cpv-btn i { font-size: 0.9rem; }

.cpv-separator {
    width: 1px;
    height: 24px;
    background: rgba(255,255,255,0.12);
    flex-shrink: 0;
}

/* Page number input */
#cpv-page-input {
    width: 48px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 6px;
    color: #f1f5f9;
    font-size: 0.82rem;
    text-align: center;
    padding: 0.3rem 0.4rem;
    outline: none;
}

#cpv-page-input:focus {
    border-color: rgba(0,156,216,0.6);
    background: rgba(0,156,216,0.1);
}

.cpv-page-count {
    color: #64748b;
    font-size: 0.82rem;
    white-space: nowrap;
}

/* ── Secure badge ────────────────────────────────────────────── */
.cpv-secure-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(34, 197, 94, 0.12);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 20px;
    padding: 0.25rem 0.7rem;
    color: #86efac;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    user-select: none;
}

.cpv-secure-badge i { font-size: 0.75rem; }

/* ── PDF Canvas Area ─────────────────────────────────────────── */
#cpv-main {
    position: fixed;
    top: 56px;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    background: #1e293b;
    padding: 1.5rem 1rem;
}

/* Custom scrollbar */
#cpv-main::-webkit-scrollbar { width: 6px; }
#cpv-main::-webkit-scrollbar-track { background: #1e293b; }
#cpv-main::-webkit-scrollbar-thumb { background: #475569; border-radius: 3px; }
#cpv-main::-webkit-scrollbar-thumb:hover { background: #64748b; }

/* ── Watermark container (canvas overlay) ───────────────────── */
#cpv-watermark-canvas {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s;
}

/* ── Page wrapper ────────────────────────────────────────────── */
.cpv-page-container {
    position: relative;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    min-width: min-content;
}

.cpv-canvas-wrapper {
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.5);
    border-radius: 4px;
    overflow: hidden;
    display: inline-block;
}

#cpv-canvas {
    display: block;
    background: #fff;
}

/* ── Loading overlay ─────────────────────────────────────────── */
#cpv-loading {
    position: fixed;
    inset: 0;
    background: #1a1a2e;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    transition: opacity 0.4s ease;
}

#cpv-loading.hidden {
    opacity: 0;
    pointer-events: none;
}

.cpv-spinner {
    width: 48px; height: 48px;
    border: 4px solid rgba(255,255,255,0.1);
    border-top-color: #009cd8;
    border-radius: 50%;
    animation: cpvSpin 0.8s linear infinite;
}

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

.cpv-loading-text {
    color: #94a3b8;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ── Error state ─────────────────────────────────────────────── */
#cpv-error {
    display: none;
    position: fixed;
    inset: 56px 0 0 0;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
    color: #f87171;
    font-size: 1rem;
    background: #1e293b;
}

#cpv-error.visible { display: flex; }

/* ── Zoom & Scale indicator ─────────────────────────────────── */
#cpv-zoom-level {
    min-width: 50px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.82rem;
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 640px) {
    #cpv-header { padding: 0 0.75rem; height: 50px; }
    #cpv-main { top: 50px; padding: 0.75rem 0.25rem; }
    .cpv-header-title { display: none; }
    .cpv-secure-badge span { display: none; }
    .cpv-btn span { display: none; }
}
