/* ============================================================
   main.css — All Component Styles
   Facebook Ads Editor
   ============================================================ */

/* ---- Reset & Base ---------------------------------------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  background: var(--color-content-bg);
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }
a { color: var(--color-meta-blue); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- App Shell ------------------------------------------- */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ---- Editor Wrapper -------------------------------------- */
#editor-wrapper {
  display: none; /* JS shows this when data is loaded */
  flex: 1;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}
#editor-wrapper.visible {
  display: flex;
}

/* #main-content inside editor-wrapper */
#editor-wrapper #main-content {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
}

/* Grid container fills remaining height */
#editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

#grid-container {
  flex: 1;
  overflow: hidden;
  min-height: 0;
  background: var(--color-content-bg);
}

.ag-grid-wrapper {
  height: 100%;
  width: 100%;
}

/* ---- Toolbar --------------------------------------------- */
#toolbar {
  height: var(--height-toolbar);
  background: var(--color-toolbar-bg);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: var(--space-2);
  flex-shrink: 0;
  z-index: var(--z-toolbar);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.toolbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-right: var(--space-4);
}

.toolbar-brand-icon {
  width: 28px;
  height: 28px;
  background: var(--color-meta-blue);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: var(--font-weight-bold);
  color: white;
}

.toolbar-brand-name {
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-semibold);
  color: white;
}

.toolbar-sep {
  width: 1px;
  height: 24px;
  background: rgba(255,255,255,0.15);
  margin: 0 var(--space-2);
}

.toolbar-spacer { flex: 1; }

/* Toolbar Buttons */
.btn-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  height: 32px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.2);
  background: transparent;
  color: var(--color-sidebar-text);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.btn-toolbar:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.35);
}

.btn-toolbar.primary {
  background: var(--color-meta-blue);
  border-color: var(--color-meta-blue);
  color: white;
}

.btn-toolbar.primary:hover {
  background: var(--color-meta-blue-dark);
  border-color: var(--color-meta-blue-dark);
}

.btn-toolbar.danger {
  border-color: #F87171;
  color: #FCA5A5;
}

.btn-toolbar.danger:hover {
  background: rgba(239,68,68,0.15);
  border-color: #EF4444;
  color: #FCA5A5;
}

.btn-toolbar:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.btn-toolbar .btn-icon { font-size: 14px; }

/* ---- Main Content Area ----------------------------------- */
#main-content {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ---- Sidebar --------------------------------------------- */
#sidebar {
  width: var(--width-sidebar);
  min-width: 120px;
  max-width: 600px;
  background: var(--color-sidebar-bg);
  display: flex;
  flex-direction: column;
  border-right: 1px solid rgba(255,255,255,0.06);
  z-index: var(--z-sidebar);
  transition: min-width var(--transition-slow);
  overflow: hidden;
  position: relative;
}

#sidebar-resize-handle {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 5px;
  cursor: col-resize;
  z-index: calc(var(--z-sidebar) + 1);
}
#sidebar-resize-handle:hover,
#sidebar.resizing #sidebar-resize-handle {
  background: rgba(255,255,255,0.2);
}

#sidebar.collapsed {
  width: 0 !important;
  min-width: 0;
  transition: width var(--transition-slow), min-width var(--transition-slow);
}

.sidebar-header {
  height: var(--height-tab-bar);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-3);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

.sidebar-header-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.sidebar-toggle {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  font-size: 14px;
  line-height: 1;
}
.sidebar-toggle:hover { color: var(--color-sidebar-text); background: var(--color-sidebar-hover); }

.sidebar-tree {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: var(--space-2) 0;
}

.sidebar-tree::-webkit-scrollbar { width: 4px; }
.sidebar-tree::-webkit-scrollbar-track { background: transparent; }
.sidebar-tree::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }

.tree-node {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: 5px var(--space-3);
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin: 1px var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-sidebar-text);
  transition: background var(--transition-fast);
  user-select: none;
  min-height: 28px;
}

.tree-node:hover { background: var(--color-sidebar-hover); }
.tree-node.active { background: var(--color-sidebar-active); }
.tree-node.selected { background: var(--color-meta-blue); }

.tree-node-indent { display: inline-block; }
.tree-node-toggle {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--color-text-secondary);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}
.tree-node-toggle.open { transform: rotate(90deg); }
.tree-node-icon { font-size: 12px; flex-shrink: 0; }
.tree-node-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--font-size-sm);
}

