/* ===================================
   GLOBAL RESET AND BASE STYLES
   =================================== */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  background-color: #f5f5f5;
  color: #333;
}

/* ===================================
   BUTTON COMPONENTS
   =================================== */

/* Base button styles */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  border: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
  white-space: nowrap;
  text-decoration: none;
  gap: 6px;
}

/* White buttons with border */
.btn-white {
  background-color: #fff;
  color: #333;
  border: 1px solid #ddd;
}

.btn-white:hover {
  background-color: #f5f5f5;
  border-color: #ccc;
}

/* Blue buttons */
.btn-blue {
  background-color: #4285f4;
  color: white;
  border: 1px solid #4285f4;
}

.btn-blue:hover {
  background-color: #3367d6;
  border-color: #3367d6;
}

/* Green buttons */
.btn-green {
  background-color: #34a853;
  color: white;
  border: 1px solid #34a853;
}

.btn-green:hover {
  background-color: #137333;
  border-color: #137333;
}

/* Button sizes */
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-lg {
  padding: 12px 20px;
  font-size: 16px;
}

/* Square buttons for icons */
.btn-square {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
  font-weight: 500;
  color: #555;
}

/* Full width buttons */
.btn-full {
  width: 100%;
  justify-content: center;
}

/* Primary action button (larger) */
.btn-primary-action {
  flex-grow: 2;
}

/* Secondary action button (smaller) */
.btn-secondary-action {
  flex-grow: 1;
}

/* Delete button special styles */
.btn-delete:hover {
  color: #d93025 !important;
  border-color: #d93025 !important;
  background-color: #fff !important;
}

/* Button icons */
.btn .icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.6;
  flex-shrink: 0;
}

/* General icon styles */
.icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.6;
  flex-shrink: 0;
}

/* ===================================
   TOP NAVIGATION BAR
   =================================== */

#controls {
  height: 60px;
  display: flex;
  background-color: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  padding: 0 20px;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  position: relative;
}

.left-section,
.right-section {
  display: flex;
  align-items: center;
  z-index: 2;
}

/* Center section with absolute positioning */
.center-section {
  display: flex;
  align-items: center;
  position: absolute;
  left: calc(50% + 110px);
  transform: translateX(-50%);
  top: 0;
  height: 100%;
  z-index: 1;
  gap: 10px;
}

.zoom-buttons {
  display: flex;
  align-items: center;
  gap: 2px;
}

/* Hidden file input */
#fileInput {
  width: 0.1px;
  height: 0.1px;
  opacity: 0;
  overflow: hidden;
  position: absolute;
  z-index: -1;
}

.file-name-display {
  margin-left: 15px;
  color: #666;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 250px;
}

#pageInput {
  width: 36px;
  text-align: center;
  height: 36px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-family: "Manrope", sans-serif;
  font-size: 14px;
  font-weight: 500;
  color: #555;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  transition: all 0.2s ease;
}

#pageInput:focus {
  outline: none;
  border-color: #4285f4;
}

#pageTotal {
  color: #555;
  font-size: 14px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.center-divider {
  height: 20px;
  width: 1px;
  background-color: #ddd;
  margin: 0 10px;
}

#zoomValue {
  min-width: 60px;
  text-align: center;
  font-size: 14px;
  font-weight: 500;
  color: #555;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* ===================================
   WORKSPACE LAYOUT
   =================================== */

#workspace {
  display: flex;
  height: calc(100vh - 60px);
}

/* ===================================
   SIDEBAR COMPONENT
   =================================== */

#sidebar {
  width: 220px;
  background-color: #fff;
  overflow-y: auto;
  padding: 32px;
  border-right: 1px solid #e0e0e0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

#sidebar canvas {
  width: 100%;
  height: auto;
  margin-bottom: 8px;
  border-radius: 8px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s;
  image-rendering: auto;
  backface-visibility: hidden;
  filter: none;
  transform: translateZ(0);
}

