@import url('./font.css');

/* --- shadcn / CSS Variables & Reset --- */
:root {
  --font-sans: 'Vazirmatn', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  
  --background: #f8fafc;
  --foreground: #0f172a;
  
  --card: #ffffff;
  --card-foreground: #0f172a;
  
  --popover: #ffffff;
  --popover-foreground: #0f172a;
  
  --primary: #0f172a;
  --primary-hover: #1e293b;
  --primary-foreground: #f8fafc;
  
  --secondary: #f1f5f9;
  --secondary-hover: #e2e8f0;
  --secondary-foreground: #0f172a;
  
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  
  --accent: #f8fafc;
  --accent-foreground: #0f172a;
  
  --destructive: #ef4444;
  --destructive-hover: #dc2626;
  --destructive-foreground: #f8fafc;
  
  --border: #e2e8f0;
  --input: #e2e8f0;
  --input-focus: #0f172a;
  --ring: #94a3b8;
  
  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
}

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

html, body {
  max-width: 100%;
  overflow-x: clip;
  direction: rtl;
  text-align: start;
  font-family: var(--font-sans);
  background-color: var(--background);
  color: var(--foreground);
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Safe area insets */
body {
  padding-top: env(safe-area-inset-top, 0);
  padding-bottom: env(safe-area-inset-bottom, 0);
  padding-inline-start: env(safe-area-inset-left, 0);
  padding-inline-end: env(safe-area-inset-right, 0);
}

/* --- Base Input & Button Ergonomics (Cross-Browser & iOS Zoom Prevention) --- */
input, select, textarea, button {
  font-family: inherit;
  font-size: 1rem; /* 16px to prevent iOS Safari auto-zoom */
}

@media (max-width: 767px) {
  input, select, textarea {
    font-size: 16px !important; /* Force minimum 16px on mobile viewports to prevent iOS Safari viewport auto-zoom */
  }
}

input[type="text"],
input[type="number"],
input[type="tel"],
input[type="date"],
select {
  width: 100%;
  min-height: 44px;
  padding: 0.5rem 0.875rem;
  padding-inline: 0.875rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--input);
  background-color: #ffffff;
  color: var(--foreground);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
  box-sizing: border-box;
}

textarea {
  width: 100%;
  min-height: 88px;
  padding: 0.75rem 1.125rem !important;
  padding-inline-start: 1.125rem !important;
  padding-inline-end: 1.125rem !important;
  padding-block: 0.75rem !important;
  line-height: 1.8 !important;
  font-family: inherit;
  font-size: 0.875rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--input);
  background-color: #ffffff;
  color: var(--foreground);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
  resize: vertical;
  box-sizing: border-box;
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 0.75rem center;
  background-size: 1rem 1rem;
  padding-inline-start: 0.75rem;
  padding-inline-end: 2.25rem;
  padding-left: 2.25rem;
  padding-right: 0.75rem;
  cursor: pointer;
}

select.mini-select,
.mini-select {
  width: auto !important;
  min-height: 24px !important;
  height: 24px !important;
  padding-block: 0 !important;
  padding-inline-start: 0.5rem !important;
  padding-inline-end: 1.25rem !important;
  font-size: 0.6875rem !important;
  border-radius: var(--radius-sm) !important;
  background-position: left 0.35rem center !important;
  background-size: 0.75rem 0.75rem !important;
  line-height: 1.2 !important;
  display: inline-block !important;
  border: 1px solid var(--border) !important;
  background-color: #ffffff !important;
  color: var(--foreground) !important;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--input-focus);
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.1);
}