.tree-node-badges {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.tree-badge-modified {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--color-modified-dot);
}
.tree-badge-new {
  font-size: 9px;
  font-weight: var(--font-weight-bold);
  color: var(--color-new-text);
  background: var(--color-new-badge);
  border-radius: 3px;
  padding: 0 3px;
  line-height: 14px;
}
.tree-badge-error {
  font-size: 11px;
  color: var(--color-error-icon);
}

.tree-children { overflow: hidden; }
.tree-children.collapsed { display: none; }

.sidebar-footer {
  padding: var(--space-3);
  border-top: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
}

/* ---- Tab Bar --------------------------------------------- */
#tab-bar {
  height: var(--height-tab-bar);
  background: var(--color-panel-bg);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  gap: 0;
  flex-shrink: 0;
}

.tab-btn {
  height: 100%;
  padding: 0 var(--space-4);
  border: none;
  background: none;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition-fast), border-color var(--transition-fast);
  white-space: nowrap;
}

.tab-btn:hover { color: var(--color-text-primary); }
.tab-btn.active {
  color: var(--color-meta-blue);
  border-bottom-color: var(--color-meta-blue);
  font-weight: var(--font-weight-semibold);
}

.tab-bar-sep {
  width: 1px; height: 18px;
  background: var(--color-border);
  margin: 0 var(--space-2);
}

.tab-bar-spacer { flex: 1; }

.tab-bar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.tab-search {
  height: 28px;
  padding: 0 var(--space-3) 0 28px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  outline: none;
  background: var(--color-content-bg);
  color: var(--color-text-primary);
  width: 180px;
  transition: border-color var(--transition-fast), width var(--transition-slow);
  background-image: url("data:image/svg+xml,%3Csvg width='14' height='14' viewBox='0 0 24 24' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Ccircle cx='11' cy='11' r='8' stroke='%236B7280' stroke-width='2'/%3E%3Cpath d='m21 21-4.35-4.35' stroke='%236B7280' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 8px center;
}
.tab-search:focus { border-color: var(--color-meta-blue); width: 220px; }
.tab-search::placeholder { color: var(--color-text-disabled); }



/* AG Grid Theme Overrides */
.ag-theme-alpine {
  --ag-font-family: var(--font-sans);
  --ag-font-size: 13px;
  --ag-row-height: 32px;
  --ag-header-height: 36px;
  --ag-border-color: var(--color-border);
  --ag-header-background-color: #F9FAFB;
  --ag-header-foreground-color: var(--color-text-secondary);
  --ag-row-hover-color: #F3F4F6;
  --ag-selected-row-background-color: var(--color-meta-blue-light);
  --ag-range-selection-border-color: var(--color-meta-blue);
  --ag-cell-horizontal-padding: 12px;
  --ag-cell-focus-border: none;
}

.ag-theme-alpine .ag-header-cell-label {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
}

.ag-theme-alpine .ag-cell {
  font-size: var(--font-size-base);
  display: flex;
  align-items: center;
}

.ag-theme-alpine .ag-cell-inline-editing {
  height: 30px;
  padding: 0;
}

.ag-theme-alpine .ag-row-selected {
  background-color: var(--color-meta-blue-light) !important;
}

/* Row state coloring is applied via getRowStyle in JS */

/* Status badges in grid */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
}
.status-active { background: #DCFCE7; color: #166534; }
.status-paused { background: #F3F4F6; color: var(--color-text-secondary); }
.status-archived { background: #F3F4F6; color: var(--color-text-disabled); }
.status-deleted { background: var(--color-error-bg); color: var(--color-danger); }

.state-badge-new {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  background: var(--color-new-badge);
  color: white;
}

.state-dot-modified {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--color-modified-dot);
  display: inline-block;
}


.changes-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--font-weight-semibold);
  line-height: 1.3;
  white-space: nowrap;
}

.changes-badge.changes-modified {
  background: #FEF3C7;
  color: #92400E;
  border: 1px solid #F59E0B33;
}

.changes-badge.changes-new {
  background: #D1FAE5;
  color: #065F46;
  border: 1px solid #10B98133;
}

.changes-badge.changes-error {
  background: #FEE2E2;
  color: #B91C1C;
  border: 1px solid #EF444433;
}

.changes-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-modified-dot);
  display: inline-block;
  flex: 0 0 auto;
}

