/* ==========================================================================
   DOMINO WORKSHEET GENERATOR - STYLESHEET
   ========================================================================== */

/* --- CSS Variables & Design Tokens --- */
.omni-generatory-domino {
  /* UI Colors (Light Theme) */
  --bg-main: #e2e8f0;
  --bg-sidebar: #ffffff;
  --bg-card: #f1f5f9;
  --border-color: #cbd5e1;
  --border-focus: #4f883d;
  --text-main: #0f172a;
  --text-muted: #475569;
  --text-accent: #4f883d;
  --accent-glow: rgba(79, 136, 61, 0.25);
  --danger: #ef4444;
  --danger-hover: #dc2626;
  
  /* Buttons and States */
  --btn-primary: linear-gradient(135deg, #4f883d 0%, #3e6d2e 100%);
  --btn-primary-hover: linear-gradient(135deg, #599845 0%, #457a35 100%);
  --btn-secondary: #f1f5f9;
  --btn-secondary-hover: #cbd5e1;

  /* Fonts */
  --font-ui: 'Outfit', sans-serif;
  
  /* Live Preview Variables (applied dynamically) */
  --preview-scale: 0.55;
}

/* --- Reset & Base Styles --- */
.omni-generatory-domino,
.omni-generatory-domino *,
.omni-generatory-domino *::before,
.omni-generatory-domino *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

.omni-generatory-domino {
  font-family: var(--font-ui);
  background-color: var(--bg-main);
  color: var(--text-main);
  width: 100%;
  max-width: 100%;
  height: clamp(760px, 86vh, 980px);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

.omni-generatory-domino :where(h1, h2, h3, h4, h5, h6, p, label, button, input, select, textarea) {
  font-family: var(--font-ui);
}

.omni-generatory-domino :where(h1, h2, h3, h4, h5, h6, p) {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}

.omni-generatory-domino :where(button, input, select, textarea) {
  font: inherit;
  line-height: normal;
  text-transform: none;
}

.omni-generatory-domino button {
  appearance: none;
  -webkit-appearance: none;
}

/* --- Layout Container --- */
.app-container {
  display: flex;
  height: 100%;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  position: relative;
  overflow: hidden;
}

/* ==========================================================================
   LEFT PANEL: SETTINGS SIDEBAR
   ========================================================================== */
.settings-sidebar {
  width: clamp(360px, 38%, 470px);
  min-width: 360px;
  flex: 0 0 clamp(360px, 38%, 470px);
  background: var(--bg-sidebar);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  z-index: 10;
  box-shadow: 10px 0 30px rgba(0, 0, 0, 0.05);
  transition: transform 0.3s ease;
}

/* --- Sidebar Content (Scrollable) --- */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 0 5px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

.sidebar-content::-webkit-scrollbar {
  width: 6px;
}

.sidebar-content::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.15);
  border-radius: 3px;
}

/* --- Accordion Sections --- */
.settings-section {
  flex: 0 0 auto;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.settings-section.active {
  border-color: rgba(79, 136, 61, 0.3);
  box-shadow: 0 4px 20px rgba(79, 136, 61, 0.08);
}

.section-title {
  padding: 13px 16px;
  display: flex;
  align-items: center;
  width: 100%;
  border: none;
  cursor: pointer;
  user-select: none;
  background: rgba(0, 0, 0, 0.01);
  transition: background 0.2s;
}

.section-title:hover {
  background: rgba(0, 0, 0, 0.03);
}

.section-title .icon {
  font-size: 18px;
  margin-right: 12px;
}

.section-title h3 {
  font-family: var(--font-ui) !important;
  font-size: 15px !important;
  font-weight: 700 !important;
  line-height: 1.25 !important;
  flex: 1;
  color: var(--text-main) !important;
  padding: 0 !important;
  margin: 0 !important;
  text-transform: none !important;
  letter-spacing: 0 !important;
}

.section-title .chevron {
  width: 8px;
  height: 8px;
  border-bottom: 2px solid var(--text-muted);
  border-right: 2px solid var(--text-muted);
  transform: rotate(45deg);
  transition: transform 0.3s ease;
  margin-right: 4px;
}

.settings-section.active .section-title .chevron {
  transform: rotate(-135deg);
}

.section-body {
  padding: 0 16px 16px 16px;
  display: none;
  border-top: 1px solid rgba(0, 0, 0, 0.05);
  background: rgba(0, 0, 0, 0.01);
  animation: slideDown 0.3s ease;
}

.settings-section.active .section-body {
  display: block;
}

.settings-section[data-section="elements"] .section-body {
  padding-left: 5px;
  padding-right: 5px;
}

.settings-section[data-section="type"] .section-body {
  padding-left: 8px;
  padding-right: 8px;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Form Controls --- */
.control-group {
  margin-top: 16px;
}

.control-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.control-group input[type="text"],
.control-group input[type="number"],
.control-group select,
.control-group textarea {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 14px;
  transition: all 0.2s;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.control-group input[type="text"]:focus,
.control-group input[type="number"]:focus,
.control-group select:focus,
.control-group textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 136, 61, 0.15);
  background: #ffffff;
}

/* --- Input Grid --- */
.input-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.input-grid > div {
  width: 100%;
}

/* --- Segmented Control --- */
.segmented-control {
  display: flex;
  background: #f1f5f9;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.segmented-control button {
  flex: 1;
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-ui);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}

.segmented-control button:hover {
  color: var(--text-main);
}

.segmented-control button.active {
  background: #4f883d;
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(79, 136, 61, 0.3);
}

/* --- Slider Style --- */
.slider-container {
  display: flex;
  align-items: center;
  gap: 12px;
}

.slider-container input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  background: rgba(0, 0, 0, 0.1);
  height: 6px;
  border-radius: 3px;
  outline: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #4f883d;
  cursor: pointer;
  box-shadow: 0 0 6px rgba(79, 136, 61, 0.5);
  transition: transform 0.1s;
}

