/* ═══════════════════════════════════════════════════════════
   TOTO PDF Viewer Widget — assets/css/pdf-viewer.css
   عارض PDF تفاعلي — روابط تفتح في تاب جديد
═══════════════════════════════════════════════════════════ */

/* ── Wrapper ── */
.toto-pv-wrap {
    position: relative;
    width: 100%;
    height: 85vh;
    display: flex;
    flex-direction: column;
    background: #1a1a2e;
    border-radius: 12px;
    overflow: hidden;
    box-shadow:
        0 4px 24px rgba(0,0,0,.35),
        0 1px 4px rgba(0,0,0,.2);
    font-family: 'GothamSSm', 'Helvetica Neue', Arial, sans-serif;
}

/* ── Fullscreen state ── */
.toto-pv-wrap.toto-pv-fullscreen {
    position: fixed !important;
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0 !important;
    z-index: 999999 !important;
}

/* ── Placeholder (editor only) ── */
.toto-pv-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 240px;
    background: #f5f5f7;
    border: 2px dashed #d0d0d8;
    border-radius: 12px;
    color: #888;
    font-size: .9rem;
    padding: 40px;
    text-align: center;
}

/* ════════════════════════════════════════
   TOOLBAR
════════════════════════════════════════ */
.toto-pv-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 16px;
    height: 52px;
    min-height: 52px;
    background: #0f0f1a;
    border-bottom: 1px solid rgba(255,255,255,.08);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

.toto-pv-toolbar-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* ── Toolbar Buttons ── */
.toto-pv-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    background: transparent;
    border: 1px solid transparent;
    color: #e8e8f0;
    cursor: pointer;
    border-radius: 7px;
    padding: 6px 10px;
    font-size: .8rem;
    font-family: inherit;
    line-height: 1;
    transition: background .18s, color .18s, border-color .18s;
    white-space: nowrap;
    text-decoration: none;
}
.toto-pv-btn:hover {
    background: rgba(255,255,255,.08);
    border-color: rgba(201,168,76,.5);
    color: #c9a84c;
}
.toto-pv-btn:focus-visible {
    outline: 2px solid #c9a84c;
    outline-offset: 2px;
}
.toto-pv-btn svg { flex-shrink: 0; }

/* Primary (download) */
.toto-pv-btn-primary {
    background: #c9a84c;
    border-color: #c9a84c;
    color: #0f0f1a;
    font-weight: 600;
    padding: 6px 14px;
}
.toto-pv-btn-primary:hover {
    background: #b8952f;
    border-color: #b8952f;
    color: #0f0f1a;
}

/* Page input */
.toto-pv-page-info {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .82rem;
    color: #e8e8f0;
}
.toto-pv-page-input {
    width: 46px;
    background: rgba(255,255,255,.1);
    border: 1px solid rgba(255,255,255,.15);
    border-radius: 5px;
    color: #e8e8f0;
    font-size: .82rem;
    font-family: inherit;
    padding: 3px 6px;
    text-align: center;
    -moz-appearance: textfield;
}
.toto-pv-page-input::-webkit-outer-spin-button,
.toto-pv-page-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.toto-pv-page-input:focus { outline: 1px solid #c9a84c; }
.toto-pv-page-sep { opacity: .5; }
.toto-pv-total-pages { opacity: .7; }

/* Zoom label */
.toto-pv-zoom-label {
    font-size: .78rem;
    min-width: 38px;
    text-align: center;
    color: rgba(232,232,240,.6);
}

/* ════════════════════════════════════════
   CANVAS AREA
════════════════════════════════════════ */
.toto-pv-canvas-area {
    flex: 1;
    position: relative;
    overflow: auto;
    background: #1a1a2e;
    display: flex;
    flex-direction: column;
    align-items: center;
    scroll-behavior: smooth;

    /* Custom scrollbar */
    scrollbar-width: thin;
    scrollbar-color: rgba(201,168,76,.4) rgba(255,255,255,.05);
}
.toto-pv-canvas-area::-webkit-scrollbar { width: 6px; height: 6px; }
.toto-pv-canvas-area::-webkit-scrollbar-track { background: rgba(255,255,255,.04); }
.toto-pv-canvas-area::-webkit-scrollbar-thumb { background: rgba(201,168,76,.4); border-radius: 3px; }

/* ── iFrame Mode ── */
.toto-pv-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ── Loading ── */
.toto-pv-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    position: absolute;
    inset: 0;
    color: rgba(232,232,240,.7);
    font-size: .9rem;
    background: #1a1a2e;
    z-index: 5;
    transition: opacity .3s;
}
.toto-pv-loading.toto-pv-done { opacity: 0; pointer-events: none; }