.state-error-icon {
  color: var(--color-error-icon);
  font-size: 14px;
}

.type-icon {
  font-size: 16px;
}

/* ---- Detail Panel ---------------------------------------- */
#detail-panel {
  background: var(--color-panel-bg);
  border-top: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  position: relative;
}

#detail-panel.hidden { display: none; }

.detail-panel-resize {
  height: 4px;
  background: transparent;
  cursor: ns-resize;
  position: absolute;
  top: 0; left: 0; right: 0;
  z-index: 5;
}
.detail-panel-resize:hover { background: var(--color-meta-blue); }

.detail-panel-header {
  height: 38px;
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-3);
  flex-shrink: 0;
}

.detail-panel-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.detail-panel-close {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  font-size: 16px;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  line-height: 1;
}
.detail-panel-close:hover { background: var(--color-content-bg); color: var(--color-text-primary); }

.detail-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
}

.detail-panel-body::-webkit-scrollbar { width: 6px; }
.detail-panel-body::-webkit-scrollbar-track { background: transparent; }
.detail-panel-body::-webkit-scrollbar-thumb { background: var(--color-border-strong); border-radius: 3px; }

/* Detail Sub-tabs */
.detail-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: var(--space-4);
  margin-top: -4px;
}

.detail-tab-btn {
  padding: 6px var(--space-3);
  border: none;
  background: none;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: color var(--transition-fast);
}
.detail-tab-btn:hover { color: var(--color-text-primary); }
.detail-tab-btn.active {
  color: var(--color-meta-blue);
  border-bottom-color: var(--color-meta-blue);
  font-weight: var(--font-weight-medium);
}

.detail-tab-pane { display: none; }
.detail-tab-pane.active { display: block; }

/* Form Layout */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3) var(--space-4);
}

.form-grid.single { grid-template-columns: 1fr; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }

.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.form-group.span-2 { grid-column: span 2; }
.form-group.span-3 { grid-column: span 3; }

.form-label {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-control {
  height: 30px;
  padding: 0 var(--space-2);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  color: var(--color-text-primary);
  background: var(--color-panel-bg);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  border-color: var(--color-meta-blue);
  box-shadow: 0 0 0 3px rgba(24,119,242,0.12);
}

.form-control:disabled, .form-control[readonly] {
  background: var(--color-content-bg);
  color: var(--color-text-disabled);
  cursor: not-allowed;
}

.form-control.error { border-color: var(--color-danger); }

textarea.form-control {
  height: auto;
  min-height: 60px;
  padding: var(--space-2);
  resize: vertical;
  line-height: var(--line-height-base);
}

select.form-control { cursor: pointer; }

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.copy-filename-hint {
  cursor: pointer;
  text-decoration: underline dotted;
}

.copy-filename-hint:hover {
  color: var(--color-primary);
}

.form-error-msg {
  font-size: var(--font-size-xs);
  color: var(--color-danger);
}


/* Ad parent context */
.ad-parent-context {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
  padding: var(--space-3);
  background: #F8FAFC;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.ad-parent-context-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.ad-parent-context-label {
  font-size: 10px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ad-parent-context-value {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 900px) {
  .ad-parent-context { grid-template-columns: 1fr; }
}


/* Field help messages */
.field-help {
  margin-top: var(--space-1);
  font-size: var(--font-size-xs);
  line-height: 1.4;
}

.field-help-info {
  color: #1D4ED8;
  background: var(--color-info-bg);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius-sm);
  padding: var(--space-2);
}

.preview-field-note {
  color: #1D4ED8;
  background: var(--color-info-bg);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius-sm);
  padding: var(--space-2);
}

/* Read-only section */
.readonly-notice {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-info-bg);
  border: 1px solid #BFDBFE;
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  color: #1D4ED8;
  margin-bottom: var(--space-3);
}

.readonly-fields-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-2) var(--space-3);
  background: var(--color-content-bg);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  border: 1px solid var(--color-border);
}

