// ============================================================
// ROLL DIALOG — Oath Hammer pre-roll configuration dialog
// ============================================================

// Target both the window chrome and the inner content to ensure background coverage
.fvtt-oath-hammer {
  .window-content {
    background: @color-paper;
    padding: 6px 8px;
  }
}

.fvtt-oath-hammer .oh-roll-dialog {
  font-family: @font-body;
  min-width: 320px;
  padding: 4px 2px;
  background: @color-paper;
  color: @color-dark;

  .roll-actor-name {
    text-align: center;
    font-family: @font-secondary;
    font-size: @font-size-xl;
    color: @color-blue;
    margin-bottom: 8px;
    padding-bottom: 4px;
    border-bottom: 1px solid @color-olive-faint;
  }

  fieldset {
    border: 1px solid @color-olive-faint;
    border-radius: 4px;
    padding: 8px 10px;
    margin-bottom: 8px;

    legend {
      font-family: @font-secondary;
      color: @color-olive;
      font-size: @font-size-xs;
      padding: 0 6px;
      letter-spacing: 0.04em;
    }
  }

  // ——— Skill info block ———
  .roll-info-block {
    background: fade(@color-olive, 6%);

    .roll-skill-line {
      display: flex;
      flex-direction: column;
      gap: 2px;
      margin-bottom: 8px;
    }

    .roll-skill-name {
      font-weight: bold;
      font-size: @font-size-lg;
      color: @color-dark;
    }

    .roll-attr-info {
      font-size: @font-size-xs;
      color: @color-olive;
    }

    .roll-dice-preview {
      display: flex;
      align-items: center;
      gap: 8px;
    }

    .roll-pool {
      font-size: 1.6rem;
      font-weight: bold;
      color: @color-blue;
      line-height: 1;
    }

    .roll-color-badge {
      display: inline-flex;
      align-items: center;
      gap: 4px;
      padding: 3px 8px;
      border-radius: 4px;
      font-size: @font-size-xs;
      font-weight: bold;
      border: 1px solid;
    }

    .color-badge-white {
      background: #f0f0f0;
      color: #555;
      border-color: #ccc;
    }

    .color-badge-red {
      background: fade(#e74c3c, 12%);
      color: #c0392b;
      border-color: fade(#e74c3c, 35%);
    }

    .color-badge-black {
      background: fade(#2c3e50, 10%);
      color: #2c3e50;
      border-color: fade(#2c3e50, 35%);
    }

    .roll-dual-attr {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-top: 8px;
      padding-top: 6px;
      border-top: 1px dashed @color-olive-faint;

      label {
        font-size: @font-size-xs;
        color: @color-olive;
        white-space: nowrap;
      }

      select {
        flex: 1;
        font-size: @font-size-xs;
        font-family: @font-body;
        padding: 2px 4px;
        border: 1px solid @color-olive-faint;
        border-radius: 3px;
        background: rgba(255, 255, 255, 0.85);
        color: @color-dark;
      }
    }
  }

  // ——— Option rows — applies to all fieldsets in any roll dialog ———
  .roll-option-row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px 8px;
    padding: 5px 0;

    &:not(:last-child) {
      border-bottom: 1px solid fade(@color-olive, 10%);
    }

    label {
      flex: 0 0 140px;
      font-size: @font-size-xs;
      color: @color-dark;
      white-space: nowrap;
      font-family: @font-body;
    }

    select, input[type="text"], input[type="number"] {
      flex: 0 0 110px;
      padding: 3px 6px;
      border: 1px solid darken(@color-olive-faint, 10%);
      border-radius: 3px;
      background: rgba(255, 255, 255, 0.85);
      color: @color-dark;
      font-family: @font-body;
      font-size: @font-size-xs;
    }

    .roll-option-hint {
      flex: 1 1 auto;
      font-size: calc(@font-size-xs * 0.85);
      color: @color-olive;
      font-style: italic;
      padding-left: 6px;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }
  }

  .roll-option-luck {
    label { color: @color-gold; font-weight: bold; }
    select { border-color: @color-gold; }
    .luck-icon { color: @color-gold; font-size: 0.8em; }
  }

  .roll-option-check {
    input[type="checkbox"] {
      flex: 0 0 auto;
      width: 16px;
      height: 16px;
      accent-color: @color-blue;
      cursor: pointer;
    }
    label {
      cursor: pointer;
      flex: 1 1 auto;
    }
  }

  // ——— Options block (legacy scope kept for skill roll dialog) ———
  .roll-options-block {
    // inherits .roll-option-row styles from parent scope
  }

  // ——— Visibility block ———
  .roll-visibility-block {
    select {
      width: 100%;
      padding: 4px 6px;
      border: 1px solid @color-olive-faint;
      border-radius: 3px;
      background: rgba(255, 255, 255, 0.85);
      color: @color-dark;
      font-family: @font-body;
      font-size: @font-size-xs;
    }
  }
}

// Rollable skill name in the skills tab
.fvtt-oath-hammer .skills-list {
  a.skill-name-col {
    cursor: pointer;
    color: @color-dark;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    .transition-opacity();

    .skill-roll-icon {
      font-size: 0.75em;
      color: @color-olive;
      flex-shrink: 0;
    }

    &:hover {
      color: @color-blue;
      text-decoration: underline;
      .skill-roll-icon { color: @color-blue; }
    }
  }
}

// ============================================================
// WEAPON DIALOG
// ============================================================

.oh-weapon-dialog {

  // ——— Weapon header bar ———
  .weapon-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 6px 0 8px;
    border-bottom: 1px solid @color-olive-faint;
    margin-bottom: 8px;

    .weapon-img-sm {
      width: 40px;
      height: 40px;
      object-fit: contain;
      border: 1px solid @color-olive-faint;
      border-radius: 4px;
      flex-shrink: 0;
    }

    .weapon-header-info {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 4px;
    }

    .weapon-name-lg {
      font-family: @font-secondary;
      font-size: @font-size-lg;
      color: @color-blue;
      font-weight: bold;
    }

    .weapon-badges {
      display: flex;
      flex-wrap: wrap;
      gap: 4px;
      align-items: center;
    }

    .damage-formula-badge {
      font-family: @font-body;
      font-size: @font-size-xs;
      font-weight: bold;
      color: @color-dark;
      background: fade(@color-olive, 10%);
      border: 1px solid @color-olive-faint;
      border-radius: 3px;
      padding: 2px 6px;
    }

    .ap-badge {
      font-size: @font-size-xs;
      font-weight: bold;
      color: #8b0000;
      background: fade(#8b0000, 8%);
      border: 1px solid fade(#8b0000, 25%);
      border-radius: 3px;
      padding: 2px 6px;
    }

    .range-badge {
      font-size: @font-size-xs;
      color: @color-olive;
      background: fade(@color-olive, 8%);
      border: 1px solid @color-olive-faint;
      border-radius: 3px;
      padding: 2px 6px;
    }

    .auto-bonus-badge {
      font-size: @font-size-xs;
      font-weight: bold;
      color: darken(@color-gold, 15%);
      background: fade(@color-gold, 12%);
      border: 1px solid fade(@color-gold, 40%);
      border-radius: 3px;
      padding: 2px 6px;
    }

    .weapon-traits-row {
      display: flex;
      flex-wrap: wrap;
      gap: 3px;
      margin-top: 2px;
    }

    .trait-tag-sm {
      font-size: calc(@font-size-xs * 0.85);
      color: @color-olive;
      background: fade(@color-olive, 8%);
      border: 1px solid @color-olive-faint;
      border-radius: 3px;
      padding: 1px 5px;
    }
  }

  // ——— Pool info line ———
  .pool-info-line {
    font-size: @font-size-xs;
    color: @color-dark;
    padding: 4px 0 6px;
    font-family: @font-body;

    strong { color: @color-blue; font-size: @font-size-lg; }

    .auto-bonus {
      color: darken(@color-gold, 10%);
      font-weight: bold;
      font-size: @font-size-xs;
    }
  }
}

// ——— Weapon / Spell / Miracle cards in chat ———
.oh-weapon-card,
.oh-spell-card,
.oh-miracle-card {
  .oh-roll-header {
    display: flex;
    align-items: center;
    gap: 8px;
  }

  .oh-card-weapon-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 3px;
    border: 1px solid @color-olive-faint;
    flex-shrink: 0;
  }

  .oh-weapon-damage-btn-row {
    margin-top: 8px;
    text-align: center;
  }

  .oh-roll-damage-btn {
    background: @color-blue;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 5px 14px;
    font-family: @font-body;
    font-size: @font-size-xs;
    cursor: pointer;
    .transition-opacity();

    &:hover { background: lighten(@color-blue, 10%); opacity: 1; }
  }

  .oh-ap-note {
    font-size: @font-size-xs;
    color: #8b0000;
    font-weight: bold;
    margin-left: 8px;
  }
}

// Attack/damage buttons in weapon list
.item-list--weapon .item-entry .item-actions {
  gap: 14px;
  a[data-action="attackWeapon"] {
    color: @color-blue;
    font-size: 1.1em;
    .transition-opacity();
  }
  a[data-action="defendWeapon"] {
    color: @color-olive;
    font-size: 1.1em;
    .transition-opacity();
  }
  a[data-action="damageWeapon"] {
    color: #8b0000;
    font-size: 1.1em;
    .transition-opacity();
  }
  a[data-action="edit"] { margin-left: 4px; }
}

// ============================================================
// SPELL / MIRACLE DIALOG STYLES
// ============================================================

.oh-spell-dialog,
.oh-miracle-dialog {

  // Spell/miracle header (reuses .spell-header, .weapon-img-sm, .weapon-name-lg, .weapon-badges)
  .dv-badge {
    background: #3a0e6b;
    color: #e8d9ff;
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 0.78em;
    font-weight: bold;
  }

  .tradition-badge {
    background: #0e3a6b;
    color: #d9eeff;
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 0.78em;
  }

  .ritual-badge {
    background: #4a3000;
    color: #ffe8a0;
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 0.78em;
  }

  .missile-badge {
    background: #1a4a1a;
    color: #b8ffb8;
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 0.78em;
  }

  .range-badge, .duration-badge {
    background: fade(@color-dark, 12%);
    color: @color-dark;
    border-radius: 3px;
    padding: 1px 6px;
    font-size: 0.75em;
  }

  .save-info {
    font-size: 0.8em;
    color: @color-dark;
    font-style: italic;
    margin-top: 3px;
  }

  // Arcane stress tracker
  .stress-tracker {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin: 8px 0 4px;
    background: fade(@color-olive, 10%);
    border: 1px solid fade(@color-olive, 30%);
    border-radius: 4px;
    font-size: 0.88em;

    i { color: @color-dark; }

    .stress-warning {
      margin-left: auto;
      color: #c00;
      font-weight: bold;
      font-size: 0.9em;
    }

    &.stress-danger {
      background: fade(#c00, 8%);
      border-color: fade(#c00, 40%);
    }
  }

  // Miracle failure warning banner
  .miracle-warning {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin: 8px 0 4px;
    background: fade(#8b0000, 8%);
    border: 1px solid fade(#8b0000, 30%);
    border-radius: 4px;
    font-size: 0.83em;
    color: #8b0000;
    font-style: italic;

    i { flex-shrink: 0; }
  }

  // Wide select for enhancement list
  select.enhancement-select {
    min-width: 220px;
  }
}

// Chat card additions for spell/miracle
.oh-spell-card, .oh-miracle-card {
  .oh-stress-line {
    margin-top: 6px;
    padding: 4px 8px;
    background: fade(@color-olive, 10%);
    border: 1px solid fade(@color-olive, 30%);
    border-radius: 3px;
    font-size: 0.82em;
    color: @color-dark;

    &.stress-blocked {
      background: fade(#c00, 8%);
      border-color: fade(#c00, 40%);
      color: #c00;
    }
  }

  .oh-miracle-blocked {
    margin-top: 6px;
    padding: 5px 8px;
    background: fade(#8b0000, 8%);
    border: 1px solid fade(#8b0000, 35%);
    border-radius: 3px;
    font-size: 0.85em;
    color: #8b0000;
    font-weight: bold;
    text-align: center;
  }
}

// Cast icons in magic item lists
.item-list--spell .item-actions,
.item-list--miracle .item-actions {
  gap: 8px;
  a[data-action="castSpell"] .spell-cast-icon { color: #3a0e6b; font-size: 1.05em; }
  a[data-action="castMiracle"] .miracle-cast-icon { color: #5a3000; font-size: 1.05em; }
  a[data-action="edit"] { margin-left: 6px; }
}

// ============================================================
// DEFENSE / ARMOR DIALOG STYLES
// ============================================================

.oh-defense-dialog,
.oh-armor-dialog {
  .oh-trait-info {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 10px;
    margin: 4px 0;
    background: fade(@color-blue, 8%);
    border: 1px solid fade(@color-blue, 25%);
    border-radius: 4px;
    font-size: 0.84em;
    color: darken(@color-blue, 10%);
    i { flex-shrink: 0; }
  }
}

// Defense card in chat
.oh-defense-card,
.oh-armor-card {
  .oh-roll-header {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  .oh-defense-icon {
    font-size: 1.1em;
    color: @color-blue;
    flex-shrink: 0;
  }
  .oh-card-weapon-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 3px;
    border: 1px solid @color-olive-faint;
    flex-shrink: 0;
  }
}

// Defense roll button in combat tab
.defense-row {
  align-items: flex-end;
  .defense-roll-group {
    flex: 0 0 auto;
  }
}

.defense-roll-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: @color-blue;
  color: #fff;
  border-radius: 4px;
  font-family: @font-secondary;
  font-size: @font-size-sm;
  cursor: pointer;
  text-decoration: none;
  .transition-opacity();

  i { font-size: 0.9em; }
  &:hover { opacity: 0.85; color: #fff; text-decoration: none; }
}

// Armor roll icon in armor list
.item-list--armor .item-actions {
  gap: 8px;
  a[data-action="rollArmorSave"] .armor-roll-icon {
    color: @color-blue;
    font-size: 1.05em;
  }
  a[data-action="edit"] { margin-left: 6px; }
}