.slider-container input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.slider-val {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-accent);
  min-width: 48px;
  text-align: right;
}

.slider-container .text-size-number {
  width: 64px;
  padding: 8px 8px;
  text-align: center;
  font-weight: 700;
}

/* --- Color Picker Wrapper --- */
.color-picker-wrapper {
  display: flex;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  align-items: center;
  padding: 3px;
}

.color-picker-wrapper input[type="color"] {
  -webkit-appearance: none;
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  background: none;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-picker-wrapper input[type="color"]::-webkit-color-swatch {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 6px;
}

.color-picker-wrapper input[type="text"] {
  border: none !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 8px 10px;
  font-family: monospace;
  font-size: 13px;
  text-transform: uppercase;
  max-width: 90px;
}

/* --- Row Align Groups --- */
.control-group.row-align {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.control-group.row-align label {
  margin-bottom: 0;
}

.control-group.switch-control {
  align-items: stretch;
}

.control-group.row-align input[type="number"] {
  width: 70px;
  padding: 6px 8px;
  text-align: center;
}

/* --- Checkbox Switch Style --- */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  min-width: 0;
  cursor: pointer;
  user-select: none;
  text-transform: none !important;
  font-weight: 700 !important;
  font-size: 13px !important;
  line-height: 1.25;
  color: var(--text-main) !important;
}

.checkbox-text {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  padding-top: 2px;
  overflow-wrap: anywhere;
}

.checkbox-label input {
  display: none;
}

.checkbox-custom {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 24px;
  background: #cbd5e1;
  border: 2px solid #94a3b8;
  border-radius: 999px;
  transition: background 0.3s, border-color 0.3s, box-shadow 0.3s;
  box-shadow: inset 0 1px 3px rgba(15, 23, 42, 0.16);
}

.checkbox-custom::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.28);
}

.checkbox-label input:checked + .checkbox-custom {
  background: #4f883d;
  border-color: #3e6d2e;
  box-shadow: 0 0 0 3px rgba(79, 136, 61, 0.16);
}

.checkbox-label input:checked + .checkbox-custom::after {
  transform: translateX(18px);
}