.readonly-field { display: flex; flex-direction: column; gap: 2px; }
.readonly-field-label {
  font-size: 10px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.readonly-field-value {
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  font-family: var(--font-mono);
  word-break: break-all;
}

/* Image hash with browse */
.image-hash-group {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}
.image-hash-group .form-control { flex: 1; font-family: var(--font-mono); font-size: var(--font-size-xs); }

/* Radio Group */
.radio-group {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.radio-option {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  cursor: pointer;
  font-size: var(--font-size-sm);
}

.radio-option input[type="radio"] {
  accent-color: var(--color-meta-blue);
  width: 14px; height: 14px;
}

/* Carousel cards */
.carousel-cards-list { display: flex; flex-direction: column; gap: var(--space-3); }

.carousel-card {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--color-content-bg);
}

.carousel-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.carousel-card-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-secondary);
}

.add-card-btn {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-2) var(--space-3);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: border-color var(--transition-fast), color var(--transition-fast);
}
.add-card-btn:hover { border-color: var(--color-meta-blue); color: var(--color-meta-blue); }

/* ---- Buttons --------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  height: 32px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
  white-space: nowrap;
  line-height: 1;
}

.btn:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; }

.btn-primary {
  background: var(--color-meta-blue);
  color: white;
  border-color: var(--color-meta-blue);
}
.btn-primary:hover { background: var(--color-meta-blue-dark); border-color: var(--color-meta-blue-dark); }

.btn-secondary {
  background: white;
  color: var(--color-text-primary);
  border-color: var(--color-border-strong);
}
.btn-secondary:hover { background: var(--color-content-bg); border-color: var(--color-text-secondary); }

.btn-danger {
  background: var(--color-danger);
  color: white;
  border-color: var(--color-danger);
}
.btn-danger:hover { background: #DC2626; border-color: #DC2626; }

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--color-content-bg); color: var(--color-text-primary); }

.btn-sm { height: 26px; padding: 0 var(--space-2); font-size: var(--font-size-xs); }
.btn-icon-only { width: 32px; padding: 0; }

/* ---- Empty State ----------------------------------------- */
#empty-state {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: var(--color-content-bg);
}

#empty-state.hidden { display: none; }

.empty-card {
  text-align: center;
  max-width: 520px;
  padding: var(--space-8);
}

.empty-icon {
  font-size: 64px;
  margin-bottom: var(--space-4);
  opacity: 0.4;
}

.empty-headline {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.empty-body {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
  line-height: var(--line-height-base);
  margin-bottom: var(--space-6);
}

.empty-note {
  margin: 10px auto 22px;
  max-width: 560px;
  color: var(--color-text-secondary);
  font-size: 13px;
  line-height: 1.5;
}


.empty-steps {
  list-style: none;
  text-align: left;
  margin-bottom: var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.empty-step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.empty-step-num {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--color-meta-blue);
  color: white;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.empty-cta { width: 100%; height: 40px; font-size: var(--font-size-md); }

.empty-settings-nudge {
  margin-top: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

/* ---- Import Summary -------------------------------------- */
#import-summary {
  display: none;
  flex: 1;
  align-items: center;
  justify-content: center;
  background: var(--color-content-bg);
  overflow-y: auto;
}
#import-summary.visible { display: flex; }

.import-summary-card {
  background: white;
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.import-summary-icon { font-size: 48px; margin-bottom: var(--space-4); }

.import-summary-title {
  font-size: 20px;
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.import-summary-subtitle {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}

.import-stats {
  display: flex;
  justify-content: center;
  gap: var(--space-6);
  margin-bottom: var(--space-6);
}

.import-stat { text-align: center; }
.import-stat-value {
  font-size: 28px;
  font-weight: var(--font-weight-bold);
  color: var(--color-meta-blue);
  line-height: 1;
}
.import-stat-label {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  margin-top: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.import-warnings {
  text-align: left;
  margin-bottom: var(--space-4);
}

.import-warnings-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-warning-bg);
  border: 1px solid #FDE68A;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: #92400E;
  cursor: pointer;
  width: 100%;
  justify-content: space-between;
}

.import-warnings-list {
  background: var(--color-content-bg);
  border: 1px solid var(--color-border);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  padding: var(--space-2) var(--space-3);
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
  max-height: 120px;
  overflow-y: auto;
  display: none;
}
.import-warnings-list.open { display: block; }
.import-warnings-list li { padding: 2px 0; }

.import-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: center;
}

/* ---- Modals ---------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: var(--z-modal);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn var(--transition-base);
}

.modal-backdrop.hidden { display: none; }

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

.modal {
  background: white;
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  animation: slideUp var(--transition-base);
}

.modal-sm { width: 480px; }
.modal-md { width: 560px; }
.modal-lg { width: 640px; }
.modal-xl { width: 900px; }

.modal-header {
  display: flex;
  align-items: center;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  gap: var(--space-3);
}

.modal-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  flex: 1;
}

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--color-text-secondary);
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  line-height: 1;
}
.modal-close:hover { color: var(--color-text-primary); background: var(--color-content-bg); }

.modal-body {
  padding: var(--space-6);
  overflow-y: auto;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--color-border);
  gap: var(--space-3);
  flex-shrink: 0;
}

/* ---- Image Library Modal --------------------------------- */
.image-library-search-bar {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.image-library-search-bar input {
  flex: 1;
  height: 34px;
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-md);
  font-size: var(--font-size-base);
  outline: none;
}
.image-library-search-bar input:focus { border-color: var(--color-meta-blue); }

.image-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: var(--space-3);
  max-height: 400px;
  overflow-y: auto;
}

.image-card {
  border: 2px solid transparent;
  border-radius: var(--radius-lg);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition-fast), transform var(--transition-fast);
  background: var(--color-content-bg);
}