#sidebar canvas.selected {
  border-color: #4285f4;
  box-shadow: 0 0 10px rgba(66, 133, 244, 0.5);
  border-radius: 8px;
}

.sidebar-thumb-wrapper {
  position: relative;
  margin-bottom: 32px;
  width: 110px;
}

.sidebar-thumb-bg {
  background-color: transparent;
  padding: 0;
  border-radius: 8px;
}

.sidebar-page-number {
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  color: #555;
  font-size: 12px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===================================
   MAIN CONTENT AREA
   =================================== */

#main {
  flex: 1;
  overflow: auto;
  position: relative;
  background-color: #f5f5f5;
  padding: 20px;
}

/* ===================================
   TOOLBAR COMPONENT
   =================================== */

#toolbar {
  position: fixed;
  top: 72px;
  left: calc(50% + 110px);
  transform: translateX(-50%);
  z-index: 100;
  display: flex;
  backdrop-filter: blur(4px);
  border-radius: 8px;
  padding: 4px;
  background-color: rgba(255, 255, 255, 0.7);
  border: 1px solid #ddd;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
  gap: 4px;
}

.toolbar-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 16px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  transition: all 0.2s ease;
  white-space: nowrap;
  color: #333;
}

.toolbar-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

.toolbar-btn.active {
  background: #4285f4;
  color: white;
  box-shadow: 0 2px 8px rgba(66, 133, 244, 0.3);
}

.toolbar-btn.active:hover {
  background: #3367d6;
}

.toolbar-icon {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.6;
  flex-shrink: 0;
}

/* ===================================
   PDF CONTAINER AND PAGES
   =================================== */

#pdfContainer {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.pdf-page-wrapper {
  margin-bottom: 30px;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.05),
    0px 0px 20px 0px rgba(0, 0, 0, 0.07),
    -12px 20px 20px 0px rgba(0, 0, 0, 0.05),
    -7px 14px 10px 0px rgba(0, 0, 0, 0.07), -2px 3px 8px 0px rgba(0, 0, 0, 0.08);
}

.page-number {
  position: absolute;
  bottom: -20px;
  left: 50%;
  transform: translateX(-50%);
  color: #333;
  font-size: 14px;
  font-weight: 400;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  z-index: 2;
  background: transparent;
  padding: 2px 8px;
}

/* ===================================
   SELECTION AND LINK HIGHLIGHTS
   =================================== */

#selectionBox {
  position: absolute;
  border: 2px dashed #4285f4;
  background-color: rgba(66, 133, 244, 0.1);
  z-index: 2;
  pointer-events: none;
}

.link-highlight {
  position: absolute;
  background-color: rgba(66, 133, 244, 0.1);
  border: 2px solid #4285f4;
  pointer-events: none;
  z-index: 1;
}

.existing-link-highlight {
  position: absolute;
  background-color: rgba(66, 133, 244, 0.05);
  border: 1px dashed #4285f4;
  pointer-events: none;
  z-index: 1;
  opacity: 0.7;
}

/* Link type colors */
.link-email {
  border-color: #4caf50;
  background-color: rgba(76, 175, 80, 0.08);
}

.link-phone {
  border-color: #ff9800;
  background-color: rgba(255, 152, 0, 0.08);
}

.link-internal {
  border-color: #9c27b0;
  background-color: rgba(156, 39, 176, 0.08);
}

.link-external {
  border-color: #007bff;
  background-color: rgba(0, 123, 255, 0.08);
}

/* ===================================
   MODAL DIALOG
   =================================== */

#linkModal {
  display: none;
  position: absolute;
  background: white;
  width: 300px;
  border-radius: 8px;
  border: 1px solid #ddd;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.06);
  z-index: 1000;
  padding: 16px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #eee;
}

.modal-title {
  font-weight: 400;
  font-size: 16px;
}

.close-modal-btn {
  background: transparent;
  border: none;
  font-size: 24px;
  line-height: 1;
  color: #999;
  cursor: pointer;
  padding: 0;
  margin: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s;
}

