.tm-head-box { padding: 10px 8px; background: var(--bg-secondary); border: 1px solid var(--border-primary); border-radius: 4px; }
.tm-head-box .tm-section-label { margin-bottom: 8px; }
.tm-head-row { display: grid; grid-template-columns: 1fr; gap: 8px; }
.tm-head-row .tm-input { width: 140px; text-transform: uppercase; }
/*
  Balloonist app styles
  - Variables: :root color/size tokens
  - Global resets and app container
  - Header/menu
  - Toolbars (left tool bar, top bar)
  - Settings panel + Accordion sections
  - Inputs (shared input styles)
  - Layout containers (auth/container/canvas)
  - PDF container (scrollbars)
  - Data table (Tabulator)
  - File drag/drop area
  - Tooltips
  - Loading overlay


*/

/* Self-hosted fonts: Plus Jakarta Sans 600/700; remove Google Fonts imports */
/* Using specific latin 600 and 700 normal weights copied to src/vendor/fonts */
@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../vendor/fonts/plus-jakarta-sans-latin-600-normal.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../vendor/fonts/plus-jakarta-sans-latin-700-normal.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Plus Jakarta Sans";
  src: url("../vendor/fonts/plus-jakarta-sans-latin-400-normal.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "MyDimFont";
  src: url("../public/fonts/Y14.5-2018.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

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

*:focus {
  outline: none;
}

:root {
  --tw-bg-opacity: 1;
  /* Original variables */
  --c1: #40444b;
  --c2: #2f3136;
  --c3: rgb(249 250 251 / var(--tw-bg-opacity));
  --color1: #3eb1ff;
  --color2: #ffc659;
  --color3: hsl(180, 50%, 50%);
  --color4: hsl(180, 100%, 50%);
  
  /* New color variables */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f5;
  --bg-tertiary: #f0f0f0;
  --text-primary: #262626;
  --text-secondary: #4d4d4d;
  --text-tertiary: #666666;
  --border-primary: #e5e7eb;
  --border-secondary: #d1d5db;
  --tooltip-bg: rgba(51, 51, 51, 0.75);
  --purple-primary: #9966CC;

  /* Size variables */
  --tool-icon-size: 24px;
  --input-height: 28px;
  --input-radius: 1px;
}

/*--------------- MAIN PAGE STRUCTURE --------------*/
/* App-level container and info popup styles */
.App {
  background-color: #2f3136;
  font-family: "Plus Jakarta Sans", sans-serif;
}

/* Info Icon and Popup Styles */
.info-icon {
  display: flex;
  align-items: center;
  cursor: pointer;
  font-size: 14px;
  padding: 1em 0.5em;
  position: relative;
  color: #888888;
  transition: color 0.2s;
  height: 100%;
}

.info-icon-text {
  margin-right: 6px;
  font-size: 13px;
  line-height: 1;
}

.info-icon-letter {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: var(--c2);
  color: white;
  font-weight: bold;
  font-size: 12px;
}

.info-icon:hover {
  color: var(--color2);
}

.info-icon:hover .info-icon-letter {
  background-color: var(--color2);
}

.info-popup {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 700px;
  background-color: white;
  border: 1px solid var(--border-secondary);
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 16px;
  z-index: 9999;
  text-align: left;
}

.info-popup h3 {
  margin-bottom: 10px;
  color: var(--text-primary);
  font-size: 16px;
}

.info-popup ul {
  list-style-type: disc;
  padding-left: 20px;
}

.info-popup li {
  margin-bottom: 8px;
  font-size: 14px;
  color: var(--text-secondary);
}



.content {
  background-color: var(--c3);
  width: 100%;
  height: 100%;
  overflow: auto;
}

/*
.container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}
*/

/*--------------- TOP MENU --------------*/
/* Fixed horizontal header with nav links */

.menu {
  list-style: none;
  background-color: var(--bg-primary);
  z-index: 9000;
  position: fixed;
  top: 0;
  width: 100%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}


.menu-item {
  float: left;
}

.menu-link {
  text-decoration: none;
  display: block;
  padding: 1em 1.2em;
  font-size: 0.9em;
  color: var(--text-primary);
  font-weight: 600;
  transition: all 0.2s ease;
}

.menu-link:hover {
  background-color: var(--bg-secondary);
  color: var(--color2);
}

.logo {
  color: var(--text-primary);
  font-weight: 700;
  float: left;
  text-decoration: none;
  display: block;
  padding: 1em 1.2em;
  font-size: 0.95em;
}

/*--------------- Dropdown Menus --------------*/
.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-content {
  display: none;
  position: absolute;
  background-color: var(--bg-primary);
  min-width: 220px;
  max-width: 280px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 1500;
  border: 1px solid var(--border-secondary);
  border-radius: 4px;
  top: 100%;
  right: 0;
}

.dropdown-content a {
  color: var(--text-primary);
  padding: 8px 12px;
  text-decoration: none;
  display: block;
  font-size: 0.75em;
  font-weight: 600;
  transition: all 0.2s ease;
}

.dropdown-content a:hover {
  background-color: var(--bg-secondary);
  color: var(--color2);
}

.dropdown:hover .dropdown-content {
  display: block;
}

.dropdown-divider {
  border-top: 1px solid var(--border-secondary);
  margin: 2px 0;
}

.dropdown-setting {
  padding: 4px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dropdown-setting label {
  font-size: 0.75em;
  color: var(--text-primary);
  white-space: nowrap;
  min-width: 80px;
  flex-shrink: 0;
  font-weight: 600;
}

.dropdown-input {
  flex: 1;
  font-size: 0.75em;
  padding: 2px 4px;
  border: 1px solid var(--border-secondary);
  border-radius: 3px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-width: 0;
}

.autosave-status-dropdown {
  flex: 1;
  font-size: 0.75em;
  font-weight: 500;
  text-align: right;
  padding: 2px 6px;
  border-radius: 3px;
  text-transform: uppercase;
}

.autosave-status-dropdown.active {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.autosave-status-dropdown.inactive {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

/*--------------- Tool Bar --------------*/
/* Left vertical toolbar with tool icons */

.tool_bar {
  display: flex;
  width: 52px;
  background-color: var(--bg-primary);
  z-index: 1001;
  border: 2px solid var(--border-secondary);
  flex-wrap: wrap;
  justify-content: center;
  align-content: flex-start;
  position: fixed;
  margin-left: 2px;
  margin-top: 50px;
  border-radius: 0px;
  padding: 1px 0;
  /* box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); */
}

.tool_bar.hidden {
  display: none;
}

.tool {
  width: 48px; /* Match parent width */
  height: 48px;
  margin: 0px 0;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.tool:hover {
  background-color: var(--bg-secondary);
}

.tool.selected {
  background-color: var(--bg-tertiary);
  border: none;
  color: var(--color2);
}

.tool svg {
  width: var(--tool-icon-size);
  height: var(--tool-icon-size);
  fill: var(--text-secondary);
  transition: all 0.2s ease;
}

.tool:hover svg {
  fill: var(--color2);
}

.tool.selected svg {
  fill: var(--color2);
}

/*--------------- Top Bar --------------*/
/* Horizontal settings bar under the header */

.top_bar {
  display: flex;
  height: min-content;
  background-color: var(--bg-primary);
  z-index: 1000;
  border: 2px solid var(--border-primary);
  /* box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); */
  flex-wrap: nowrap;
  justify-content: flex-start;
  position: fixed;
  border-radius: 0px;
  padding: 6px 12px;
  gap: 12px;
  margin-left: 54px;
  margin-top: 50px;
  max-width: calc(100% - 96px);
}

.top_bar.hidden {
  display: none;
}

/* Add styles for grouped settings */
.top_bar_group {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-right: 12px;
  border-right: 1px solid var(--border-primary);
}

.rotation-select {
  width: 80px;
  height: var(--input-height);
  padding: 2px 6px;
  border: 1px solid var(--border-primary);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-primary);
  transition: all 0.2s ease;
  background-color: var(--bg-primary);
}

.rotation-select:hover {
  border-color: var(--border-secondary);
}

.rotation-select:focus {
  border-color: var(--color2);
  box-shadow: 0 0 0 2px rgba(255, 198, 89, 0.1);
}

/* Remove border from last top_bar_group before page-zoom-group */
.top_bar_group:last-of-type:not(:last-child) {
  border-right: none;
}


.top_bar_items {
  display: flex;
  flex-direction: row;
  gap: 12px;
  width: auto;
  align-items: center;
}

.top-bar-label {
  color: var(--text-primary);
  font-size: 13px; /* Increased from 11px */
  font-weight: 600;
  padding: 2px 6px 2px 0;
  text-align: left;
  white-space: nowrap;
  min-width: auto;
}

.top_bar_setting {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: fit-content;
}

/* Add divider between main settings and page/zoom */
.page-zoom-group {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-left: auto;
  padding-left: 12px;
  border-left: 1px solid var(--border-primary);
}



/*--------------- Context-sensitive top bar --------------*/

/* Hide tool-specific groups by default */
#tool-bar-settings .top_bar_group[data-tool-group]:not([data-tool-group="nav"]) {
  display: none;
}

/* Show balloon group for balloon and auto tools */
#tool-bar-settings[data-active-tool="balloon"] .top_bar_group[data-tool-group="balloon"],
#tool-bar-settings[data-active-tool="auto"] .top_bar_group[data-tool-group="balloon"] {
  display: flex;
}

/* Show text group for text tool */
#tool-bar-settings[data-active-tool="text"] .top_bar_group[data-tool-group="text"] {
  display: flex;
}

/* Show drawrect group for drawrect tool */
#tool-bar-settings[data-active-tool="drawrect"] .top_bar_group[data-tool-group="drawrect"] {
  display: flex;
}

/* Show text and drawrect groups when select tool is active */
#tool-bar-settings[data-active-tool="select"] .top_bar_group[data-tool-group="text"],
#tool-bar-settings[data-active-tool="select"] .top_bar_group[data-tool-group="drawrect"] {
  display: flex;
}