.image-card:hover { border-color: var(--color-border-strong); transform: translateY(-2px); }
.image-card.selected { border-color: var(--color-meta-blue); }

.image-card-thumb {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--color-border);
}

.image-card-thumb-placeholder {
  width: 100%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: var(--color-text-disabled);
}

.image-card-info {
  padding: var(--space-2);
}
.image-card-name {
  font-size: 11px;
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.image-card-hash {
  font-size: 10px;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.image-library-selected-info {
  padding: var(--space-3);
  background: var(--color-meta-blue-light);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  margin-top: var(--space-3);
  min-height: 40px;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.image-library-empty {
  grid-column: span 5;
  text-align: center;
  padding: var(--space-8);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
}

/* ---- Settings Panel -------------------------------------- */
#settings-panel {
  position: fixed;
  top: 0; right: 0; bottom: 0;
  width: var(--width-settings-panel);
  background: white;
  z-index: var(--z-panel);
  box-shadow: -4px 0 24px rgba(0,0,0,0.12);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--transition-slow);
}

#settings-panel.open { transform: translateX(0); }

#settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  z-index: calc(var(--z-panel) - 1);
  display: none;
  animation: fadeIn var(--transition-slow);
}
#settings-backdrop.open { display: block; }

.settings-header {
  height: var(--height-toolbar);
  display: flex;
  align-items: center;
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--color-border);
  gap: var(--space-3);
  flex-shrink: 0;
}

.settings-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  flex: 1;
}

.settings-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-6);
}

.settings-section {
  margin-bottom: var(--space-6);
}

.settings-section-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: var(--space-3);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--color-border);
}

.token-status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  margin-bottom: var(--space-3);
}
.token-status-pill.valid { background: var(--color-success-bg); color: #065F46; }
.token-status-pill.invalid { background: var(--color-error-bg); color: #991B1B; }
.token-status-pill.unknown { background: var(--color-warning-bg); color: #92400E; }

.token-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}
.token-status-pill.valid .token-status-dot { background: var(--color-success); }
.token-status-pill.invalid .token-status-dot { background: var(--color-danger); }
.token-status-pill.unknown .token-status-dot { background: var(--color-warning); }

.password-field-wrapper {
  position: relative;
}
.password-field-wrapper .form-control { padding-right: 36px; }
.password-reveal-btn {
  position: absolute;
  right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none;
  color: var(--color-text-secondary);
  font-size: 14px; cursor: pointer; padding: 2px;
}
.password-reveal-btn:hover { color: var(--color-text-primary); }

.image-cache-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2) var(--space-3);
  background: var(--color-content-bg);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  margin-bottom: var(--space-3);
  font-size: var(--font-size-sm);
}

/* ---- New Campaign/Ad Set Dialog -------------------------- */
.template-list {
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: var(--space-3);
}

.template-item {
  display: flex;
  align-items: center;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
  border-bottom: 1px solid var(--color-border);
  transition: background var(--transition-fast);
  gap: var(--space-2);
}
.template-item:last-child { border-bottom: none; }
.template-item:hover { background: var(--color-content-bg); }
.template-item.selected { background: var(--color-meta-blue-light); }

.template-item-name {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  flex: 1;
}
.template-item-meta {
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.template-item-rich {
  display: block;
  padding: 9px 12px;
}

.template-item-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-width: 0;
}

