/* ==========================================================================
   GrowthCanvas UI Components
   ========================================================================== */

/* ==========================================================================
   Cards
   ========================================================================== */
.card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 6px 20px #00000022;
  transition: all 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: grid-column;
}

/* Internal section headers - default styling */
.card h3 {
  margin: 0 0 6px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--muted);
}

/* Main card title header - styled with shading and separator */
.card > h3:first-of-type {
  margin: -14px -14px 12px -14px;
  padding: 14px 14px 10px 84px;
  border-bottom: 2px solid var(--line);
  background: rgba(0, 0, 0, 0.06);
  border-radius: 14px 14px 0 0;
}

.theme-dark .card > h3:first-of-type,
.theme-ocean .card > h3:first-of-type {
  background: rgba(255, 255, 255, 0.04);
}

.card h2 {
  margin: 0 0 6px;
  font-size: 16px;
}

.card.selected {
  border: 2px solid var(--accent);
  box-shadow: 0 0 0 3px #ff6a0033;
}

/* Panel expansion animation highlight */
.card.expanding {
  border-color: var(--accent);
  box-shadow: 0 6px 30px rgba(139, 92, 246, 0.3);
}

/* ==========================================================================
   Tags & Badges
   ========================================================================== */
.kv {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.tag {
  font-size: 12px;
  border: 1px solid var(--line);
  padding: 4px 8px;
  border-radius: 999px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
}

.b-ok { background: #16a34a20; color: var(--ok); }
.b-warn { background: #f59e0b20; color: var(--warn); }
.b-bad { background: #ef444420; color: var(--bad); }

/* ==========================================================================
   Icons & Panel Numbers
   ========================================================================== */
.icons {
  position: absolute;
  top: 8px;
  right: 8px;
  display: flex;
  gap: 6px;
}

.icon {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: var(--card);
}

.icon:hover {
  border-color: var(--accent);
}

.icon.done::after {
  content: "✓";
  position: absolute;
  top: -6px;
  right: -6px;
  background: #16a34a;
  color: #fff;
  border-radius: 999px;
  font-size: 10px;
  padding: 2px 4px;
}

.panel-number {
  position: absolute;
  top: 8px;
  left: 8px;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 14px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Panel Quality Indicators
   ========================================================================== */
.panel-quality {
  position: absolute;
  top: 8px;
  left: 42px;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 700;
  cursor: help;
  transition: transform 0.2s, opacity 0.3s;
  opacity: 0;
  pointer-events: none;
  z-index: 10;
}

.panel-quality.visible {
  opacity: 1;
  pointer-events: auto;
}

.panel-quality:hover {
  transform: scale(1.15);
  z-index: 9999;
}

.panel-quality.quality-good { background: var(--ok); color: #fff; border-radius: 50%; }
.panel-quality.quality-warn { background: var(--warn); color: #fff; border-radius: 50%; }
.panel-quality.quality-bad { background: var(--bad); color: #fff; border-radius: 50%; }

.panel-quality-tooltip {
  position: absolute;
  top: 100%;
  left: -10px;
  width: 300px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  padding-top: 20px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.35);
  z-index: 9999;
  font-size: 12px;
  text-align: left;
  font-weight: 400;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease-in-out, visibility 0.15s ease-in-out;
  pointer-events: none;
}

.panel-quality-tooltip::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 16px;
  background: transparent;
}

.panel-quality:hover .panel-quality-tooltip {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0.1s;
}

.panel-quality-tooltip:hover {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.panel-quality-tooltip h4 {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--text);
  border-bottom: 1px solid var(--line);
  padding-bottom: 6px;
}

.panel-quality-tooltip .pq-item {
  margin-bottom: 10px;
  padding: 8px 8px 8px 12px;
  border-left: 3px solid var(--line);
  border-radius: 0 6px 6px 0;
  transition: background 0.15s, transform 0.15s;
  cursor: default;
}

.panel-quality-tooltip .pq-item:hover {
  background: var(--bg);
  transform: translateX(4px);
}

.panel-quality-tooltip .pq-item:last-child {
  margin-bottom: 0;
}

.panel-quality-tooltip .pq-item.pq-high { border-left-color: var(--bad); }
.panel-quality-tooltip .pq-item.pq-medium { border-left-color: var(--warn); }
.panel-quality-tooltip .pq-item.pq-low { border-left-color: var(--ok); }

.panel-quality-tooltip .pq-title {
  font-weight: 600;
  margin-bottom: 2px;
  color: var(--text);
}

.panel-quality-tooltip .pq-message {
  color: var(--muted);
  line-height: 1.4;
}

.panel-quality-tooltip .pq-empty {
  color: var(--ok);
  font-style: italic;
}

/* ==========================================================================
   Tables
   ========================================================================== */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
}

th, td {
  padding: 10px 12px;
  border-bottom: 1px dashed var(--line);
  vertical-align: top;
  word-wrap: break-word;
}

th {
  color: var(--muted);
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  background: var(--bg);
  border: 1px solid var(--line);
}

td {
  border: 1px solid var(--line);
  font-size: 13px;
}

/* Ensure first column has adequate width */
th:first-child, td:first-child {
  min-width: 120px;
  max-width: 200px;
}

/* Better table formatting in chat messages */
.chat-message table {
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.chat-message th {
  background: var(--card);
  padding: 8px 10px;
}

.chat-message td {
  padding: 8px 10px;
}

.chat-message tbody tr:hover {
  background: rgba(255, 106, 0, 0.05);
}

/* ==========================================================================
   Designation Tracking Table
   ========================================================================== */
.designation-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.designation-table th {
  background: var(--bg);
  padding: 10px 8px;
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* Score column headers (designation names) - limit width */
.designation-table th:not(:first-child):not(:nth-child(2)) {
  max-width: 150px;
  min-width: 120px;
  width: 150px;
}

.designation-table td {
  padding: 8px;
  border: 1px solid var(--line);
  text-align: center;
}

.designation-table .category-cell {
  text-align: left;
  font-weight: 600;
  background: var(--bg);
}

.designation-table .subcategory-cell {
  text-align: left;
  padding-left: 12px;
  font-size: 11px;
  background: var(--bg);
}

.designation-table .score-cell {
  position: relative;
  cursor: pointer;
  padding: 6px 4px;
  max-width: 150px;
  min-width: 120px;
  width: 150px;
}

.designation-table .score-cell input {
  width: 50%;
  background: transparent;
  border: none;
  color: var(--text);
  text-align: right;
  padding: 4px 10px 4px 4px;
  font-size: 12px;
}

.designation-table .score-cell input:focus {
  outline: 2px solid var(--accent);
  border-radius: 4px;
}

.designation-table .score-cell input[type="number"]::-webkit-inner-spin-button {
  margin-left: 8px;
}

.designation-table .score-cell .max-value {
  color: var(--muted);
  font-size: 12px;
  margin-left: 2px;
}

.designation-table .total-row {
  font-weight: 700;
  background: var(--bg);
  border-top: 2px solid var(--line);
}

.designation-table .cell-green { background: #16a34a30; border-color: var(--ok); }
.designation-table .cell-amber { background: #f59e0b30; border-color: var(--warn); }
.designation-table .cell-red { background: #ef444430; border-color: var(--bad); }

.designation-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.designation-controls button {
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
}

.designation-controls button:hover {
  opacity: 0.9;
}

.designation-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11px;
  margin: 2px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.designation-badge:hover {
  opacity: 0.8;
}

.designation-badge .remove {
  margin-left: 6px;
  font-weight: bold;
  cursor: pointer;
}

/* ==========================================================================
   Focus Mode
   ========================================================================== */
.icon.focus {
  font-size: 14px;
  font-weight: bold;
}

.icon.focus.active {
  color: var(--accent);
}

.card.focus-hidden {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
  position: absolute;
  visibility: hidden;
}

.card.focus-active {
  border-color: var(--accent);
  box-shadow: 0 8px 40px rgba(255, 106, 0, 0.25);
  z-index: 10;
  min-height: calc(100vh - 180px);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.card.focus-animating {
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.focus-exit-btn {
  position: fixed;
  bottom: 24px;
  right: 440px;
  background: var(--accent);
  color: #fff;
  border: none;
  padding: 12px 24px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  z-index: 100;
  display: none;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
}

.focus-exit-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.4);
}

body.focus-mode-active .focus-exit-btn {
  display: flex;
}

.focus-badge {
  position: absolute;
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: #fff;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.card.focus-active .focus-badge {
  opacity: 1;
}

@media (max-width: 1200px) {
  .focus-exit-btn {
    right: 24px;
    bottom: 80px;
  }
}

/* ==========================================================================
   Modals
   ========================================================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.modal .panel {
  width: min(780px, 92vw);
  max-height: 90vh;
  background: var(--card);
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 0 0 1px var(--line), 0 8px 32px rgba(0, 0, 0, 0.5), 0 0 60px rgba(255, 106, 0, 0.15);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Body scroll lock when modal is open */
body.modal-open {
  overflow: hidden;
}

/* Theme-specific modal panel styling */
.theme-light .modal .panel {
  background: #ffffff;
  border-color: #e5e7eb;
  box-shadow: 0 0 0 1px #d1d5db, 0 8px 40px rgba(0, 0, 0, 0.25), 0 0 0 4px rgba(0, 0, 0, 0.05);
}

.theme-ocean .modal .panel {
  border-color: #11b5e4;
  box-shadow: 0 0 0 1px var(--line), 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 60px rgba(17, 181, 228, 0.2);
}

.theme-dark .modal .panel {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--line), 0 8px 32px rgba(0, 0, 0, 0.7), 0 0 60px rgba(255, 106, 0, 0.15);
}

.modal.with-listen .panel {
  width: min(1400px, 90vw);
  max-height: 75vh;
  display: flex;
  flex-direction: column;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  position: relative;
}

.modal-header h3 {
  margin: 0;
}

/* Maximize button styles */
.modal-maximize-btn {
  position: absolute;
  top: 0;
  right: 0;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  font-size: 16px;
  z-index: 10;
}

.modal-maximize-btn:hover {
  background: var(--bg);
  border-color: var(--accent);
  color: var(--accent);
}

.modal-maximize-btn svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Maximized modal state */
.modal.maximized .panel {
  width: 100vw !important;
  height: 100vh !important;
  max-width: 100vw !important;
  max-height: 100vh !important;
  border-radius: 0;
  margin: 0;
}

.modal.maximized .modal-maximize-btn svg.maximize-icon {
  display: none;
}

.modal.maximized .modal-maximize-btn svg.restore-icon {
  display: block;
}

.modal-maximize-btn svg.restore-icon {
  display: none;
}

.modal .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
}

/* ==========================================================================
   Forms
   ========================================================================== */
input, textarea, select {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 10px;
}

.row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.row.onecol {
  grid-template-columns: 1fr;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Question field grouping in modals - clean paper-like flow */
.modal .field {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 0 0 16px 0;
  margin-bottom: 16px;
}

.modal .field:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

/* Modal form elements - clean inset textarea styling */
.modal .field input,
.modal .field textarea,
.modal .field select {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06);
  transition: border-color 0.2s, box-shadow 0.2s;
  color: var(--text);
}

.modal .field input:focus,
.modal .field textarea:focus,
.modal .field select:focus {
  border-color: var(--accent);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.06), 0 0 0 2px rgba(255, 106, 0, 0.1);
  outline: none;
}

/* Question labels in modals */
.modal .field label {
  font-weight: 500;
  color: var(--muted);
  font-size: 13px;
  padding: 0;
  margin-bottom: 6px;
}

/* Light theme */
.theme-light .modal .field {
  border-bottom-color: #e5e7eb;
}

.theme-light .modal .field input,
.theme-light .modal .field textarea,
.theme-light .modal .field select {
  background: #f8fafc;
  border: 1px solid #d1d5db;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04);
}

.theme-light .modal .field input:focus,
.theme-light .modal .field textarea:focus,
.theme-light .modal .field select:focus {
  border-color: #2563eb;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.04), 0 0 0 2px rgba(37, 99, 235, 0.1);
}

/* Ocean theme */
.theme-ocean .modal .field {
  border-bottom-color: #1a3a4a;
}

.theme-ocean .modal .field input,
.theme-ocean .modal .field textarea,
.theme-ocean .modal .field select {
  background: #071018;
  border: 1px solid #1a4a5a;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15);
}

.theme-ocean .modal .field input:focus,
.theme-ocean .modal .field textarea:focus,
.theme-ocean .modal .field select:focus {
  border-color: #11b5e4;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.15), 0 0 0 2px rgba(17, 181, 228, 0.15);
}

/* Dark theme */
.theme-dark .modal .field {
  border-bottom-color: #21262d;
}

.theme-dark .modal .field input,
.theme-dark .modal .field textarea,
.theme-dark .modal .field select {
  background: #0d1117;
  border: 1px solid #30363d;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2);
}

.theme-dark .modal .field input:focus,
.theme-dark .modal .field textarea:focus,
.theme-dark .modal .field select:focus {
  border-color: #ff6a00;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 0 2px rgba(255, 106, 0, 0.15);
}

/* ==========================================================================
   Partner Selector
   ========================================================================== */
.partner-selector {
  position: relative;
  min-width: 280px;
}

.partner-selector-input {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 12px;
  cursor: pointer;
  transition: all 0.2s;
}

.partner-selector-input:hover {
  border-color: var(--accent);
}

.partner-selector-input.open {
  border-color: var(--accent);
  border-radius: 8px 8px 0 0;
}

.partner-selector-input .partner-display {
  flex: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.partner-selector-input .partner-display.placeholder {
  color: var(--muted);
  font-weight: 400;
}

.partner-edit-btn {
  background: transparent;
  border: none;
  font-size: 14px;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  opacity: 0.6;
  transition: all 0.2s;
}

.partner-edit-btn:hover {
  opacity: 1;
  background: var(--bg-hover);
}

.partner-selector-input .dropdown-arrow {
  font-size: 10px;
  color: var(--muted);
  transition: transform 0.2s;
}

.partner-selector-input.open .dropdown-arrow {
  transform: rotate(180deg);
}

.partner-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--card);
  border: 1px solid var(--accent);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 300px;
  overflow: hidden;
  display: none;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.partner-dropdown.open {
  display: block;
}

.partner-dropdown-search {
  padding: 8px;
  border-bottom: 1px solid var(--line);
}

.partner-dropdown-search input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}

.partner-dropdown-search input:focus {
  outline: none;
  border-color: var(--accent);
}

.partner-dropdown-list {
  max-height: 200px;
  overflow-y: auto;
}

.partner-dropdown-item {
  padding: 10px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  border-bottom: 1px solid var(--line);
}

.partner-dropdown-item:last-child {
  border-bottom: none;
}

.partner-dropdown-item:hover {
  background: var(--bg);
}

.partner-dropdown-item.selected {
  background: var(--accent);
  color: #fff;
}

.partner-dropdown-item .partner-meta {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
}

.partner-dropdown-item.selected .partner-meta {
  color: rgba(255, 255, 255, 0.7);
}

.partner-dropdown-create {
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--accent);
  font-weight: 600;
}

.partner-dropdown-create:hover {
  background: var(--line);
}

.partner-dropdown-empty {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.partner-dropdown-loading {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.partner-dropdown-loading .spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

/* ==========================================================================
   Theme Toggle
   ========================================================================== */
.theme-toggle {
  display: flex;
  gap: 0;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
}

.theme-toggle button {
  padding: 6px 12px;
  border: none;
  background: var(--card);
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s;
}

.theme-toggle button:hover {
  background: var(--bg);
}

.theme-toggle button.active {
  background: var(--accent);
  color: #fff;
}

.theme-toggle button:first-child {
  border-radius: 5px 0 0 5px;
}

.theme-toggle button:last-child {
  border-radius: 0 5px 5px 0;
}

/* ==========================================================================
   Autosave Indicator
   ========================================================================== */
.autosave-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid var(--line);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.autosave-indicator.visible {
  opacity: 1;
}

.autosave-indicator.saving {
  color: var(--warn);
}

.autosave-indicator.saved {
  color: var(--ok);
}

.autosave-indicator.error {
  color: var(--bad);
}

.autosave-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--line);
  border-top-color: var(--warn);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.autosave-indicator.saved .autosave-spinner {
  display: none;
}

.autosave-indicator.error .autosave-spinner {
  display: none;
}

/* ==========================================================================
   Export Dropdown
   ========================================================================== */
.export-dropdown {
  position: relative;
  display: inline-block;
}

.export-dropdown-btn {
  display: flex;
  align-items: center;
  gap: 6px;
}

.export-dropdown-content {
  display: none;
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 140px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
}

.export-dropdown.open .export-dropdown-content {
  display: block;
}

.export-dropdown-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.export-dropdown-item:hover {
  background: var(--bg);
}

.export-dropdown-item:first-child {
  border-radius: 7px 7px 0 0;
}

.export-dropdown-item:last-child {
  border-radius: 0 0 7px 7px;
}

/* ==========================================================================
   Loading & Spinners
   ========================================================================== */
.loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  border-radius: 12px;
}

.spinner {
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-top: 3px solid var(--accent);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulse-border {
  0%, 100% { border-color: var(--line); }
  50% { border-color: var(--accent); }
}

/* ROI field fade-in animation */
.roi-field {
  transition: opacity 0.6s ease-in-out, max-width 0.6s ease-in-out;
}

.roi-field[style*="display: none"] {
  opacity: 0;
  max-width: 0;
  overflow: hidden;
}

.roi-field[style*="display: table-cell"] {
  opacity: 1;
  max-width: none;
}

/* ==========================================================================
   Rich Text Editor
   ========================================================================== */
.rich-editor {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.rich-toolbar {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--line);
  background: var(--card);
  flex-wrap: wrap;
}

.rich-toolbar button {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  min-width: 32px;
}

.rich-toolbar button:hover {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.rich-toolbar button.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.rich-content {
  padding: 12px;
  min-height: 120px;
  max-height: 300px;
  overflow-y: auto;
  outline: none;
  line-height: 1.6;
}

.rich-content ul, .rich-content ol {
  margin: 6px 0 0 20px;
  padding: 0;
}

.rich-content li {
  margin: 4px 0;
}

.rich-content p {
  margin: 8px 0;
}

.rich-content strong {
  font-weight: 700;
}

.rich-content em {
  font-style: italic;
}

/* ==========================================================================
   Infographic Config Modal
   ========================================================================== */
#infographicConfigModal .panel {
  width: min(620px, 92vw);
  max-height: 85vh;
  display: flex;
  flex-direction: column;
}

#infographicConfigModal .modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

#infographicConfigModal .modal-footer {
  padding: 16px 20px;
  border-top: 1px solid var(--line);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.config-section {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}

.config-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.config-section h4 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px;
  color: var(--text);
}

.config-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 12px;
}

.scope-checkboxes {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.scope-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.scope-checkbox:hover {
  background: var(--bg);
  border-color: var(--accent);
}

.scope-checkbox input {
  margin-top: 2px;
  accent-color: var(--accent);
}

.scope-checkbox .checkbox-label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.scope-checkbox .checkbox-label strong {
  font-size: 13px;
  color: var(--text);
}

.scope-checkbox .checkbox-label small {
  font-size: 11px;
  color: var(--muted);
}

.scope-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.scope-actions button {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  transition: all 0.2s;
}

.scope-actions button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.toggle-group {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 4px;
  border-radius: 8px;
  flex-wrap: wrap;
}

.toggle-group button {
  flex: 1;
  min-width: 80px;
  padding: 10px 12px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  transition: all 0.2s;
}

.toggle-group button.active {
  background: var(--accent);
  color: #fff;
}

.toggle-group button:hover:not(.active) {
  background: var(--line);
  color: var(--text);
}

#customInstructions {
  width: 100%;
  min-height: 80px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  resize: vertical;
  font-size: 13px;
  font-family: inherit;
  background: var(--bg);
  color: var(--text);
}

#customInstructions::placeholder {
  color: var(--muted);
}

.btn-secondary {
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-primary {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 10px 24px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.2s;
}

.btn-primary:hover {
  opacity: 0.9;
}

/* ==========================================================================
   Asset History
   ========================================================================== */
.asset-history-section {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 2px solid var(--line);
}

.asset-history-section h3 {
  font-size: 15px;
  margin: 0 0 12px;
  color: #06b6d4;
  font-weight: 600;
}

.asset-card {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 10px;
  position: relative;
  transition: border-color 0.2s;
}

.asset-card:hover {
  border-color: #06b6d4;
}

.asset-card .asset-name {
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 4px;
  color: var(--text);
}

.asset-card .asset-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.asset-card .asset-type-badge {
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 4px;
  background: #06b6d420;
  color: #06b6d4;
  border: 1px solid #06b6d4;
  font-weight: 600;
  text-transform: uppercase;
}

.asset-card .asset-date {
  font-size: 11px;
  color: var(--muted);
}

.asset-card .asset-actions {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.asset-card .asset-actions a {
  flex: 1;
  text-decoration: none;
  padding: 6px 10px;
  background: #06b6d4;
  color: #fff;
  border-radius: 6px;
  font-size: 11px;
  text-align: center;
  font-weight: 600;
  transition: background 0.2s;
}

.asset-card .asset-actions a:hover {
  background: #0891b2;
}

.asset-card .delete-asset {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bad);
  color: #fff;
  border: none;
  border-radius: 4px;
  width: 22px;
  height: 22px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.asset-card:hover .delete-asset {
  opacity: 1;
}

.asset-card .delete-asset:hover {
  background: #dc2626;
}

.asset-history-empty {
  padding: 16px;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px dashed var(--line);
}

.load-more-link {
  display: block;
  text-align: center;
  padding: 12px;
  color: #ec4899;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: 1px dashed #ec4899;
  border-radius: 8px;
  margin-top: 12px;
  transition: all 0.2s;
}

.load-more-link:hover {
  background: #ec489910;
  border-style: solid;
}

/* Asset Preview Popup */
.asset-preview-popup {
  position: fixed;
  z-index: 9999;
  background: var(--card);
  border: 2px solid var(--accent);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
  overflow: hidden;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.asset-preview-popup.visible {
  opacity: 1;
}

.asset-preview-popup iframe {
  width: 100%;
  height: 100%;
  border: none;
  background: #fff;
}

.asset-preview-popup .preview-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--muted);
  font-size: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.asset-preview-popup .preview-loading .spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.asset-card .preview-btn {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.asset-card .preview-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent)10;
}

.brand-logo-preview {
  margin-bottom: 16px;
}

.brand-logo-preview h4 {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.brand-logo-preview img {
  max-width: 100%;
  max-height: 80px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  padding: 8px;
}

/* Dev tests */
#tests {
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

/* Partner Name Field */
.partner-name-field {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.partner-name-field label {
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.partner-name-field input {
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  min-width: 250px;
}

.partner-name-field input:focus {
  outline: 2px solid var(--accent);
  border-color: var(--accent);
}

.partner-name-field .partner-id {
  font-size: 11px;
  color: var(--muted);
  padding: 4px 8px;
  background: var(--bg);
  border-radius: 6px;
  border: 1px solid var(--line);
}
