/* ===========================
   GLOBAL LAYOUT
   =========================== */
body {
  height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: #f8f9fa;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: #212529;
  margin: 0;
}

.navbar {
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  z-index: 10;
}

footer {
  background-color: #fff;
  border-top: 1px solid #dee2e6;
  font-size: 0.85rem;
  padding: 0.5rem;
}

/* ===========================
   NAVBAR / TOOLBAR
   =========================== */
.app-navbar {
  backdrop-filter: blur(6px);
}

.app-toolbar {
  gap: 0.75rem;
}

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

.toolbar-file {
  min-width: 210px;
  max-width: 260px;
}

.toolbar-page input {
  width: 70px;
}

.toolbar-zoom {
  min-width: 160px;
  max-width: 220px;
}

.toolbar-zoom .form-range {
  margin: 0;
}

.toolbar-save {
  white-space: nowrap;
}

/* ===========================
   PDF VIEWER
   =========================== */
#viewer-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  overflow-x: auto;
  background: #f1f3f6;
  padding: 1rem;
}

#pdf-container {
  position: relative;
  display: inline-block;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  background-color: #ffffff;
  border-radius: 8px;
  overflow: hidden;
  max-width: 100%;
}

canvas {
  display: block;
  border: none;
  border-radius: 6px;
}

#overlay {
  position: absolute;
  left: 0;
  top: 0;
  cursor: crosshair;
}

/* ===========================
   SIDEBAR
   =========================== */
.app-sidebar {
  background-color: #ffffff;
  min-height: 100%;
  border-right: 1px solid #dee2e6;
}

button.btn-outline-primary.active,
button.btn-outline-danger.active {
  background-color: #0d6efd;
  color: #fff;
  border-color: #0d6efd;
}

/* ===========================
   TEXT BOXES
   =========================== */
.text-box {
  position: absolute;
  border: 1px dashed #6c757d;
  background: transparent;
  min-width: 50px;
  min-height: 20px;
  cursor: move;
  padding: 2px 4px;
  resize: both;
  overflow: hidden;
  border-radius: 3px;
  transition: border-color 0.2s, background-color 0.2s;
}

.text-box:hover {
  border-color: #0d6efd;
  background-color: rgba(13, 110, 253, 0.05);
}

.resize-handle {
  width: 10px;
  height: 10px;
  background: #0d6efd;
  border-radius: 50%;
  position: absolute;
  bottom: -5px;
  right: -5px;
  cursor: se-resize;
}

.selected-text {
  outline: 2px dashed #0d6efd;
  outline-offset: 2px;
}

/* ===========================
   FORM CONTROLS
   =========================== */
input[type="range"] {
  accent-color: #0d6efd;
}

input[type="color"] {
  border: none;
  background: transparent;
}

/* ===========================
   MODAL
   =========================== */
.modal-content {
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-header,
.modal-footer {
  background: #f8f9fa;
  border-color: #dee2e6;
}

/* ===========================
   SCROLLBAR
   =========================== */
#viewer-wrap::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

#viewer-wrap::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 10px;
}

#viewer-wrap::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.3);
}

/* ===========================
   DARK MODE
   =========================== */
body.dark-mode {
  background-color: #121212;
  color: #e0e0e0;
}

/* Main surfaces */
body.dark-mode .navbar,
body.dark-mode footer,
body.dark-mode .app-sidebar,
body.dark-mode .modal-content {
  background-color: #1e1e1e !important;
  color: #e0e0e0;
  border-color: #333;
}

/* Generic white backgrounds (e.g. bg-white, border cards) */
body.dark-mode .bg-white {
  background-color: #1e1e1e !important;
}

body.dark-mode .border,
body.dark-mode .border-top,
body.dark-mode .border-end {
  border-color: #333 !important;
}

/* Viewer background */
body.dark-mode #viewer-wrap {
  background: #151515;
}

body.dark-mode #pdf-container {
  background-color: #1a1a1a;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.8);
}

body.dark-mode canvas {
  border-color: #444;
}

/* Text + muted text */
body.dark-mode,
body.dark-mode .modal-content {
  color: #e0e0e0;
}

body.dark-mode .text-muted,
body.dark-mode .form-text {
  color: #aaaaaa !important;
}

/* Text boxes */
body.dark-mode .text-box {
  border-color: #bbb;
  background-color: rgba(255, 255, 255, 0.05);
}

body.dark-mode .text-box:hover {
  border-color: #0d6efd;
  background-color: rgba(13, 110, 253, 0.15);
}

body.dark-mode .selected-text {
  outline-color: #0d6efd;
}

/* Buttons */
body.dark-mode .btn-primary {
  background-color: #0b63d1;
  border-color: #0b63d1;
}

body.dark-mode .btn-primary:hover {
  background-color: #0953b1;
  border-color: #0953b1;
}

body.dark-mode .btn-secondary {
  background-color: #343a40;
  border-color: #343a40;
  color: #f8f9fa;
}

body.dark-mode .btn-warning {
  background-color: #b98502;
  border-color: #b98502;
  color: #212529;
}

body.dark-mode .btn-outline-primary {
  color: #0d82ff;
  border-color: #0d82ff;
}

body.dark-mode .btn-outline-primary.active,
body.dark-mode .btn-outline-danger.active {
  background-color: #0d6efd;
  color: #fff;
  border-color: #0d6efd;
}

body.dark-mode .btn-outline-secondary {
  color: #adb5bd;
  border-color: #555;
}

body.dark-mode .btn-outline-secondary:hover {
  background-color: #333;
}

body.dark-mode .btn-outline-danger {
  color: #ff6b6b;
  border-color: #ff6b6b;
}

body.dark-mode .btn-outline-dark {
  color: #f8f9fa;
  border-color: #f8f9fa;
}

/* Forms & inputs */
body.dark-mode .form-control,
body.dark-mode .form-range,
body.dark-mode .form-select,
body.dark-mode input[type="color"],
body.dark-mode .form-control-color {
  background-color: #2c2c2c;
  color: #e0e0e0;
  border-color: #444;
}

body.dark-mode .form-control:focus,
body.dark-mode .form-select:focus {
  background-color: #303030;
  color: #ffffff;
  border-color: #0d6efd;
  box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

body.dark-mode .input-group-text {
  background-color: #2c2c2c;
  border-color: #444;
  color: #ddd;
}

/* Modal header/footer */
body.dark-mode .modal-header,
body.dark-mode .modal-footer {
  background-color: #222;
  border-color: #333;
}

/* Icons inside navbar/sidebar */
body.dark-mode .navbar i,
body.dark-mode .app-sidebar i {
  color: #e0e0e0;
}

/* Footer text */
body.dark-mode footer {
  color: #bbbbbb;
}

/* Scrollbar in dark mode */
body.dark-mode #viewer-wrap::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.15);
}

body.dark-mode #viewer-wrap::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.3);
}