.template-item-rich .template-item-name {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-item-budget {
  flex: 0 0 auto;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

.template-item-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 3px;
  min-width: 0;
  font-size: var(--font-size-xs);
  color: var(--color-text-secondary);
}

.template-item-sub span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.template-item-dot {
  color: var(--color-text-disabled);
  flex: 0 0 auto;
}

.template-preview-fields-wide {
  grid-template-columns: 1fr 1fr;
}

.preview-field-full {
  grid-column: 1 / -1;
}

.template-preview {
  background: var(--color-content-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  margin-bottom: var(--space-3);
  font-size: var(--font-size-sm);
}

.template-preview-title {
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: var(--space-2);
}

.template-preview-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-1) var(--space-4);
}

.preview-field { font-size: var(--font-size-xs); color: var(--color-text-secondary); }
.preview-field span { color: var(--color-text-primary); font-weight: var(--font-weight-medium); }

/* ---- Export Validation Modal ----------------------------- */
.validation-section { margin-bottom: var(--space-4); }

.validation-section-title {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.validation-section-title.errors { color: var(--color-danger); }
.validation-section-title.warnings { color: var(--color-warning); }

.validation-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 200px;
  overflow-y: auto;
}

.validation-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  background: var(--color-content-bg);
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
}

.validation-item.error { background: var(--color-error-bg); }
.validation-item.warning { background: var(--color-warning-bg); }

.validation-item-icon { flex-shrink: 0; font-size: 14px; margin-top: 1px; }
.validation-item-msg { flex: 1; color: var(--color-text-primary); }
.validation-go-to {
  background: none; border: none;
  color: var(--color-meta-blue);
  font-size: var(--font-size-xs);
  cursor: pointer;
  white-space: nowrap;
  padding: 0;
  text-decoration: underline;
}

.validation-success {
  text-align: center;
  padding: var(--space-6);
  color: var(--color-success);
  font-size: var(--font-size-md);
}

/* ---- Toast Notifications --------------------------------- */
#toast-container {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  min-width: 280px;
  max-width: 380px;
  border-left: 4px solid var(--color-border);
  pointer-events: all;
  animation: slideInRight var(--transition-base);
  font-size: var(--font-size-sm);
}

@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left-color: var(--color-success); }
.toast.error { border-left-color: var(--color-danger); }
.toast.warning { border-left-color: var(--color-warning); }
.toast.info { border-left-color: var(--color-info); }

.toast-icon { font-size: 18px; flex-shrink: 0; }
.toast-msg { flex: 1; color: var(--color-text-primary); }
.toast-dismiss {
  background: none; border: none;
  color: var(--color-text-disabled);
  font-size: 16px; cursor: pointer;
  padding: 2px; line-height: 1;
}
.toast-dismiss:hover { color: var(--color-text-secondary); }

/* ---- Tooltip --------------------------------------------- */
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1F2937;
  color: white;
  font-size: var(--font-size-xs);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 400ms;
  z-index: var(--z-tooltip);
}
[data-tooltip]:hover::after { opacity: 1; }

/* ---- Loading overlay ------------------------------------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.75);
  z-index: calc(var(--z-modal) + 5);
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: var(--space-3);
}
.loading-overlay.visible { display: flex; }

.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-meta-blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-msg {
  font-size: var(--font-size-md);
  color: var(--color-text-secondary);
}

/* ---- Utilities ------------------------------------------- */
.hidden { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.text-mono { font-family: var(--font-mono); }
.text-sm { font-size: var(--font-size-sm); }
.text-secondary { color: var(--color-text-secondary); }
.flex-center { display: flex; align-items: center; justify-content: center; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.mt-3 { margin-top: var(--space-3); }
.mb-3 { margin-bottom: var(--space-3); }
.w-full { width: 100%; }


/* ---- AG Grid column filter icon clarity ------------------- */
.f15-column-filter-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  background-color: var(--color-text-secondary);
  opacity: 0.72;
  vertical-align: middle;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5h16l-6.5 7.5v5L10.5 19v-6.5L4 5z'/%3E%3C/svg%3E") center / contain no-repeat;
          mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 5h16l-6.5 7.5v5L10.5 19v-6.5L4 5z'/%3E%3C/svg%3E") center / contain no-repeat;
}

.ag-theme-alpine .ag-header-cell-menu-button:hover .f15-column-filter-icon,
.ag-theme-alpine .ag-header-cell-menu-button.ag-header-cell-menu-button-active .f15-column-filter-icon {
  background-color: var(--color-meta-blue);
  opacity: 1;
}

.ag-theme-alpine .ag-header-cell-menu-button {
  border-radius: 4px;
}

.ag-theme-alpine .ag-header-cell-menu-button:hover {
  background: var(--color-meta-blue-light);
}

/* Filter bar */
.filter-bar {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  background: var(--color-panel-bg);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
  align-items: center;
}
.filter-bar.hidden { display: none; }

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border-strong);
  background: white;
  font-size: var(--font-size-xs);
  cursor: pointer;
  transition: background var(--transition-fast);
}
.filter-chip:hover { background: var(--color-content-bg); }
.filter-chip.active {
  background: var(--color-meta-blue-light);
  border-color: var(--color-meta-blue);
  color: var(--color-meta-blue);
}