/*--------------- Settings --------------*/
/* Right side settings panel (draggable) */

.settings {
  display: flex;
  background-color: var(--bg-primary);
  z-index: 999;
  border: 2px solid var(--border-secondary);
  flex-wrap: wrap;
  justify-content: flex-start;
  position: fixed;
  border-radius: 0px;
  margin-top: 100px;
  right: 2px;
  width: 300px; /* Increased width to accommodate wider inputs */
  max-height: 520px; /* Slightly increased height */
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 0;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.settings.hidden {
  display: none;
}

.settings_items {
  display: flex;
  flex-direction: column;
  width: 100%;
  padding: 0;
  margin: 0;
}
/* Updated scrollbar to be hidden but allow scrolling */
.settings::-webkit-scrollbar {
  width: 0px; /* Hide scrollbar */
  background: transparent;
}

.settings::-webkit-scrollbar-track {
  background: transparent;
}

.settings::-webkit-scrollbar-thumb {
  background: transparent;
}

.settings::-webkit-scrollbar-thumb:hover {
  background: transparent;
}



/*--------------- ACCORDION SECTIONS --------------*/
/* Collapsible settings sections with compact layout */
/* Settings within sections - COMPACT LAYOUT */
.settings_setting {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 4px; /* Reduced from 12px */
  padding: 0; /* Removed vertical padding */
}

.settings_setting:last-child {
  margin-bottom: 0;
}

/* Label styling */
.settings-label {
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  padding: 0;
  text-align: left;
  justify-self: start;
  line-height: 1.3;
  max-width: 120px;
}

/* Input styling adjustments - UNIFORM WIDTHS */
.settings-section .number-input,
.settings-section select,
.settings-section input[type="text"],
.settings-section input[type="number"] {
  width: 120px; /* Uniform width for all inputs */
  height: var(--input-height);
  padding: 6px 10px;
  font-size: 12px;
  justify-self: end;
  border: 1px solid var(--border-primary);
  border-radius: var(--input-radius);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: all 0.2s ease;
  box-sizing: border-box;
}

/* Number inputs - keep right alignment */
.settings-section input[type="number"] {
  text-align: right;
}

/* Hover states */
.settings-section .number-input:hover,
.settings-section select:hover,
.settings-section input[type="text"]:hover,
.settings-section input[type="number"]:hover {
  border-color: var(--border-secondary);
  background-color: var(--bg-secondary);
}

/* Focus states */
.settings-section .number-input:focus,
.settings-section select:focus,
.settings-section input[type="text"]:focus,
.settings-section input[type="number"]:focus {
  border-color: var(--color2);
  background-color: var(--bg-primary);
  box-shadow: 0 0 0 2px rgba(255, 198, 89, 0.15);
  outline: none;
  transform: translateY(-1px);
}

/* Select dropdown styling */
.settings-section select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 9l3-3H3z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  background-size: 12px;
  padding-right: 28px;
}