/* --- Buttons in shadcn Style --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 44px;
  padding-inline: 1rem;
  padding-block: 0.5rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  user-select: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--primary);
  color: var(--primary-foreground);
}
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover {
    background-color: var(--primary-hover);
  }
}

.btn-secondary {
  background-color: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border);
}
@media (hover: hover) and (pointer: fine) {
  .btn-secondary:hover {
    background-color: var(--secondary-hover);
  }
}

.btn-outline {
  background-color: transparent;
  color: var(--foreground);
  border-color: var(--border);
}
@media (hover: hover) and (pointer: fine) {
  .btn-outline:hover {
    background-color: var(--secondary);
  }
}

.btn-destructive {
  background-color: transparent;
  color: var(--destructive);
  border-color: rgba(239, 68, 68, 0.2);
}
@media (hover: hover) and (pointer: fine) {
  .btn-destructive:hover {
    background-color: rgba(239, 68, 68, 0.08);
    border-color: var(--destructive);
  }
}

.btn-sm {
  min-height: 36px;
  padding-inline: 0.75rem;
  padding-block: 0.375rem;
  font-size: 0.8125rem;
}

.btn-icon {
  min-width: 44px;
  padding-inline: 0.5rem;
}

/* --- Cards and Containers --- */
.shadcn-card {
  background-color: var(--card);
  color: var(--card-foreground);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
}

/* --- shadcn Accordion --- */
.accordion-item {
  background-color: var(--card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04), 0 1px 2px -1px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: start;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--foreground);
  transition: background-color 0.15s ease;
  user-select: none;
}

@media (hover: hover) and (pointer: fine) {
  .accordion-trigger:hover {
    background-color: rgba(241, 245, 249, 0.6);
  }
}

.accordion-chevron {
  width: 1.125rem;
  height: 1.125rem;
  color: var(--muted-foreground);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  flex-shrink: 0;
}

.accordion-item.is-open .accordion-chevron {
  transform: rotate(180deg);
}

.accordion-content {
  padding: 0 1.25rem 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.accordion-item:not(.is-open) .accordion-content {
  display: none;
}

.shadcn-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 9999px;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

.badge-neutral {
  background-color: var(--secondary);
  color: var(--muted-foreground);
  border: 1px solid var(--border);
}

.badge-success {
  background-color: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

/* --- Form Groups & Typography --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.form-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: #334155;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.form-hint {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

/* --- Paper Sheet (Invoice Print Simulation) --- */
.paper-container {
  width: 100%;
  display: block;
  padding-block: 0.5rem;
}

@media (min-width: 1024px) {
  .paper-container {
    display: block !important;
    position: sticky !important;
    top: 5rem; /* Exactly below header (h-16 = 4rem + 1rem buffer) */
    align-self: start;
    max-height: calc(100dvh - 5.75rem);
    overflow-y: auto;
    overflow-x: hidden;
    padding-inline: 0;
    padding-block: 0.25rem 2rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(148, 163, 184, 0.4) transparent;
  }

  .paper-container::-webkit-scrollbar {
    width: 6px;
  }

  .paper-container::-webkit-scrollbar-track {
    background: transparent;
  }

  .paper-container::-webkit-scrollbar-thumb {
    background-color: rgba(148, 163, 184, 0.35);
    border-radius: 9999px;
  }

  .paper-container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(148, 163, 184, 0.6);
  }
}

.invoice-paper {
  background-color: #ffffff;
  color: #0f172a;
  width: 100%;
  max-width: 100%; /* WIDE BY DEFAULT: expands to fill full available preview width */
  margin-inline: 0;
  min-height: auto;
  height: auto !important;
  box-sizing: border-box;
  padding: clamp(1.25rem, 2.5vw, 2.75rem);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border);
  box-shadow: 0 10px 30px -5px rgba(0, 0, 0, 0.06), 0 8px 12px -6px rgba(0, 0, 0, 0.03);
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: max-width 0.25s cubic-bezier(0.4, 0, 0.2, 1), margin 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@media (min-width: 1024px) {
  .invoice-paper {
    min-height: clamp(680px, 82dvh, 1050px);
    height: auto !important;
  }
}

/* Optional Boxed Mode if toggled by user */
.invoice-paper.mode-boxed {
  max-width: 860px !important;
  margin-inline: auto !important;
}

/* Styling applied strictly during direct PDF export */
#pdf-render-sandbox {
  position: fixed !important;
  top: 0 !important;
  left: -9999px !important;
  width: 794px !important;
  min-width: 794px !important;
  max-width: 794px !important;
  margin: 0 !important;
  padding: 0 !important;
  border: none !important;
  outline: none !important;
  background-color: #ffffff !important;
  z-index: -99999 !important;
  opacity: 1 !important;
  visibility: visible !important;
  overflow: visible !important;
  direction: rtl !important;
  text-align: start !important;
  pointer-events: none !important;
}

