/* ===== FEATURE STYLES (Redesign v2) ===== */

/* ===== CATEGORIES ===== */

.key.has-category {
  border-left: 3px solid;
}

/* Category submenu in context menu */
.key-context-menu .cat-submenu {
  border-top: 1px solid var(--border-subtle);
  padding-top: 4px;
  margin-top: 4px;
}

.key-context-menu .cat-submenu-label {
  padding: 4px 14px;
  font-size: 10px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.key-context-menu .cat-option {
  display: flex;
  align-items: center;
  gap: 8px;
}

.key-context-menu .cat-swatch {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}

/* ===== CONFLICT DETECTION ===== */

.key.has-conflict {
  outline: 2px solid var(--danger) !important;
  outline-offset: 1px;
}

.conflict-badge {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
  background: var(--danger);
  color: #fff;
  border-radius: 4px;
  font-weight: 700;
  pointer-events: none;
  z-index: 5;
}

/* ===== TOOLTIPS ===== */

.key-tooltip {
  position: fixed;
  z-index: 550;
  background: var(--header);
  border: 1px solid var(--key-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  padding: 10px 14px;
  font-size: 12px;
  color: var(--key-text);
  max-width: 240px;
  pointer-events: none;
  display: none;
  line-height: 1.4;
}

.key-tooltip.visible { display: block; }
.key-tooltip .tooltip-label { font-weight: 700; margin-bottom: 4px; }
.key-tooltip .tooltip-desc { color: var(--keybind-text); }
.key-tooltip .tooltip-category { margin-top: 4px; font-size: 11px; opacity: 0.6; }

/* ===== SEARCH STATES ===== */

.key.search-match {
  box-shadow: 0 0 0 2px var(--success), 0 0 16px rgba(90, 184, 90, 0.3) !important;
  border-color: var(--success) !important;
}

.key.search-dim {
  opacity: 0.15;
  pointer-events: none;
}

/* ===== DRAG AND DROP ===== */

.key.dragging {
  opacity: 0.35;
  transform: scale(0.95);
}

.key.drag-over {
  border: 2px dashed var(--accent) !important;
  background: var(--accent-dim) !important;
  box-shadow: 0 0 0 3px rgba(108, 126, 224, 0.15) !important;
}

/* ===== HEATMAP MODE ===== */

body.heatmap-active .key .keybind { pointer-events: none; }
body.heatmap-active .key { cursor: default; }
body.heatmap-active .key .key-clear-btn { display: none !important; }
body.heatmap-active .key:hover { transform: none; }

/* ===== PRINT / SCREENSHOT MODE ===== */

body.print-mode .header,
body.print-mode .sidebar,
body.print-mode .key-editor,
body.print-mode .key-context-menu,
body.print-mode .clear-confirm,
body.print-mode .modal,
body.print-mode .modal-overlay,
body.print-mode .key-tooltip,
body.print-mode .category-legend {
  display: none !important;
}

body.print-mode .app-layout {
  margin-top: 0;
}

body.print-mode .main-content {
  padding: 16px;
}

body.print-mode .key .key-clear-btn { display: none !important; }
body.print-mode .key .keybind { pointer-events: none; }
body.print-mode .key:hover { transform: none; }

#print-exit {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 700;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  background: var(--header);
  border: 1px solid var(--key-border);
  color: var(--key-text);
  border-radius: 8px;
  cursor: pointer;
  display: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: background 0.12s;
}

body.print-mode #print-exit { display: block; }
#print-exit:hover { background: var(--key-bg); }

/* Print legend */
.print-legend {
  display: none;
  margin-top: 16px;
  padding: 12px 20px;
  background: var(--header);
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

body.print-mode .print-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
}

.print-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}

.print-legend .legend-swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

/* ===== @MEDIA PRINT ===== */

@media print {
  body {
    background: #fff !important;
    color: #000 !important;
  }

  .header, .sidebar, .key-editor, .key-context-menu,
  .clear-confirm, .modal, .modal-overlay,
  #print-exit, .key-tooltip, .category-legend {
    display: none !important;
  }

  .app-layout { margin-top: 0; }

  .keyboard {
    box-shadow: none !important;
    background: #f5f5f5 !important;
    border: 1px solid #ccc !important;
  }

  .key {
    background: #e8e8e8 !important;
    border-color: #999 !important;
    box-shadow: none !important;
    color: #000 !important;
    transform: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .key-cap { color: #000 !important; text-shadow: none !important; }
  .keybind { color: #333 !important; text-shadow: none !important; }
  .key-clear-btn { display: none !important; }

  .key.has-category {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .print-legend {
    display: flex !important;
    background: #f5f5f5 !important;
    border-color: #ccc !important;
  }
}

/* ===== INFO / HOW IT WORKS MODAL ===== */

.info-modal {
  max-width: 560px;
  width: 90vw;
  max-height: 80vh;
  display: none;
}

.info-modal.visible { display: block; }

.info-body {
  max-height: calc(80vh - 80px);
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.info-section {
  padding-bottom: 12px;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.info-section:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.info-section h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 6px;
}

.info-section p {
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--keybind-text);
  margin: 0 0 6px;
}

.info-section p:last-child {
  margin-bottom: 0;
}

.info-section strong {
  color: var(--key-text);
}
