/* Spell Manager - Styles */

/* ============================================
   TABS BAR
   ============================================ */
.spell-tabs-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border-color);
  padding: 0 16px;
  background: rgba(20, 12, 7, 0.5);
}

.spell-tab {
  padding: 10px 20px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.spell-tab:hover {
  color: var(--text-main);
}

.spell-tab.active {
  color: var(--primary);
}

.spell-tab.active::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  border-radius: 2px 2px 0 0;
}

/* ============================================
   TAB PANES
   ============================================ */
.spell-tab-pane {
  min-height: 200px;
}

/* ============================================
   GRADE CARDS (accordion)
   ============================================ */
.spell-grade-card {
  border: 1px solid rgba(224, 151, 95, 0.4);
  border-radius: 8px;
  margin-bottom: 10px;
  overflow: hidden;
  background: var(--bg-card, #241710);
}

.spell-grade-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  cursor: pointer;
  background: rgba(224, 151, 95, 0.08);
  transition: background 0.15s;
}

.spell-grade-header:hover {
  background: rgba(224, 151, 95, 0.15);
}

.spell-grade-header .grade-level {
  color: #d98b53;
  font-weight: 700;
  font-size: 0.95rem;
}

.spell-grade-header .grade-summary {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.spell-grade-body {
  border-top: 1px solid rgba(224, 151, 95, 0.3);
  padding: 14px;
  background: rgba(20, 12, 7, 0.3);
}

.spell-grade-body .form-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-bottom: 2px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.spell-grade-body .form-control,
.spell-grade-body .form-select {
  font-size: 0.85rem;
}

.spell-grade-body .form-check-label {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ============================================
   EFFECT ROWS
   ============================================ */
.spell-effect-row {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 10px 12px;
  margin-bottom: 8px;
}

.spell-effect-row:last-child {
  margin-bottom: 0;
}

.spell-effect-row .form-label {
  color: var(--text-muted);
  font-size: 0.72rem;
  margin-bottom: 1px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.spell-effect-row .form-control,
.spell-effect-row .form-select {
  font-size: 0.82rem;
}

.spell-effect-row .effect-name-label {
  font-size: 0.72rem;
  color: #d16e81;
  font-weight: 600;
  margin-top: 2px;
}

/* ============================================
   EFFECTS SECTIONS (normal / critical)
   ============================================ */
.spell-effects-normal {
  border-left: 3px solid #c87743;
  padding-left: 12px;
  margin-bottom: 16px;
}

.spell-effects-normal .effects-section-title {
  color: #d98b53;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.spell-effects-critical {
  border-left: 3px solid #cf7a35;
  padding-left: 12px;
  margin-bottom: 8px;
}

.spell-effects-critical .effects-section-title {
  color: #dd9052;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ============================================
   TRIGGER ROWS
   ============================================ */
.spell-trigger-row {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 12px;
  margin-bottom: 10px;
}

.spell-trigger-row:last-child {
  margin-bottom: 0;
}

.spell-trigger-row .form-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-bottom: 2px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.spell-trigger-row .form-control,
.spell-trigger-row .form-select {
  font-size: 0.85rem;
}

/* ============================================
   SIDEBAR
   ============================================ */
.spell-sidebar-card {
  border-radius: 10px;
  overflow: hidden;
  position: sticky;
  top: 16px;
}

.spell-sidebar-header {
  padding: 16px;
  background: linear-gradient(135deg, rgba(224, 151, 95, 0.15), rgba(184, 70, 92, 0.1));
  border-bottom: 1px solid var(--border-color);
  min-height: 60px;
  display: flex;
  align-items: center;
}

.spell-sidebar-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 6px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spell-sidebar-spell-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
}

.spell-sidebar-spell-id {
  font-size: 0.85rem;
  color: #d98b53;
  font-weight: 600;
}

.spell-sidebar-spell-sprite {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* Sections */
.spell-sidebar-section {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(58, 42, 30, 0.3);
}

.spell-sidebar-section:last-child {
  border-bottom: none;
}

.spell-sidebar-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.spell-sidebar-section-title i {
  font-size: 0.8rem;
}

/* Info grid */
.spell-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.spell-info-grid .info-cell {
  padding: 5px 0;
  border-bottom: 1px solid rgba(58, 42, 30, 0.25);
  display: flex;
  justify-content: space-between;
  font-size: 0.85rem;
}

.spell-info-grid .info-cell:nth-child(odd) {
  padding-right: 10px;
  border-right: 1px solid rgba(58, 42, 30, 0.25);
}

.spell-info-grid .info-cell:nth-child(even) {
  padding-left: 10px;
}

.spell-info-grid .info-cell .lbl {
  color: var(--text-muted);
  font-weight: 500;
}

.spell-info-grid .info-cell .val {
  color: var(--text-main);
  font-weight: 700;
}

/* ============================================
   SWF PREVIEW
   ============================================ */
.spell-lang-preview {
  background-color: #150c06;
  color: #7ee787;
  font-family: 'Consolas', 'Monaco', monospace;
  font-size: 0.82rem;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow-y: auto;
  border-radius: 6px;
}

/* ============================================
   SEARCH RESULTS
   ============================================ */
#spellSearchResults .list-group-item {
  font-size: 0.9rem;
  padding: 8px 12px;
}

#spellSearchResults .list-group-item strong {
  color: var(--text-main);
}

#spellSearchResults .badge {
  font-size: 0.78rem;
}

/* ============================================
   DELETE EFFECT BUTTON
   ============================================ */
.btn-remove-effect {
  background: none;
  border: none;
  color: var(--danger, #c0455a);
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
  padding: 0 4px;
  line-height: 1;
}

.btn-remove-effect:hover {
  opacity: 1;
}

.btn-remove-trigger {
  background: none;
  border: none;
  color: var(--danger, #c0455a);
  font-size: 1rem;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s;
  padding: 0 4px;
  line-height: 1;
}

.btn-remove-trigger:hover {
  opacity: 1;
}

/* Grade delete button */
.btn-delete-grade {
  background: none;
  border: none;
  color: var(--danger, #c0455a);
  font-size: 0.9rem;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s;
  padding: 2px 6px;
}

.btn-delete-grade:hover {
  opacity: 1;
}

/* Chevron for accordion */
.spell-grade-chevron {
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: transform 0.2s;
}

/* ============================================
   AUDIT RESULTS
   ============================================ */
.spell-audit-summary {
  display: flex;
  gap: 12px;
  margin-bottom: 14px;
  padding: 10px 14px;
  background: rgba(20, 12, 7, 0.5);
  border-radius: 8px;
  border: 1px solid var(--border-color);
  font-size: 0.85rem;
  font-weight: 600;
}

.spell-audit-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 0.85rem;
  line-height: 1.4;
}

.spell-audit-item:last-child {
  margin-bottom: 0;
}

.spell-audit-item i {
  flex-shrink: 0;
  margin-top: 2px;
}

.spell-audit-error {
  background: rgba(184, 70, 92, 0.1);
  border: 1px solid rgba(184, 70, 92, 0.3);
  color: #e3a8b1;
}

.spell-audit-warning {
  background: rgba(154, 138, 78, 0.1);
  border: 1px solid rgba(154, 138, 78, 0.3);
  color: #ecc276;
}

.spell-audit-success {
  background: rgba(90, 168, 115, 0.1);
  border: 1px solid rgba(90, 168, 115, 0.3);
  color: #86efac;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
}

/* ============================================
   TARGET BUILDER (inline dans effect rows)
   ============================================ */
.spell-target-inline {
  position: relative;
}

.spell-target-compact {
  display: flex;
  gap: 4px;
  align-items: center;
}

.spell-target-compact .target-value-input {
  flex: 1;
  min-width: 50px;
}

.spell-target-toggle-btn {
  background: rgba(224, 151, 95, 0.15);
  border: 1px solid rgba(224, 151, 95, 0.3);
  color: #d98b53;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
}

.spell-target-toggle-btn:hover,
.spell-target-toggle-btn.active {
  background: rgba(224, 151, 95, 0.3);
  color: #7dd3fc;
}

.spell-target-summary {
  font-size: 0.7rem;
  color: #d16e81;
  font-weight: 600;
  margin-top: 2px;
  line-height: 1.2;
  word-break: break-word;
}

.spell-target-builder {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  width: 340px;
  background: #1a0f07;
  border: 1px solid rgba(224, 151, 95, 0.4);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  margin-top: 4px;
  overflow: hidden;
}

.spell-target-builder-header {
  background: rgba(224, 151, 95, 0.1);
  border-bottom: 1px solid rgba(224, 151, 95, 0.2);
  padding: 8px 12px;
  font-size: 0.82rem;
  font-weight: 700;
  color: #d98b53;
  display: flex;
  align-items: center;
  gap: 6px;
}

.spell-target-section {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(58, 42, 30, 0.2);
}

.spell-target-section:last-child {
  border-bottom: none;
}

.spell-target-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.spell-target-flags {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.spell-target-flag-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-main, #e9ecef);
  cursor: pointer;
  padding: 3px 4px;
  border-radius: 4px;
  transition: background 0.1s;
}

.spell-target-flag-item:hover {
  background: rgba(224, 151, 95, 0.06);
}

.spell-target-flag-item .form-check-input {
  margin: 0;
  flex-shrink: 0;
}

.spell-target-flag-item code {
  margin-left: auto;
  font-size: 0.7rem;
  color: #8b7461;
  background: rgba(119, 100, 84, 0.15);
  padding: 1px 5px;
  border-radius: 3px;
}

.spell-target-state {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.spell-target-state-row {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.spell-target-state-label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
}

.spell-target-state .form-select {
  font-size: 0.8rem;
}

.spell-target-state-formula {
  font-size: 0.72rem;
  color: #e0a851;
  font-family: 'Consolas', monospace;
  min-height: 16px;
}

/* ============================================
   TRIGGER SECTIONS (refonte)
   ============================================ */
.spell-trigger-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(58, 42, 30, 0.3);
  margin-bottom: 10px;
}

.spell-trigger-header .btn-remove-trigger {
  margin-left: auto;
}

.spell-trigger-summary {
  font-size: 0.78rem;
  color: #d16e81;
  font-style: italic;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spell-trigger-section {
  padding: 10px 0;
  border-bottom: 1px solid rgba(58, 42, 30, 0.15);
}

.spell-trigger-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.spell-trigger-section-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #d98b53;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Toggle porteur / source */
.trigger-apply-toggle {
  display: flex;
  gap: 8px;
}

.trigger-toggle-option {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(58, 42, 30, 0.3);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
  background: rgba(20, 12, 7, 0.3);
}

.trigger-toggle-option:hover {
  border-color: rgba(224, 151, 95, 0.3);
  background: rgba(224, 151, 95, 0.05);
}

.trigger-toggle-option.active {
  border-color: rgba(224, 151, 95, 0.6);
  background: rgba(224, 151, 95, 0.1);
  box-shadow: 0 0 0 1px rgba(224, 151, 95, 0.2);
}

.trigger-toggle-option.active i {
  color: #d98b53;
}

.trigger-toggle-option i {
  font-size: 1.2rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.trigger-toggle-option strong {
  font-size: 0.82rem;
  color: var(--text-main, #e9ecef);
}

/* Effect search dropdown */
.trigger-effect-dropdown {
  position: absolute;
  z-index: 100;
  background: #1a0f07;
  border: 1px solid rgba(224, 151, 95, 0.4);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  max-height: 220px;
  overflow-y: auto;
  width: 100%;
  min-width: 280px;
  margin-top: 4px;
}

.trigger-effect-dropdown-item {
  padding: 8px 12px;
  font-size: 0.82rem;
  color: var(--text-main, #e9ecef);
  cursor: pointer;
  border-bottom: 1px solid rgba(58, 42, 30, 0.15);
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 6px;
}

.trigger-effect-dropdown-item:last-child {
  border-bottom: none;
}

.trigger-effect-dropdown-item:hover {
  background: rgba(224, 151, 95, 0.1);
}

.trigger-effect-dropdown-empty {
  padding: 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82rem;
}

/* Conflict badges */
.spell-conflict-ok {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #86efac;
  background: rgba(90, 168, 115, 0.1);
  border: 1px solid rgba(90, 168, 115, 0.3);
  padding: 2px 8px;
  border-radius: 4px;
}

.spell-conflict-error {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  color: #e3a8b1;
  background: rgba(184, 70, 92, 0.1);
  border: 1px solid rgba(184, 70, 92, 0.3);
  padding: 2px 8px;
  border-radius: 4px;
}

/* Condition builder */
.trigger-condition-builder .form-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  margin-bottom: 2px;
}

.trigger-condition-summary {
  font-size: 0.75rem;
  color: #d16e81;
  font-weight: 600;
}

.trigger-conflict-badge {
  min-height: 20px;
}

/* ============================================
   EFFECT ID SEARCH DROPDOWN (dans grades)
   ============================================ */
.effect-id-search-wrapper {
  display: flex;
  gap: 4px;
  align-items: center;
}

.effect-id-search-wrapper .effect-id-input {
  flex: 1;
  min-width: 60px;
}

.effect-id-search-btn {
  background: rgba(224, 151, 95, 0.15);
  border: 1px solid rgba(224, 151, 95, 0.3);
  color: #d98b53;
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.15s;
  flex-shrink: 0;
  line-height: 1;
}

.effect-id-search-btn:hover {
  background: rgba(224, 151, 95, 0.3);
  color: #7dd3fc;
}

.effect-id-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 120;
  width: 300px;
  background: #1a0f07;
  border: 1px solid rgba(224, 151, 95, 0.4);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6);
  margin-top: 4px;
  overflow: hidden;
}

.effect-id-dropdown-filter {
  width: 100%;
  padding: 8px 12px;
  background: rgba(20, 12, 7, 0.8);
  border: none;
  border-bottom: 1px solid rgba(224, 151, 95, 0.2);
  color: var(--text-main, #e9ecef);
  font-size: 0.82rem;
  outline: none;
}

.effect-id-dropdown-filter::placeholder {
  color: #8b7461;
}

.effect-id-dropdown-list {
  max-height: 250px;
  overflow-y: auto;
}

.effect-id-dropdown-item {
  padding: 6px 12px;
  font-size: 0.82rem;
  color: var(--text-main, #e9ecef);
  cursor: pointer;
  border-bottom: 1px solid rgba(58, 42, 30, 0.1);
  transition: background 0.1s;
}

.effect-id-dropdown-item:hover {
  background: rgba(224, 151, 95, 0.1);
}

.effect-id-dropdown-item.selected {
  background: rgba(224, 151, 95, 0.15);
  border-left: 3px solid #d98b53;
}

.effect-id-dropdown-item:last-child {
  border-bottom: none;
}

/* Agrandir le label effect name */
.spell-effect-row .effect-name-label {
  font-size: 0.8rem;
  color: #d16e81;
  font-weight: 700;
  margin-top: 3px;
  line-height: 1.2;
}

/* ============================================
   TRIGGER EFFECT LABELS
   ============================================ */
.trigger-effect-label {
  font-size: 0.78rem;
  color: #d16e81;
  font-weight: 600;
  margin-top: 3px;
  line-height: 1.2;
  min-height: 16px;
}

/* ============================================
   STATES PREVIEW BADGES
   ============================================ */
.spell-states-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  min-height: 10px;
}

.spell-state-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: default;
  transition: all 0.15s;
}

.spell-state-badge-forbidden {
  background: rgba(184, 70, 92, 0.15);
  border: 1px solid rgba(184, 70, 92, 0.4);
  color: #e3a8b1;
}

.spell-state-badge-required {
  background: rgba(90, 168, 115, 0.15);
  border: 1px solid rgba(90, 168, 115, 0.4);
  color: #86efac;
}

.spell-state-badge-remove {
  cursor: pointer;
  font-size: 0.9rem;
  opacity: 0.6;
  transition: opacity 0.15s;
  line-height: 1;
  font-weight: 700;
}

.spell-state-badge-remove:hover {
  opacity: 1;
}

/* ============================================
   STATES REFERENCE TABLE (cliquable)
   ============================================ */
.spell-state-ref-row {
  cursor: pointer;
  transition: background 0.1s;
}

.spell-state-ref-row:hover {
  background: rgba(224, 151, 95, 0.1) !important;
}

.spell-state-ref-row.state-selected-forbidden {
  background: rgba(184, 70, 92, 0.15) !important;
  border-left: 3px solid #c0455a;
}

.spell-state-ref-row.state-selected-forbidden td:first-child {
  color: #e3a8b1 !important;
}

.spell-state-ref-row.state-selected-required {
  background: rgba(90, 168, 115, 0.15) !important;
  border-left: 3px solid #5aa873;
}

.spell-state-ref-row.state-selected-required td:first-child {
  color: #86efac !important;
}