.checkbox-label input:focus-visible + .checkbox-custom {
  outline: 3px solid rgba(79, 136, 61, 0.28);
  outline-offset: 3px;
}

/* --- Buttons Styles --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 8px;
  border: none;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  width: 100%;
}

.btn-primary {
  background: var(--btn-primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--btn-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-glow {
  position: relative;
}

.btn-glow::after {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 10px;
  background: var(--btn-primary);
  z-index: -1;
  opacity: 0.4;
  filter: blur(8px);
  transition: opacity 0.3s;
}

.btn-glow:hover::after {
  opacity: 0.6;
}

.btn-secondary {
  background: var(--btn-secondary);
  color: var(--text-main);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: var(--btn-secondary-hover);
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-outline {
  background: transparent;
  color: var(--text-main);
  border: 1px solid rgba(0, 0, 0, 0.15);
}

.btn-outline:hover {
  background: rgba(0, 0, 0, 0.04);
  border-color: rgba(0, 0, 0, 0.3);
}

.btn-link {
  background: transparent;
  color: var(--text-muted);
  padding: 4px 8px;
  font-size: 12px;
  width: auto;
}

.btn-link.btn-danger:hover {
  color: var(--danger);
  text-decoration: underline;
}

.btn-group-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.btn-group-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

/* --- File Upload Area --- */
.file-upload-wrapper {
  position: relative;
  width: 100%;
}

.file-upload-input {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.file-upload-label {
  margin: 0;
}

.modal-upload-wrapper {
  flex: 0 0 auto;
  width: auto;
}

.modal-upload-wrapper .file-upload-label {
  min-height: 38px;
  padding: 9px 14px;
  white-space: nowrap;
}

/* --- Sidebar Elements List --- */
.elements-actions {
  margin-bottom: 14px;
}

.elements-list-container {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  min-height: 160px;
  max-height: 320px;
  overflow-y: auto;
  position: relative;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
}

.elements-list-container::-webkit-scrollbar {
  width: 4px;
}

.elements-list-container::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
}

.drag-info-text {
  font-size: 14px;
  line-height: 1.35;
  font-weight: 500;
  color: #334155;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
  background: #f8fafc;
  display: none; /* Shown only when items present */
}

.elements-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.elements-list-footer {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  padding: 24px;
  flex: 1;
  line-height: 1.5;
}

/* --- Domino Element Item in Sidebar --- */
.element-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  gap: 12px;
  background: #ffffff;
  transition: background 0.15s;
}

.element-item-text,
.element-item-text-pair {
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 8px;
  padding-right: 8px;
}

.element-item-text .element-inputs,
.element-item-text-pair .element-inputs {
  flex: 0 0 100%;
  order: 10;
  width: 100%;
}

.element-item-text .element-inputs input,
.element-item-text-pair .element-inputs input {
  min-width: 0;
}

.element-item-text .element-thumb,
.element-item-text-pair .element-thumb {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
}

.element-item-text .element-controls,
.element-item-text-pair .element-controls {
  margin-left: auto;
}

.element-item:hover {
  background: #f8fafc;
}

.element-item:last-child {
  border-bottom: none;
}

.element-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  background: #f1f5f9;
  border: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.element-thumb img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
}

.element-thumb.text-type {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-accent);
}

.element-inputs {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.element-inputs input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background: #f8fafc;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  padding: 8px 10px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.element-inputs input:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(79, 136, 61, 0.14);
}

.element-inputs .input-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

.element-meta-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: flex-start;
  min-width: 0;
}

.element-index {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  min-width: 16px;
}