.filter-chip-clear {
  background: none; border: none;
  color: var(--color-text-secondary);
  font-size: 12px; cursor: pointer; padding: 0;
}

/* Shared post badge */
.shared-post-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: #EDE9FE;
  color: #6D28D9;
  font-size: 10px;
  font-weight: var(--font-weight-semibold);
}

/* ---- Responsive adjustments ----------------------------- */
@media (max-width: 1024px) {
  #sidebar { width: 200px; min-width: 200px; }
  --width-sidebar: 200px;
}

/* ---- Settings clarity states ------------------------------ */
.settings-optional-label {
  display: inline-flex;
  align-items: center;
  margin-left: var(--space-2);
  padding: 1px 6px;
  border-radius: var(--radius-full);
  background: #EEF2FF;
  color: #4338CA;
  font-size: 10px;
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  vertical-align: middle;
}

.settings-section-note {
  margin: -4px 0 var(--space-3);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  line-height: 1.4;
}

.settings-shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  color: var(--color-text-secondary);
}

.settings-shortcut-row {
  display: flex;
  justify-content: space-between;
  gap: var(--space-3);
  align-items: center;
}

.settings-shortcut-row code {
  font-family: var(--font-mono);
  background: #F3F4F6;
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--color-text-secondary);
  white-space: nowrap;
}

/* ---- New Ad from Template live preview -------------------- */
.template-preview-section + .template-preview-section {
  margin-top: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border);
}

.template-preview-live {
  background: rgba(37, 99, 235, 0.04);
  border-radius: var(--radius-sm);
  padding: var(--space-2);
}

.template-preview-live .preview-field span {
  overflow-wrap: anywhere;
}

/* ---- How to Use Tab -------------------------------------- */
.tab-btn-help {
  color: var(--color-text-primary);
}

#how-to-use-panel {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: var(--color-content-bg);
  padding: 24px;
}

.howto-wrap {
  max-width: 1180px;
  margin: 0 auto;
}

.howto-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  align-items: stretch;
  margin-bottom: 20px;
}

.howto-kicker {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: #E8F1FF;
  color: var(--color-meta-blue);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 10px;
}

.howto-hero h2 {
  margin: 0 0 8px;
  font-size: 26px;
  line-height: 1.2;
  color: var(--color-text-primary);
}

.howto-hero p {
  margin: 0;
  color: var(--color-text-secondary);
  font-size: 14px;
  line-height: 1.55;
  max-width: 760px;
}

.howto-status-card {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 16px;
  background: var(--color-panel-bg);
  box-shadow: var(--shadow-sm);
}

.howto-status-card strong {
  display: block;
  color: var(--color-text-primary);
  font-size: 14px;
  margin-bottom: 6px;
}

.howto-status-card span {
  color: var(--color-text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.howto-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.howto-card {
  border: 1px solid var(--color-border);
  border-radius: 12px;
  background: var(--color-panel-bg);
  padding: 16px 18px;
  box-shadow: var(--shadow-sm);
}

.howto-card h3 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--color-text-primary);
}

.howto-card p {
  margin: 0 0 10px;
  color: var(--color-text-secondary);
  font-size: 13px;
  line-height: 1.45;
}

.howto-card ol,
.howto-card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--color-text-secondary);
  font-size: 13px;
  line-height: 1.55;
}

.howto-card li + li {
  margin-top: 4px;
}

.howto-card strong {
  color: var(--color-text-primary);
}