.close-modal-btn:hover {
  color: #333;
}

/* Modal form radio groups */
.modal-radio-group {
  margin-bottom: 12px;
  transition: all 0.2s;
}

.modal-radio-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 400;
  transition: color 0.2s;
  cursor: pointer;
}

.modal-input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-family: "Manrope", sans-serif;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  transition: all 0.2s;
  margin-bottom: 0;
}

.modal-input:focus {
  outline: none;
  border-color: #4285f4;
}

.modal-input:disabled {
  background-color: #f0f0f0;
  color: #999;
  border-color: #ddd;
  cursor: not-allowed;
}

/* Radio button styles */
.modal-radio-group input[type="radio"] {
  margin-right: 8px;
  cursor: pointer;
}

.modal-radio-group:has(input:checked) label {
  color: #4285f4;
  font-weight: 500;
}

/* Modal actions */
.modal-actions {
  display: flex;
  flex-direction: row;
  gap: 8px;
  margin-top: 15px;
}

.save-btn {
  flex-grow: 1;
}

.delete-btn {
  transition: all 0.2s;
}

.delete-btn:hover {
  color: #d93025;
  border-color: #d93025;
}

/* ===================================
   TUTORIAL AND ONBOARDING
   =================================== */

/* Inline animation inside tutorial tooltip */
.tutorial-inline-animation {
  position: relative;
  border: 1px solid #e9ecef !important;
  background: #f8f9fa !important;
}

.tutorial-cursor {
  position: absolute;
  width: 20px;
  height: 20px;
  z-index: 3;
  opacity: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tutorial-selection-area {
  position: absolute;
  border: 2px dashed #4285f4;
  background: rgba(66, 133, 244, 0.1);
  opacity: 0;
  border-radius: 2px;
  pointer-events: none;
  box-sizing: border-box;
}

.tutorial-side-tooltip {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  cursor: pointer;
  user-select: none;
}

/* Compact tutorial tooltip styles */
.tutorial-compact-tooltip {
  max-width: 320px !important;
  min-width: 300px !important;
  padding: 12px 16px !important;
}

.tutorial-compact-tooltip h3 {
  font-size: 18px !important;
  margin-bottom: 8px !important;
}

.tutorial-compact-tooltip p {
  font-size: 13px !important;
  line-height: 1.3 !important;
  margin: 0 0 12px 0 !important;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tutorial-compact-tooltip .bottom-section {
  gap: 8px !important;
}

/* Tutorial element highlighting */
.tutorial-highlight {
  position: relative;
  z-index: 10000;
}

.tutorial-highlight::before {
  content: "";
  position: absolute;
  top: -8px;
  left: -8px;
  right: -8px;
  bottom: -8px;
  background: rgba(66, 133, 244, 0.2);
  border: 2px solid #4285f4;
  border-radius: 12px;
  animation: tutorialPulse 2s infinite;
  pointer-events: none;
}

@keyframes tutorialPulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.7;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.3;
  }
}

@keyframes tutorialFadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tutorial-tooltip.tutorial-animate {
  animation: tutorialFadeIn 0.4s ease-out;
}

/* ===================================
   PREVIEW MODE TOOLTIPS
   =================================== */

#previewTooltip {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
    Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif;
  pointer-events: none !important;
  user-select: none;
  white-space: normal !important;
}

#previewTooltip h3 {
  font-size: 16px !important;
  margin-bottom: 8px !important;
  font-weight: 600 !important;
}

#previewTooltip p {
  font-size: 13px !important;
  line-height: 1.3 !important;
  margin: 0 !important;
  white-space: normal !important;
  overflow: visible !important;
  text-overflow: initial !important;
}

/* ===================================
   UTILITY CLASSES
   =================================== */

/* Hide welcome message when PDF is loaded */
#pdfContainer:has(.pdf-page-wrapper) .welcome-message {
  display: none;
}