.element-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-item-control {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.btn-item-control:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

.btn-item-control.delete:hover {
  color: var(--danger);
  background: rgba(239, 68, 68, 0.1);
}

.btn-item-control svg {
  width: 14px;
  height: 14px;
}

.btn-change-image {
  width: auto;
  gap: 4px;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 700;
  color: #3e6d2e;
  background: rgba(79, 136, 61, 0.08);
  border: 1px solid rgba(79, 136, 61, 0.18);
  white-space: nowrap;
}

.btn-change-image:hover {
  background: rgba(79, 136, 61, 0.14);
  color: #2f5c22;
}

/* --- Sidebar Footer (Export Panel) --- */
.sidebar-footer {
  padding: 20px 24px 24px 24px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
}

.sidebar-footer .btn-large {
  padding: 14px 20px;
  font-size: 15px;
}

/* ==========================================================================
   RIGHT PANEL: WORKSPACE & PREVIEW
   ========================================================================== */
.preview-workspace {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background-color: #cbd5e1;
  position: relative;
  overflow: hidden;
  height: 100%;
}

/* --- Workspace Header --- */
.workspace-header {
  height: 68px;
  padding: 0 24px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 5;
}

.workspace-title-info {
  margin-right: auto;
}

.workspace-title-info h2 {
  font-family: var(--font-ui) !important;
  font-size: 16px !important;
  font-weight: 700 !important;
  color: var(--text-main) !important;
  letter-spacing: 0 !important;
  line-height: 1.2 !important;
  padding: 0 !important;
  margin: 0 !important;
  text-transform: none !important;
}

.page-badge {
  font-size: 11px;
  background: rgba(79, 136, 61, 0.1);
  color: #3e6d2e;
  border: 1px solid rgba(79, 136, 61, 0.25);
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 600;
  display: inline-block;
  margin-top: 2px;
}

/* --- Zoom Controls --- */
.zoom-controls {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 4px;
}

.btn-zoom {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-zoom:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-main);
}

.btn-zoom:active {
  background: rgba(0, 0, 0, 0.08);
}

.zoom-level {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  min-width: 48px;
  text-align: center;
  user-select: none;
}

.divider-v {
  width: 1px;
  height: 20px;
  background: var(--border-color);
  margin: 0 4px;
}

.btn-icon-only {
  width: 32px;
  height: 32px;
}

.btn-header-download {
  width: auto;
  min-height: 42px;
  padding: 10px 16px;
  white-space: nowrap;
  box-shadow: 0 4px 12px var(--accent-glow);
}

/* --- Scrollable Workspace Panel --- */
.preview-scroll-container {
  flex: 1;
  overflow: auto;
  padding: clamp(12px, 2vw, 24px);
  display: block;
  scrollbar-width: auto;
  scrollbar-color: rgba(0, 0, 0, 0.1) transparent;
}

.preview-scroll-container::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

.preview-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 5px;
}

/* --- Scale Wrapper --- */
.preview-scale-wrapper {
  position: relative;
  width: max-content;
  max-width: 100%;
  min-width: 0;
  margin: 0 auto;
  overflow: visible;
  transition: width 0.2s, height 0.2s;
}

/* ==========================================================================
   WORKSHEET A4 PAGES AND TILES RENDERING
   ========================================================================== */
.worksheet-pages-container {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 30px;
  padding-bottom: 50px;
  transform: scale(var(--preview-scale));
  transform-origin: top left;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Single A4 Page Style --- */
.a4-page {
  background: #ffffff;
  color: #000000;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
  box-sizing: border-box;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
  
  /* Standard A4 dimensions in mm */
  width: 210mm;
  height: 297mm;
  padding: 15mm;
  transition: all 0.3s ease;
}

/* Landscape Mode overrides */
.a4-page.landscape {
  width: 297mm;
  height: 210mm;
  padding: 12mm 15mm;
}

/* --- Page Header Layout --- */
.worksheet-header {
  margin-bottom: 8mm;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 4mm;
  display: flex;
  flex-direction: column;
  gap: 1.5mm;
}

.worksheet-title {
  font-size: 24pt;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  line-height: 1.2;
}

.worksheet-description {
  font-size: 10.5pt;
  color: #64748b;
  margin: 0;
  line-height: 1.4;
  font-weight: 500;
}

/* --- Page Content (Grid for Tiles) --- */
.worksheet-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.domino-grid {
  display: grid;
  justify-content: center;
  align-content: center;
  width: 100%;
  height: 100%;
  margin: auto;
}

/* --- Page Footer Layout --- */
.worksheet-footer {
  margin-top: auto;
  padding-top: 3mm;
  border-top: 1px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8pt;
  color: #94a3b8;
  font-weight: 500;
}

/* ==========================================================================
   DOMINO TILES (Inside pages)
   ========================================================================== */
.domino-tile {
  box-sizing: border-box;
  display: flex;
  position: relative;
  overflow: hidden;
  background-color: var(--tile-bg);
}

.tile-half {
  width: 50%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3%;
  box-sizing: border-box;
  position: relative;
}

/* Center divider line inside tile */
.tile-divider-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 0;
  transform: translateX(-50%);
  z-index: 2;
}