.settings-section select:hover {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 9l3-3H3z'/%3E%3C/svg%3E");
}

/* Tooltip styling - more compact */
.settings_setting .tool_tip_text {
  grid-column: 1 / -1;
  margin-top: 2px; /* Reduced from 6px */
  font-size: 11px;
  color: var(--text-secondary);
  line-height: 1.3;
  padding: 2px 0; /* Reduced padding */
  border-left: 2px solid var(--border-primary);
  padding-left: 8px;
}

/* Section content - reduced padding */
.settings-section-content {
  padding: 12px 16px; /* Reduced vertical padding */
  background: var(--bg-primary);
  overflow: visible; /* allow content to define height; scrolling handled by .settings */
  transition: max-height 0.3s ease, padding 0.3s ease;
  max-height: none; /* no artificial cap to avoid clipping last rows */
}

.settings-section-content.collapsed {
  max-height: 0;
  padding: 0 16px;
  overflow: hidden;
}

/* Section titles - keep existing padding */
.settings-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 10px;
  background: var(--bg-secondary);
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-primary);
  transition: all 0.2s ease;
  user-select: none;
  border: none;
  margin: 0;
}

.settings-section-title:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.settings-section-title:hover .accordion-arrow {
  color: var(--text-primary);
}

/* Accordion arrow */
.accordion-arrow {
  font-size: 11px;
  transition: all 0.3s ease;
  color: var(--text-secondary);
  font-weight: bold;
}

