/* =====================================================================
   BEM DZA (بيام ديزاد) — PDF.js Local Viewer Stylesheet
   Modern, responsive, touch-friendly Arabic RTL viewer.
   ===================================================================== */

.pdf-viewer-wrapper {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 4.5rem);
  background-color: #334155;
  color: #f8fafc;
  position: relative;
  overflow: hidden;
}

/* --- Viewer Header / Back Bar --- */
.pdf-viewer-header {
  background-color: #1e293b;
  border-bottom: 1px solid #475569;
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.pdf-header-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: #ffffff;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 600px;
}

.pdf-header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Viewer Toolbar --- */
.pdf-toolbar {
  background-color: #0f172a;
  border-bottom: 1px solid #334155;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.toolbar-btn {
  background-color: #1e293b;
  color: #f8fafc;
  border: 1px solid #475569;
  border-radius: var(--radius-sm, 6px);
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 36px;
  min-width: 36px;
  transition: all 0.15s ease;
  user-select: none;
}

.toolbar-btn:hover:not(:disabled) {
  background-color: #334155;
  border-color: #64748b;
  color: #ffffff;
}

.toolbar-btn:focus-visible {
  outline: 2px solid #10b981;
  outline-offset: 1px;
}

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

.toolbar-btn.btn-primary {
  background-color: #059669;
  border-color: #047857;
  color: #ffffff;
}

.toolbar-btn.btn-primary:hover:not(:disabled) {
  background-color: #047857;
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: #cbd5e1;
}

.page-number-input {
  width: 48px;
  height: 34px;
  background-color: #1e293b;
  border: 1px solid #475569;
  border-radius: var(--radius-sm, 6px);
  color: #ffffff;
  text-align: center;
  font-weight: 700;
  font-size: 0.9rem;
  padding: 0 0.25rem;
}

.page-number-input:focus {
  border-color: #10b981;
  outline: none;
}

.zoom-text {
  min-width: 45px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  color: #cbd5e1;
}

/* --- Main Canvas Container --- */
.pdf-canvas-container {
  flex: 1;
  overflow: auto;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: #475569;
  position: relative;
  min-height: 500px;
}

.pdf-page-wrapper {
  position: relative;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  background-color: #ffffff;
  border-radius: 4px;
  margin-bottom: 1.5rem;
  transition: transform 0.15s ease;
  max-width: 100%;
}

.pdf-canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 4px;
}

/* --- Overlay States: Loading & Error --- */
.pdf-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(30, 41, 59, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 2rem;
  text-align: center;
}

.pdf-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #475569;
  border-top-color: #10b981;
  border-radius: 50%;
  animation: pdf-spin 0.8s linear infinite;
  margin-bottom: 1rem;
}

@keyframes pdf-spin {
  to { transform: rotate(360deg); }
}

.pdf-loading-text {
  font-size: 1.1rem;
  font-weight: 700;
  color: #f8fafc;
}

.pdf-error-box {
  background-color: #1e293b;
  border: 1px solid #ef4444;
  border-radius: 12px;
  padding: 2rem;
  max-width: 480px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.pdf-error-icon {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  color: #ef4444;
}

.pdf-error-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 0.5rem;
}

.pdf-error-desc {
  font-size: 0.95rem;
  color: #94a3b8;
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.pdf-error-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 768px) {
  .pdf-toolbar {
    padding: 0.5rem;
    justify-content: center;
  }

  .toolbar-group {
    gap: 0.25rem;
  }

  .toolbar-btn {
    padding: 0.35rem 0.5rem;
    font-size: 0.8rem;
    min-height: 40px;
    min-width: 40px;
  }

  .toolbar-btn span.btn-label {
    display: none;
  }

  .pdf-header-title {
    max-width: 100%;
    font-size: 0.95rem;
  }

  .pdf-canvas-container {
    padding: 0.75rem 0.5rem;
  }
}

@media (max-width: 480px) {
  .pdf-viewer-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .pdf-header-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* --- Inline Viewer Responsive Specifications --- */
.pdf-viewer-wrapper.inline-viewer {
  min-height: unset;
  height: 75vh;
  border-radius: var(--radius-lg, 12px);
  border: 1px solid #475569;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.25), 0 8px 10px -6px rgba(0, 0, 0, 0.2);
  margin-top: 1.5rem;
  margin-bottom: 2rem;
  overflow: hidden;
}

.pdf-viewer-wrapper.inline-viewer .pdf-canvas-container {
  height: calc(75vh - 55px);
  min-height: 480px;
}

/* Fullscreen support */
.pdf-viewer-wrapper:fullscreen,
.pdf-viewer-wrapper:-webkit-full-screen {
  width: 100vw !important;
  height: 100vh !important;
  max-height: 100vh !important;
  border-radius: 0 !important;
  border: none !important;
  margin: 0 !important;
  z-index: 999999 !important;
}

.pdf-viewer-wrapper:fullscreen .pdf-canvas-container,
.pdf-viewer-wrapper:-webkit-full-screen .pdf-canvas-container {
  height: calc(100vh - 55px) !important;
  max-height: calc(100vh - 55px) !important;
}

@media (max-width: 768px) {
  .pdf-viewer-wrapper.inline-viewer {
    height: 70vh;
    border-radius: var(--radius-md, 8px);
    margin-top: 1rem;
    margin-bottom: 1.5rem;
  }

  .pdf-viewer-wrapper.inline-viewer .pdf-canvas-container {
    height: calc(70vh - 90px);
    min-height: 380px;
  }
}