/* Image styling in tiles */
.tile-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  display: block;
}

/* Text styling in tiles */
.tile-text {
  text-align: center;
  word-break: normal;
  overflow-wrap: break-word;
  line-height: 1.25;
  width: 100%;
  max-height: 100%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   MODAL WINDOW DIALOGS (Graphics Library & Bulk Import)
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  width: 90%;
  max-width: 1000px;
  height: 80vh;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-container {
  transform: scale(1);
}

.modal-container.modal-small {
  max-width: 500px;
  height: auto;
  max-height: 90vh;
}

/* --- Modal Header --- */
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title-area h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  transition: color 0.2s;
  padding: 4px;
}

.modal-close:hover {
  color: var(--text-main);
}

/* --- Modal Toolbar --- */
.modal-toolbar {
  padding: 12px 24px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
}

.search-box {
  position: relative;
  flex: 1;
  max-width: 400px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 14px;
  color: var(--text-muted);
}

.search-box input {
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 8px 36px 8px 36px;
  color: var(--text-main);
  font-family: var(--font-ui);
  font-size: 14px;
  outline: none;
  transition: all 0.2s;
}

.search-box input:focus {
  border-color: var(--border-focus);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(79, 136, 61, 0.15);
}

.clear-search {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  font-size: 16px;
  color: var(--text-muted);
  cursor: pointer;
  display: none;
}

.clear-search.visible {
  display: block;
}

.selection-status {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-accent);
}

/* --- Modal Split Body --- */
.modal-body-split {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* --- Modal Categories Sidebar --- */
.modal-categories-sidebar {
  width: 240px;
  border-right: 1px solid var(--border-color);
  background: #f8fafc;
  overflow-y: auto;
  scrollbar-width: thin;
}

.categories-list {
  list-style: none;
  padding: 12px;
}

.category-item {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.category-item:hover {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text-main);
}

.category-item.active {
  background: rgba(79, 136, 61, 0.1);
  color: #4f883d;
}

.category-count {
  font-size: 11px;
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: 10px;
}

.category-item.active .category-count {
  background: rgba(79, 136, 61, 0.2);
  color: #4f883d;
}

/* --- Modal Images Grid --- */
.modal-grid-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: #f1f5f9;
}

.images-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 16px;
}