.settings-section.collapsed .accordion-arrow {
  transform: rotate(-90deg);
}

/* Section borders */
.settings-section {
  border-bottom: 1px solid var(--border-primary);
  margin: 0;
  background: var(--bg-primary);
}

.settings-section:last-child {
  border-bottom: none;
}

/* Disabled state styling */
.settings-section input:disabled,
.settings-section select:disabled {
  background-color: var(--bg-secondary);
  color: var(--text-tertiary);
  cursor: not-allowed;
  opacity: 0.7;
}


.settings-section-content .gdt-symbols-table {
  width: 100%;
  border-collapse: collapse;
}
.settings-section-content .gdt-symbols-table thead th {
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-primary);
}
.settings-section-content .gdt-symbols-table td {
  padding: 2px 4px; /* tightened */
  border-bottom: 1px solid var(--border-primary);
  vertical-align: middle;
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
}
/* Center Character and Symbol inputs */
.settings-section-content .gdt-symbols-table td:nth-child(2),
.settings-section-content .gdt-symbols-table td:nth-child(3) {
  text-align: center;
}
/* Hide Character column (2nd) in settings GD&T table so only Name + Symbol + Copy remain */
#gdt-symbols-settings .gdt-symbols-table thead th:nth-child(2),
#gdt-symbols-settings .gdt-symbols-table tbody td:nth-child(2) {
  display: none !important;
}

/* Hide the header row for the GD&T table in Settings */
#gdt-symbols-settings .gdt-symbols-table thead {
  display: none !important;
}
/* Inputs sizing */
.gdt-input-char,
.gdt-input-symbol {
  width: 54px !important; /* override .number-input width */
  height: 22px; /* tighter */
  padding: 1px 4px; /* tighter */
  text-align: center;
}
.gdt-input-symbol {
  font-family: "MyDimFont","Segoe UI Symbol","Noto Sans Symbols",Arial,sans-serif !important;
  font-size: 16px !important;
  letter-spacing: 0.02em;
}