.invoice-paper.pdf-exporting {
  width: 794px !important;
  min-width: 794px !important;
  max-width: 794px !important;
  min-height: auto !important;
  height: auto !important;
  box-sizing: border-box !important;
  padding: 28px 32px !important;
  margin: 0 !important;
  box-shadow: none !important;
  border: none !important;
  outline: none !important;
  border-radius: 0 !important;
  background-color: #ffffff !important;
  letter-spacing: normal !important;
  direction: rtl !important;
  text-align: start !important;
  transition: none !important;
  animation: none !important;
  overflow: visible !important;
}

.invoice-paper.pdf-exporting * {
  letter-spacing: normal !important;
  text-rendering: geometricPrecision !important;
  transition: none !important;
  animation: none !important;
}

/* Ensure consistent desktop A4 layout in PDF regardless of device viewport */
.invoice-paper.pdf-exporting .invoice-header-border {
  display: flex !important;
  flex-direction: row !important;
  align-items: center !important;
  justify-content: space-between !important;
  gap: 1rem !important;
}

.invoice-paper.pdf-exporting .invoice-header-border > div:last-child {
  min-width: 210px !important;
  align-self: auto !important;
}

.invoice-paper.pdf-exporting .grid.sm\:grid-cols-2,
.invoice-paper.pdf-exporting .grid.grid-cols-1.sm\:grid-cols-2 {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
  gap: 0.875rem !important;
}

.invoice-paper.pdf-exporting .grid.md\:grid-cols-12,
.invoice-paper.pdf-exporting .grid.grid-cols-1.md\:grid-cols-12 {
  display: grid !important;
  grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
  gap: 1rem !important;
}

.invoice-paper.pdf-exporting .order-2.md\:order-1.md\:col-span-7 {
  order: 1 !important;
  grid-column: span 7 / span 7 !important;
}

.invoice-paper.pdf-exporting .order-1.md\:order-2.md\:col-span-5 {
  order: 2 !important;
  grid-column: span 5 / span 5 !important;
}

.invoice-paper.pdf-exporting .invoice-table-wrapper {
  overflow: visible !important;
  width: 100% !important;
  margin-block: 1rem !important;
  box-shadow: none !important;
}

.invoice-paper.pdf-exporting .invoice-table {
  width: 100% !important;
  min-width: 100% !important;
  table-layout: auto !important;
}

.invoice-paper.pdf-exporting .invoice-table td,
.invoice-paper.pdf-exporting .invoice-table th {
  padding: 8px 12px !important;
}

.invoice-paper.pdf-exporting .invoice-table td:last-child,
.invoice-paper.pdf-exporting .invoice-table th:last-child {
  padding-inline-end: 18px !important;
}

.invoice-paper.pdf-exporting .grand-total span {
  white-space: nowrap !important;
}

/* Invoice Header */
.invoice-header-border {
  border-bottom: 2px solid #0f172a;
  padding-bottom: 1.25rem;
}

/* --- Modern shadcn Invoice Table with Clean Grid Architecture --- */
.invoice-table-wrapper {
  width: 100%;
  border-radius: var(--radius-lg);
  border: 1px solid #cbd5e1;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  margin-block: 1.25rem;
  background-color: #ffffff;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
}

.invoice-table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 0.8125rem;
  text-align: start;
}