/* --- Image Grid Card --- */
.grid-image-card {
  aspect-ratio: 1;
  background: #ffffff;
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.grid-image-card:hover {
  transform: translateY(-2px);
  background: #f8fafc;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.grid-image-card img {
  max-width: 88%;
  max-height: 88%;
  object-fit: contain;
  transition: transform 0.2s;
}

.grid-image-card:hover img {
  transform: scale(1.05);
}

/* Selected state */
.grid-image-card.selected {
  border-color: #4f883d;
  background: rgba(79, 136, 61, 0.06);
}

.grid-image-card.selected::before {
  content: '✓';
  position: absolute;
  top: 6px;
  right: 6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #4f883d;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: bold;
  box-shadow: 0 0 6px var(--accent-glow);
}

.grid-empty-state {
  text-align: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 14px;
}

/* --- Modal Footer --- */
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

.modal-footer .btn {
  width: auto;
  min-width: 100px;
}

/* --- Bulk Text Modal Body --- */
.modal-body {
  padding: 20px 24px;
}

.ai-status {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(79, 136, 61, 0.1);
  color: #365f2b;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.ai-status.error {
  background: rgba(239, 68, 68, 0.1);
  color: #b91c1c;
}

/* ==========================================================================
   HIDDEN HTML PRINT UTILITIES (For PDF Export)
   ========================================================================== */
.printable-container-hidden {
  position: fixed;
  left: -9999px;
  top: -9999px;
  width: 210mm;
  opacity: 1;
  pointer-events: none;
}

.printable-container-hidden.is-exporting-pdf {
  left: 0;
  top: 0;
  z-index: 9999;
  background: #ffffff;
}

.pdf-export-stage {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 9999;
  background: #ffffff;
  pointer-events: none;
}

/* ==========================================================================
   MEDIA QUERIES FOR SCREEN RESPONSIVENESS
   ========================================================================== */

/* Layout change only below 850px; 850px+ keeps sidebar and preview side by side. */
@media (max-width: 849px) {
  .omni-generatory-domino {
    height: auto;
    min-height: 100vh;
    overflow: visible;
  }

  .app-container {
    flex-direction: column;
    height: auto;
    min-height: 100vh;
    overflow-y: auto;
  }
  
  .settings-sidebar {
    width: 100%;
    min-width: 100%;
    height: auto;
    max-height: none;
    overflow: visible;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  }

  .sidebar-content {
    flex: none;
    overflow: visible;
  }
  
  .preview-workspace {
    flex: none;
    height: 60vh;
  }

  .preview-scroll-container {
    padding: 20px;
  }
}

@media (min-width: 850px) and (max-width: 980px) {
  .omni-generatory-domino {
    height: clamp(760px, 86vh, 920px);
  }

  .settings-sidebar {
    width: 340px;
    min-width: 340px;
    flex-basis: 340px;
  }

  .sidebar-content {
    padding: 8px 5px;
    gap: 10px;
  }

  .section-title {
    padding: 12px;
  }

  .section-body {
    padding: 0 12px 12px 12px;
  }

  .segmented-control button {
    font-size: 10px;
    padding: 7px 4px;
  }

  .workspace-header {
    padding: 0 12px;
    gap: 8px;
  }

  .btn-header-download {
    padding: 8px 10px;
  }
}

/* Adjustments for tablets/smaller screens */
@media (max-width: 599px) {
  .modal-container {
    width: 95%;
    height: 90vh;
  }
  
  .modal-body-split {
    flex-direction: column;
  }
  
  .modal-categories-sidebar {
    width: 100%;
    height: 60px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
  }
  
  .categories-list {
    display: flex;
    padding: 6px;
    gap: 6px;
  }
  
  .category-item {
    margin-bottom: 0;
    padding: 6px 12px;
  }
}

/* ==========================================================================
   MEDIA REGULES FOR PHYSICAL PRINTING
   ========================================================================== */
@media print {
  /* Hide all interactive elements */
  .omni-generatory-domino,
  .omni-generatory-domino .app-container {
    background: white !important;
    color: black !important;
    overflow: visible !important;
    height: auto !important;
    width: auto !important;
  }

  .omni-generatory-domino .settings-sidebar,
  .omni-generatory-domino .workspace-header,
  .omni-generatory-domino .zoom-controls,
  .omni-generatory-domino .modal-overlay {
    display: none !important;
  }

  .omni-generatory-domino .preview-workspace,
  .omni-generatory-domino .preview-scroll-container,
  .omni-generatory-domino .preview-scale-wrapper,
  .omni-generatory-domino .worksheet-pages-container {
    display: block !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    overflow: visible !important;
    transform: none !important;
    height: auto !important;
    width: auto !important;
  }

  .omni-generatory-domino .a4-page {
    box-shadow: none !important;
    margin: 0 !important;
    padding: 15mm !important;
    page-break-after: always !important;
    break-after: always !important;
    border: none !important;
    float: none !important;
  }

  .omni-generatory-domino .a4-page.landscape {
    padding: 12mm 15mm !important;
  }
}