/* Copy button next to inputs */
.copy-btn {
  margin-left: 6px;
  padding: 6px 6px; /* tighter */
  font-size: 12px;
  line-height: 1;
  border: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border-radius: 2px;
  cursor: pointer;
}
.copy-btn:hover {
  color: var(--text-primary);
  border-color: var(--border-secondary);
}

/* Filter bar above GD&T table */
.gdt-filter-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 8px;
}
.gdt-filter-bar .number-input {
  width: 100% !important;;
  height: 24px;
  font-size: 12px;
}
.gdt-filter-bar .copy-btn {
  height: 24px;
}

/*--------------- INPUTS --------------*/
/* Shared input styles used across toolbars and settings */

.number-input {
  width: 80px;
  height: 26px; /* Reduced height */
  padding: 2px 6px; /* Reduced padding */
  border: 1px solid var(--border-primary);
  border-radius: 1px;
  font-size: 13px; /* Increased from 11px to match labels */
  color: var(--text-primary);
  transition: all 0.2s ease;
}

.number-input:hover {
  border-color: var(--border-secondary);
}

.number-input:focus {
  border-color: var(--color2);
  box-shadow: 0 0 0 2px rgba(255, 198, 89, 0.1);
}

.page-number-input {
  width: 80px;
  height: 26px; /* Reduced height */
  padding: 5px;
  outline: none;
  border: 1px solid var(--border-primary);
  border-radius: 1px;
  display: inline-block;
  text-align: left;
  align-items: center;
  font-size: 13px; /* Increased from 12px to match other inputs */
}

.page-number-input:hover {
  border-color: var(--border-secondary);
}

.page-number-input:focus {
  border-color: var(--color2);
  box-shadow: 0 0 0 2px rgba(255, 198, 89, 0.1);
}

/*--------------- HIDE LABELS --------------*/
/* Utility rules for hiding native inputs (file picker) */

#pdf-upload {
  display: none;
}

/*--------------- CONTAINER(S) --------------*/
/* Auth and central canvas containers */

.container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -30%);
  display: flex;
}

.auth_container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -30%);
  display: flex;
  flex-direction: column;
  align-items: center;
  background-color: var(--bg-primary);
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

#auth-view-pur p {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  margin-bottom: 1rem;
  text-align: center;
}

#auth-view-pur a {
  color: var(--color1);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.2s ease;
}

#auth-view-pur a:hover {
  color: var(--color1);
}

canvas,
.canvas-container {
  margin-bottom: auto;
}

.canvas-container {
  margin: 20px auto;
  z-index: 900;
  display: none;
  border: 3px solid var(--border-primary);
  position: relative;
  background-color: white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  overflow: auto;
  padding: 0;
  box-sizing: border-box;
  width: fit-content;
  height: fit-content;  
}

.canvas-container .upper-canvas,
.canvas-container .lower-canvas {
  position: absolute;
  left: 0;
  top: 0;
}



/*--------------- PDF CONTAINER --------------*/
/* Scrollable area around the rendered PDF/canvas */

#pdf-container {
  margin-top: 96px;
  margin-left: 64px;
  text-align: center;
  overflow: auto;
  height: calc(100vh - 146px) !important;
  width: calc(100% - 64px) !important;
  min-width: 300px;
  min-height: 200px;
  max-width: 100vw;
  max-height: 100vh;
  border: none;
  transition: border 0.3s ease; /* Smooth transition when border appears */
}

/* Add new class for when PDF is loaded */
#pdf-container.pdf-loaded {
  border: 2px solid var(--border-primary);
}

/* Optional: Add a subtle hover effect when PDF is loaded */
#pdf-container.pdf-loaded:hover {
  border-color: var(--border-secondary);
}

/* For smaller screens 
@media (max-width: 768px) {
  #pdf-container {
    margin-left: 10px;
    width: calc(100% - 20px);
    margin-top: 80px;
    height: calc(100vh - 120px);
  }
}*/

/* Make scrollbars visible and styled */
#pdf-container::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