.howto-card-warning {
  border-color: #FCD34D;
  background: #FFFBEB;
}

@media (max-width: 900px) {
  .howto-hero,
  .howto-grid {
    grid-template-columns: 1fr;
  }
}

/* ---- How to Use access before import --------------------- */
#empty-howto-link {
  color: var(--color-meta-blue);
  font-weight: var(--font-weight-semibold);
  text-decoration: none;
}

#empty-howto-link:hover {
  text-decoration: underline;
}

.howto-modal {
  width: min(960px, calc(100vw - 32px));
}

.howto-modal-body {
  padding: 22px 24px;
}

.howto-modal .howto-wrap {
  max-width: none;
}

.howto-modal .howto-hero {
  grid-template-columns: minmax(0, 1fr) 280px;
}

@media (max-width: 900px) {
  .howto-modal .howto-hero {
    grid-template-columns: 1fr;
  }
}


/* ============================================================
   Video V1 — template/context helpers
   ============================================================ */
.new-ad-template-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 8px;
}
.new-ad-creative-filter {
  min-width: 0;
}
.new-ad-template-hint {
  margin: 6px 0 8px;
}
.template-item-video {
  border-left: 3px solid #7C3AED;
}
.template-type-video {
  background: #EDE9FE;
  color: #5B21B6;
}
.template-item-asset {
  margin-top: 4px;
  overflow: hidden;
  color: var(--color-text-secondary);
  font-family: var(--font-mono);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-field-video {
  border-left: 3px solid #7C3AED;
  padding-left: 8px;
}
.media-cell {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  gap: 6px;
  overflow: hidden;
  white-space: nowrap;
}
.media-cell span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-cell-icon {
  flex: 0 0 auto;
}
.media-cell-video {
  color: #5B21B6;
  font-weight: 600;
}
.video-asset-notice {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid #DDD6FE;
  border-radius: 8px;
  background: #F5F3FF;
  color: #4C1D95;
}
.video-asset-notice-icon {
  line-height: 1.2;
}
.video-asset-notice strong,
.video-asset-notice span,
.video-asset-notice small {
  display: block;
}
.video-asset-notice span {
  margin-top: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  overflow-wrap: anywhere;
}
.video-asset-notice small {
  margin-top: 4px;
  color: #6B21A8;
  font-size: 11px;
}
@media (max-width: 720px) {
  .new-ad-template-tools {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   Public workflow V1 refinements
   ============================================================ */
.btn:disabled,
.btn-toolbar:disabled {
  cursor: not-allowed;
}

@media (max-width: 760px) {
  #toolbar {
    overflow-x: auto;
    overflow-y: hidden;
    gap: 6px;
    padding: 0 10px;
    scrollbar-width: thin;
  }

  .toolbar-brand-name,
  .toolbar-sep {
    display: none;
  }

  .toolbar-brand {
    margin-right: 2px;
  }

  .btn-toolbar {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  #tab-bar {
    overflow-x: auto;
    overflow-y: hidden;
  }

  .tab-btn,
  .tab-bar-actions {
    flex: 0 0 auto;
  }

  #sidebar {
    width: 180px;
    min-width: 180px;
  }
}


/* ============================================================
   Public workflow v1.0.6 — New Ad modal fit / overflow cleanup
   ============================================================ */
#new-ad-modal .modal-lg {
  width: min(780px, calc(100vw - 32px));
  max-width: calc(100vw - 32px);
}

#new-ad-modal .modal-body {
  overflow-x: hidden;
}

#new-ad-modal .form-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
}

#new-ad-modal .form-grid.single {
  grid-template-columns: minmax(0, 1fr);
}

#new-ad-modal .form-group,
#new-ad-modal .new-ad-template-tools,
#new-ad-modal .template-item-main,
#new-ad-modal .template-item-sub {
  min-width: 0;
}

#new-ad-modal .form-control,
#new-ad-modal textarea,
#new-ad-modal select,
#new-ad-modal input {
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

#new-ad-modal .template-item-sub > span:not(.template-item-dot) {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#new-ad-modal .template-item-budget {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 720px) {
  #new-ad-modal .modal-lg {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
  }

  #new-ad-modal .modal-body {
    padding: 16px;
  }

  #new-ad-modal .form-grid,
  #new-ad-modal .new-ad-template-tools {
    grid-template-columns: minmax(0, 1fr);
  }
}