.invoice-table thead {
  background-color: #f1f5f9;
  border-bottom: 2px solid #cbd5e1;
}

.invoice-table th {
  background-color: #f1f5f9;
  color: #1e293b;
  font-weight: 700;
  text-align: start;
  padding: 0.75rem 0.875rem;
  font-size: 0.8125rem;
  white-space: nowrap;
  letter-spacing: normal !important;
  border-inline-end: 1px solid #cbd5e1;
}

.invoice-table th:last-child {
  border-inline-end: none;
}

.invoice-table td {
  padding: 0.75rem 0.875rem;
  border-bottom: 1px solid #e2e8f0;
  border-inline-end: 1px solid #e2e8f0;
  vertical-align: middle;
  color: #334155;
  background-color: #ffffff;
}

.invoice-table td:last-child {
  border-inline-end: none;
}

.invoice-table td:not(:nth-child(2)) {
  white-space: nowrap;
}

.invoice-table tbody tr:last-child td {
  border-bottom: none;
}

.invoice-table tbody tr:nth-child(even) td {
  background-color: #f8fafc;
}

.invoice-table tbody tr:hover td {
  background-color: #f1f5f9;
}

/* Invoice Totals Box */
.invoice-totals {
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  background-color: #f8fafc;
  padding: 1rem;
  font-size: 0.875rem;
}

.invoice-totals-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-block: 0.35rem;
  color: #475569;
}

.invoice-totals-row.grand-total {
  border-top: 2px dashed #cbd5e1;
  margin-top: 0.5rem;
  padding-top: 0.75rem;
  font-weight: 700;
  font-size: 1.125rem;
  color: #0f172a;
}

.invoice-totals-row.grand-total > span:first-child {
  white-space: nowrap;
}