#pdf-container::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 2px;
}

#pdf-container::-webkit-scrollbar-thumb {
  background: #888;
  border-radius: 2px;
}

#pdf-container::-webkit-scrollbar-thumb:hover {
  background: #555;
}

/* (removed global scrollbar hide to avoid conflicts with container-specific styling) */

/*---------------- DATA TABLE --------------*/
/* Tabulator table pinned to bottom with themed colors */

#data-table {
  position: absolute;
  bottom: 0px;
  z-index: 950;
  overflow-y: scroll;
  max-height: 279px;
  width: 100%;
}

.tabulator {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-primary);
  font-size: 13px;
}

/* .custom-gdt-column {
  font-family: "MyDimFont", Arial, sans-serif !important;
  font-size: 20px;
} */

.tabulator .tabulator-cell.custom-gdt-column {
  font-family: "MyDimFont","Segoe UI Symbol","Noto Sans Symbols", Arial, sans-serif !important;
  font-size: 20px;
}


.tabulator .tabulator-col.custom-gdt-column .tabulator-col-title {
  font-family: inherit !important;
  font-size: inherit;
}

/*--------------- FILE DRAG --------------*/
/* Centered drag-and-drop upload state */
.drag-area {
  border: 2px dashed var(--border-secondary);
  background-color: var(--bg-primary);
  height: 300px;
  width: 500px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  padding: 30px;
  text-align: center;
}

.drag-area .icon svg {
  width: 40px;
  height: 40px;
  fill: var(--text-tertiary);
  margin-bottom: 12px;
}

.drag-area header {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.drag-area span {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 20px;
}

.drag-area button {
  padding: 10px 25px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border-secondary);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.drag-area button:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-secondary);
}

.drag-area.active {
  border-color: var(--color2);
  background-color: #fafafa;
}

.drag-area.hidden {
  display: none;
}
/*--------------- TOOLTIP --------------*/
/* Tooltip for toolbar/settings items (fixed positioned) */

.tool .tool_tip_text,
.top_bar_setting .tool_tip_text,
.settings_setting .tool_tip_text {
  visibility: hidden;
  width: 280px; /* Made wider */
  height: auto;
  background-color: var(--tooltip-bg);
  color: var(--bg-primary);
  text-align: left;
  padding: 4px 8px; /* Slightly reduced padding */
  border-radius: 4px;
  position: fixed;
  /*z-index: 2000;  Changed to be higher than data-table */
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  margin: 0;
  transform: none;
  font-size: 14px; /* Smaller text */
  font-weight: 600;
  line-height: 1.3; /* Better line height for readability */
  right: 16px; /* Position from right edge */
  bottom: 28px; /* Position from bottom instead of top */
  top: auto; /* Remove top positioning */
}

/* Show tooltips on hover */
.tool:hover .tool_tip_text,
.top_bar_setting:hover .tool_tip_text,
.settings_setting:hover .tool_tip_text {
  visibility: visible;
  opacity: 0.95;
}

/* Solid border */
hr.solid {
  border-top: 1px solid #bbb;
}


/* Add to your style.css */

/* Prevent clicks during drag operations */
.ui-draggable-dragging .settings-section-title {
  pointer-events: none;
}

/* Add visual feedback during drag */
.ui-draggable-dragging {
  opacity: 0.9;
  cursor: grabbing !important;
}

/* Prevent text selection during drag */
.ui-draggable-dragging * {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

#loading-message {
  display: none; 
  position: fixed; 
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%); 
  padding: 80px;
  background-color: rgba(0, 0, 0, 0.7); 
  border-radius: 5px;
  font-size: 20px;
  font-weight: bold;  
  text-align: center;
  color: white;
  border-radius: 1px;
  z-index: 9999999;
}

/* File System Access API Styles */
.file-btn {
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border-secondary);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.file-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-primary);
}

.file-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.autosave-status {
  display: inline-block;
  margin-left: 10px;
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  font-weight: 500;
  text-transform: uppercase;
}

.autosave-status.active {
  background: #d4edda;
  color: #155724;
  border: 1px solid #c3e6cb;
}