.toto-pv-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(201,168,76,.2);
    border-top-color: #c9a84c;
    border-radius: 50%;
    animation: toto-pv-spin .75s linear infinite;
}
@keyframes toto-pv-spin { to { transform: rotate(360deg); } }

/* ── Error ── */
.toto-pv-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 40px;
    text-align: center;
    color: rgba(232,232,240,.7);
    font-size: .9rem;
}
.toto-pv-error[hidden] {
    display: none !important;
}
.toto-pv-error a { color: #c9a84c; }

/* ── Pages Container ── */
.toto-pv-pages-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 24px 16px;
    width: 100%;
    box-sizing: border-box;
}

/* ── Individual Page ── */
.toto-pv-page-wrapper {
    position: relative;
    box-shadow:
        0 8px 32px rgba(0,0,0,.5),
        0 2px 8px rgba(0,0,0,.3);
    border-radius: 3px;
    overflow: hidden;
    line-height: 0;
    transition: box-shadow .2s;
}
.toto-pv-page-wrapper:hover {
    box-shadow:
        0 12px 40px rgba(0,0,0,.6),
        0 4px 12px rgba(0,0,0,.4);
}

/* The rendered PDF canvas */
.toto-pv-page-canvas {
    display: block;
    max-width: 100%;
}

/* ── Link Overlay Layer ──
   هذه الطبقة تحتوي كل عناصر <a> المستخرجة من الـ PDF
   وتضمن فتحها في تاب جديد
── */
.toto-pv-link-layer {
    position: absolute;
    inset: 0;
    pointer-events: none; /* الكونتينر نفسه لا يمسك الأحداث */
}

/* كل رابط فردي */
.toto-pv-link-layer a {
    position: absolute;
    display: block;
    pointer-events: all;    /* الروابط تمسك الأحداث */
    cursor: pointer;
    opacity: 0;             /* invisible — for click area only */
    z-index: 20;
    border-radius: 2px;
    transition: opacity .15s, background .15s;
}
/* Hover highlight — يظهر للمستخدم إن فيه رابط */
.toto-pv-link-layer a:hover {
    opacity: 1;
    background: rgba(201,168,76,.18);
    outline: 1.5px solid rgba(201,168,76,.5);
}

/* ════════════════════════════════════════
   RESPONSIVE
════════════════════════════════════════ */
@media (max-width: 768px) {
    .toto-pv-wrap { height: 75vh; border-radius: 8px; }

    .toto-pv-toolbar {
        padding: 0 10px;
        height: 48px;
        min-height: 48px;
        flex-wrap: nowrap;
        overflow-x: auto;
        gap: 4px;
    }
    .toto-pv-toolbar::-webkit-scrollbar { display: none; }

    .toto-pv-btn-label { display: none; } /* hide text labels on mobile */
    .toto-pv-btn-primary { padding: 6px 10px; }

    .toto-pv-zoom-label { display: none; }

    .toto-pv-pages-container { padding: 12px 8px; gap: 10px; }
}

@media (max-width: 480px) {
    .toto-pv-wrap { height: 70vh; border-radius: 6px; }
    .toto-pv-page-info { font-size: .75rem; }
    .toto-pv-page-input { width: 38px; }
}