/* Logo container */
.seller-logo-box {
  max-width: 110px;
  max-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.seller-logo-box img {
  max-width: 100%;
  max-height: 80px;
  object-fit: contain;
}

/* --- Drag and Drop Logo Upload Zone & Resume Card --- */
.logo-dropzone {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.logo-dropzone:hover {
  border-color: #94a3b8;
  background-color: #f1f5f9;
}

.logo-dropzone.is-dragover {
  border-color: #0f172a !important;
  background-color: #e2e8f0 !important;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.12) !important;
  transform: scale(1.015);
}

.logo-preview-card {
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.logo-preview-card.is-dragover {
  border-color: #0f172a !important;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.12) !important;
  transform: scale(1.015);
}

/* Number in words box */
.words-box {
  background-color: #f1f5f9;
  border-inline-start: 4px solid #0f172a;
  padding: 0.625rem 0.875rem;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 500;
  color: #334155;
}

/* Notes & Payment Info Boxes */
.invoice-meta-box {
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  background-color: rgba(248, 250, 252, 0.85);
  padding: 0.75rem 1rem;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.02);
}

.invoice-meta-box .title {
  font-weight: 700;
  color: #1e293b;
  display: block;
  margin-bottom: 0.35rem;
  font-size: 0.8125rem;
}

/* Signatures */
.signature-box {
  border: 1px dashed #cbd5e1;
  border-radius: var(--radius-md);
  height: 90px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  font-size: 0.75rem;
  color: #64748b;
}

/* --- Tabs on Mobile --- */
.view-tabs {
  display: flex;
  background-color: #e2e8f0;
  padding: 0.25rem;
  border-radius: var(--radius-lg);
  gap: 0.25rem;
  margin-bottom: 1rem;
}

.view-tab-btn {
  flex: 1;
  min-height: 44px;
  border-radius: var(--radius-md);
  font-size: clamp(0.75rem, 2.5vw, 0.875rem);
  font-weight: 600;
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.view-tab-btn.active {
  background-color: #ffffff;
  color: #0f172a;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* --- Mobile Bottom Action Bar --- */
#mobile-bottom-bar {
  padding-bottom: max(0.5rem, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.08), 0 -1px 3px rgba(0, 0, 0, 0.04);
}

@supports not (backdrop-filter: blur(12px)) {
  #mobile-bottom-bar {
    background-color: #ffffff;
  }
}

/* Responsive grid for desktop vs mobile */
.app-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
}

@media (max-width: 1023px) {
  .editor-sidebar.hidden {
    display: none !important;
  }
  .paper-container.hidden {
    display: none !important;
  }
}

@media (min-width: 1024px) {
  .editor-sidebar {
    display: block !important;
  }
  .paper-container {
    display: block !important;
  }
  .app-layout {
    grid-template-columns: 380px 1fr;
    align-items: start;
    gap: 1.25rem;
  }
}

@media (min-width: 1280px) {
  .app-layout {
    grid-template-columns: 420px 1fr;
    gap: 1.5rem;
  }
}

@media (min-width: 1536px) {
  .app-layout {
    grid-template-columns: 450px 1fr;
    gap: 1.75rem;
  }
}

@media (min-width: 1920px) {
  .app-layout {
    grid-template-columns: 480px 1fr;
    gap: 2rem;
  }
}

/* Ultra-small screens (< 360px e.g. Galaxy Fold folded) */
@media (max-width: 359px) {
  .signature-box {
    height: 75px;
    font-size: 0.7rem;
    padding: 0.35rem;
  }
  .invoice-totals {
    padding: 0.75rem;
    font-size: 0.8125rem;
  }
}

/* --- Print Styles (@media print) --- */
@page {
  size: A4 portrait;
  margin: 10mm;
}

@media print {
  html, body {
    background-color: #ffffff !important;
    color: #000000 !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    height: auto !important;
    min-height: auto !important;
    overflow: visible !important;
  }

  /* Hide app chrome, editor panels, buttons, headers, mobile bar */
  .no-print,
  .app-header,
  .editor-sidebar,
  .editor-sidebar.hidden,
  .view-tabs,
  #mobile-bottom-bar,
  .toast-container,
  #btn-scroll-top,
  #global-tooltip {
    display: none !important;
  }

  #main-container,
  main {
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .app-layout {
    display: block !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .paper-container,
  .paper-container.hidden,
  #preview-panel {
    padding: 0 !important;
    margin: 0 !important;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: static !important;
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    width: 100% !important;
  }

  .invoice-paper,
  .invoice-paper.mode-boxed {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    max-width: 100% !important;
    min-height: auto !important;
    height: auto !important;
    width: 100% !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background-color: #ffffff !important;
    overflow: visible !important;
  }

  .invoice-table-wrapper {
    border: 1px solid #cbd5e1 !important;
    border-radius: 4px !important;
    overflow: hidden !important;
    box-shadow: none !important;
  }

  .invoice-table th {
    background-color: #f1f5f9 !important;
    color: #000000 !important;
    border-bottom: 2px solid #cbd5e1 !important;
    border-inline-end: 1px solid #cbd5e1 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .invoice-table td {
    border-bottom: 1px solid #e2e8f0 !important;
    border-inline-end: 1px solid #e2e8f0 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .invoice-totals {
    background-color: #f8fafc !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .words-box {
    background-color: #f1f5f9 !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  tr, .signature-box, .invoice-totals {
    page-break-inside: avoid;
    break-inside: avoid;
  }
}

/* --- Global Floating Tooltip (shadcn style) --- */
#global-tooltip {
  position: fixed;
  z-index: 99999;
  pointer-events: none;
  padding: 0.35rem 0.65rem;
  border-radius: var(--radius-md);
  background-color: #0f172a;
  color: #f8fafc;
  font-size: 0.75rem;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.18), 0 2px 4px rgba(0, 0, 0, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.12);
  transition: opacity 0.12s ease-out, transform 0.12s ease-out;
  opacity: 0;
  transform: scale(0.95);
  font-family: var(--font-sans);
  direction: rtl;
}

#global-tooltip.is-visible {
  opacity: 1;
  transform: scale(1);
}