.autosave-status.inactive {
  background: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

.autosave-status.needs-setup {
  background: #fff3cd;
  color: #856404;
  border: 1px solid #ffeaa7;
}

/* Backup Browser Modal */
.backup-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10000;
}

.backup-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg-primary);
  border: 1px solid var(--border-primary);
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 80%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  font-family: "Plus Jakarta Sans", sans-serif; /* enforce app font */
  font-size: 13px; /* align with app controls */
}

/* Template Manager styles (build on backup modal) */
#template-modal .backup-modal-content {
  max-width: 900px; /* narrower, more vertical layout */
}
.backup-modal-body #tmpl-table-container { overflow-x: auto; }

.tm-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 8px;
}
.tm-helper {
  color: var(--text-secondary);
  font-size: 12px;
}
.tm-actions { display: flex; gap: 8px; align-items: center; }
.tm-actions .number-input { font-size: 12px; height: 28px; padding: 4px 10px; width: auto !important; }

.tm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px; /* +1pt */
  table-layout: fixed; /* keep column widths stable regardless of content/inputs */
}
.tm-th {
  text-align: left;
  background: var(--bg-secondary);
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-primary);
  color: var(--text-primary);
  font-weight: 600;
}
.tm-th.center { text-align: center; }
.tm-th.left { text-align: left; }

.tm-td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-primary);
  color: var(--text-primary);
  vertical-align: middle;
  font-weight: 600;
  font-size: 13px; /* +1pt */
}
.tm-td.center { text-align: center; }
.tm-td.left { text-align: left; }

/* Action buttons in table cells */
.tm-td .number-input { width: auto !important; font-size: 12px; height: 24px; padding: 2px 8px; }
.tm-td .number-input + .number-input { margin-left: 6px; }

/* Icon buttons for template manager actions */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--border-primary);
  background: var(--bg-secondary);
  border-radius: 3px;
  cursor: pointer;
  padding: 0;
}
.icon-btn:hover { background: var(--bg-tertiary); border-color: var(--border-secondary); }
.icon-btn svg { width: 16px; height: 16px; fill: var(--text-secondary); }
.icon-btn:hover svg { fill: var(--text-primary); }
.tm-td .icon-btn + .icon-btn { margin-left: 6px; }

