/* ── Reset & base ─────────────────────────────────────────────────────────── */
#aplb-modal *,
#aplb-modal *::before,
#aplb-modal *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Overlay ──────────────────────────────────────────────────────────────── */
#aplb-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 999999;
    align-items: stretch;
    justify-content: center;
}
#aplb-modal.aplb-open { display: flex; }

/* ── Inner layout ─────────────────────────────────────────────────────────── */
.aplb-inner {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100dvh;
    background: #2d2d2d;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Toolbar ──────────────────────────────────────────────────────────────── */
.aplb-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px;
    background: #1e293b;
    color: #e2e8f0;
    flex-shrink: 0;
    flex-wrap: wrap;
}

.aplb-toolbar-left {
    display: flex;
    align-items: center;
    min-width: 0;
    flex: 1 1 120px;
}
.aplb-doc-title {
    font-size: 13.5px;
    font-weight: 600;
    color: #f1f5f9;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.aplb-toolbar-center {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.aplb-toolbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto;
}

.aplb-tool-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    background: transparent;
    border: none;
    border-radius: 7px;
    color: #cbd5e1;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
}
.aplb-tool-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }
.aplb-tool-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.aplb-close-btn {
    font-size: 22px;
    line-height: 1;
}

.aplb-page-info {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 13px;
    color: #cbd5e1;
    white-space: nowrap;
}
.aplb-page-info input {
    width: 42px;
    text-align: center;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.15);
    color: #f1f5f9;
    border-radius: 5px;
    font-size: 13px;
    padding: 4px 2px;
}
.aplb-page-info input:focus { outline: none; border-color: #3b82f6; }

.aplb-divider {
    width: 1px;
    height: 20px;
    background: rgba(255,255,255,0.15);
    margin: 0 4px;
    flex-shrink: 0;
}

.aplb-zoom-level {
    font-size: 12.5px;
    color: #cbd5e1;
    min-width: 42px;
    text-align: center;
    white-space: nowrap;
}

/* ── Canvas area ──────────────────────────────────────────────────────────── */
.aplb-canvas-wrap {
    position: relative;
    flex: 1 1 auto;
    overflow: auto;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 24px;
    background: #404040;
}

#aplb-canvas {
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
    background: #fff;
    visibility: hidden;
    max-width: 100%;
}

/* Loading state */
.aplb-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    color: #cbd5e1;
    font-size: 13px;
	display:none;
}
.aplb-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid rgba(255,255,255,0.15);
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: aplb-spin 0.7s linear infinite;
}
@keyframes aplb-spin { to { transform: rotate(360deg); } }

/* Error state */
.aplb-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 320px;
    text-align: center;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 20px 22px;
    color: #dc2626;
}
.aplb-error strong { display: block; margin-bottom: 6px; font-size: 14px; }
.aplb-error p { margin: 0; font-size: 13px; line-height: 1.5; color: #b91c1c; }

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 640px) {
    .aplb-toolbar {
        padding: 8px 10px;
        gap: 8px;
    }
    .aplb-doc-title { font-size: 12px; }
    .aplb-toolbar-left { flex-basis: 100%; order: 1; }
    .aplb-toolbar-center { order: 2; flex: 1 1 auto; justify-content: center; }
    .aplb-toolbar-right { order: 3; }
    .aplb-tool-btn { width: 30px; height: 30px; }
    .aplb-canvas-wrap { padding: 12px; }
    .aplb-zoom-level { display: none; }
    .aplb-divider { display: none; }
}