/* Destructive action button (Delete) */
.icon-btn.danger { border-color: #f1c2c2; background: #fff5f5; }
.icon-btn.danger svg { fill: #d54b4b; }
.icon-btn.danger:hover { background: #ffeaea; border-color: #e79d9d; }
.icon-btn.danger:hover svg { fill: #b42424; }

/* Primary action (Add) */
.icon-btn.primary { border-color: rgba(62, 177, 255, 0.6); background: rgba(62, 177, 255, 0.08); }
.icon-btn.primary svg { fill: var(--color1); }
.icon-btn.primary:hover { background: rgba(62, 177, 255, 0.15); border-color: rgba(62, 177, 255, 0.9); }
.icon-btn.primary[disabled], .icon-btn.primary[disabled]:hover { opacity: 0.5; cursor: not-allowed; background: rgba(62,177,255,0.08); border-color: rgba(62,177,255,0.3); }

/* Inline edit inputs inside table */
.tm-input { width: 100%; max-width: 100%; box-sizing: border-box; height: 26px; font-size: 13px; padding: 2px 6px; border: 1px solid var(--border-primary); border-radius: 2px; background: var(--bg-primary); color: var(--text-primary); }
.tm-input { font-weight: 600; }
.tm-input:focus { border-color: var(--color2); box-shadow: 0 0 0 2px rgba(255, 198, 89, 0.15); }

/* Keep inputs centered in center-aligned cells */
.tm-td.center .tm-input { text-align: center; }

/* Fixed column widths for simplified header */
#tmpl-table th:nth-child(1),
#tmpl-table td:nth-child(1) { width: 45%; }
#tmpl-table th:nth-child(2),
#tmpl-table td:nth-child(2) { width: 220px; }
#tmpl-table th:nth-child(3),
#tmpl-table td:nth-child(3) { width: 80px; }
#tmpl-table th:nth-child(4),
#tmpl-table td:nth-child(4) { width: 140px; }

.tm-editor {
  margin-top: 0;
  padding: 6px 0 12px 16px; /* indent to read under file info */
  border-bottom: 1px solid var(--border-primary);
}
/* Always keep bottom separator for clarity */
.tm-editor:last-of-type { border-bottom: 1px solid var(--border-primary); }
.tm-row-editing .tm-td { border-bottom: 0 !important; }
/* Warning badge for missing sheet */
.tm-badge-warning { display:inline-block; margin-left:6px; background:#fff5e0; color:#a86a00; font-size:10px; padding:2px 6px; border:1px solid #f3d49b; border-radius:10px; vertical-align:middle; }
/* Invalid input state */
.tm-input.invalid { border-color:#d54b4b; background:#fff5f5; }
.tm-input.invalid:focus { border-color:#d54b4b; box-shadow:0 0 0 2px rgba(213,75,75,0.15); }
.tm-hint { color: var(--text-secondary); font-size: 11px; }
.tm-editor-title {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-primary);
}
.tm-editor-grid {
  display: grid;
  grid-template-columns: 1fr 160px; /* fixed input column for alignment */
  gap: 8px;
  align-items: center;
}
.tm-editor-grid .number-input { width: 160px !important; }
.tm-editor-actions {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.tm-editor-actions .number-input { width: auto !important; padding: 4px 12px; height: 28px; font-size: 12px; }

/* New: vertical two-column editor layout */
.tm-edit-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.tm-edit-left, .tm-edit-right { min-width: 0; }

/* Meta/header (left column) */
.tm-meta-row { display: grid; grid-template-columns: auto auto; column-gap: 16px; row-gap: 12px; align-items: end; padding: 8px 0; }
.tm-head-box { grid-column: 1 / -1; }
.tm-field { min-width: 0; }
.tm-field label { display: block; font-size: 12px; color: var(--text-secondary); margin-bottom: 4px; font-weight: 600; } /* +1pt */
.tm-field .tm-input { width: 180px; height: 26px; }
.tm-field-grow { min-width: 0; }
.tm-head-row { display: flex; flex-direction: column; gap: 8px; }
.tm-head-row .tm-input { width: 120px; text-transform: uppercase; }

/* Mapping (right column) */
.tm-map-row { display: block; padding: 10px 8px; background: var(--bg-secondary); border: 1px solid var(--border-primary); border-radius: 4px; }
.tm-section-label { font-weight: 600; color: var(--text-primary); margin-bottom: 8px; }
.tm-map-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tm-map-col { display: flex; flex-direction: column; gap: 6px; }
.tm-map-pair { display: flex; align-items: center; gap: 6px; }
.tm-map-pair:last-child { margin-bottom: 0; }
.tm-map-pair .tm-lab { width: 96px; font-size: 12px; color: var(--text-secondary); font-weight: 600; } /* narrower labels, +1pt */
.tm-map-pair .tm-input { width: 64px; text-transform: uppercase; } /* narrower inputs */

@media (max-width: 1100px) {
  .tm-map-grid { grid-template-columns: 1fr; }
}

/* Responsive: stack columns on narrow widths */
@media (max-width: 1100px) {
  .tm-edit-grid { grid-template-columns: 1fr; }
}
@media (max-width: 700px) {
  .tm-meta-row { grid-template-columns: 1fr; }
}

.backup-modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-secondary);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.backup-modal-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.backup-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--text-secondary);
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.backup-modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

.backup-file-item {
  padding: 12px;
  border: 1px solid var(--border-secondary);
  border-radius: 4px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.backup-file-item:hover {
  background: var(--bg-secondary);
  border-color: var(--border-primary);
}

.backup-file-item.current-drawing {
  background: rgba(0, 123, 255, 0.05);
  border-color: rgba(0, 123, 255, 0.3);
}

.backup-file-item.current-drawing:hover {
  background: rgba(0, 123, 255, 0.1);
  border-color: rgba(0, 123, 255, 0.5);
}

.backup-file-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.backup-file-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}