@import "variables";
@import "utilities";

.window-app.vermineDialog {
  max-width: 50vw;
  height: fit-content;

  .window-content {
    .background-image(url("@{ui-path}/box_background.webp"), repeat);
    color: #000;
  }

  details > summary::after {
    content: "▶️";
    position: relative;
    right: 40%;
  }

  details[open] > summary::after {
    content: "🔽";
  }

  .grid {
    justify-content: space-around;
    .shadow(0px, 1px, 10px, rgba(0, 0, 0, 0.555));
    align-items: center;
    padding: 0.5rem 0.2rem;

    > * { margin: 0 0.3rem; }
  }

  label {
    font-family: "DistressBlack", sans-serif;
    font-size: larger;
  }

  select {
    max-width: fit-content;
    .custom-select-style();
    option { max-width: fit-content; }
  }

  .dialog-buttons {
    display: flex;
    justify-content: space-around;
    flex-direction: row;

    button {
      display: block;
      flex: 0.3;
      color: @theme-color-dark;
    }
  }
}

input[type="range"] { .custom-input-style(); }
input[type="checkbox"],
input[type="radio"] { .custom-checkbox-radio(); }

input[type="radio"] {
  width: 1rem;
  height: 1rem;

  &:after {
    width: 0.8rem;
    background-size: 100% 100%;
    top: 5%;
    left: 5%;
    width: 90%;
    height: 90%;
    background-size: 30% 30%;
    background-position: center;
  }

  &:not([disabled]):hover::after { background-size: 90% 90%; }

  &:checked::after {
    content: "";
    background-size: 70% 70%;
    top: 5%;
    left: 5%;
    position: relative;
    background-color: rgba(26, 1, 1, 0);
  }
}

.app.vermine2047.trait-selector {
  .form-group {
    .shadow(0, 0, 30px, gray);
    padding: 0.3rem 0.5rem;
    border: 3px solid #8e9010;

    &:has(input[type="checkbox"]:checked) {
      border: 3px solid green;
    }

    label {
      display: inline-flex;
      align-items: center;
      justify-content: space-around;
      width: 100%;
      text-align: center;
      border-bottom: 2px solid #000;
    }
  }
}

.app .actor.choose {
  div.actor {
    position: relative;

    img {
      border-radius: 50%;
      .shadow(0px, 0px, 8px, #000);
    }

    span.actor-name {
      position: absolute;
      text-align: center;
      background-color: rgba(255, 255, 255, 0.562);
      border: 5px;
      width: 100%;
      padding: 0 1rem;
      border-radius: 5px;
      .shadow(0px, 0px, 8px, #000);
    }
  }
}

iframe {
  min-height: 500px;

  .tabs.moods-headings {
    max-width: 1px;
  }
}

// ── Roll Dialog V2 ─────────────────────────────────────────────────────
.application.vermine-roll {
  .window-content {
    overflow-y: auto;
  }

  .roll-dialog-content {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px;
    height: 100%;
    overflow-y: auto;
    color: @theme-color-dark;

    .dice-pool {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: inherit;
    }

    label {
      font-family: "DistressBlack", sans-serif;
      text-transform: uppercase;
      font-size: @font-size-12;
    }

    input, select, textarea {
      color: @color-chitin-dark;
      background: @color-text-light-0;
    }

    select {
      .custom-select-style();
      width: 100%;
    }

    input[type="range"] { .custom-input-style(); }
    input[type="checkbox"],
    input[type="radio"] { .custom-checkbox-radio(); }

    // ── Main roll section: ability + skill side-by-side ─────────────
    .main-roll-section {
      gap: 10px;

      > .flexcol {
        flex: 1;
        gap: 4px;
        min-width: 0;

        > label {
          font-size: @font-size-13;
          color: @color-text-light-2;
          white-space: nowrap;
        }

        select {
          min-height: 28px;
          width: 100%;
        }
      }

      .ability-score {
        gap: 4px;
        font-size: @font-size-12;
        color: @color-text-dark-secondary;
        opacity: 0.85;

        #abilityScoreValue {
          font-weight: bold;
          color: @color-acid-green;
        }
      }
    }

    // ── Collapsible sections (specialties, difficulty, bonuses) ─────
    details {
      margin-top: 2px;

      summary {
        font-family: "DistressBlack", sans-serif;
        text-transform: uppercase;
        font-size: @font-size-12;
        padding: 6px 10px;
        background: 50% 0% / cover no-repeat url("@{ui-path}/scotch.webp");
        box-shadow: 0px 0px 3px rgba(31, 26, 26, 0.5) inset;
        cursor: pointer;
        color: @theme-color-dark;
        display: flex;
        align-items: center;
        gap: 8px;

        &::after {
          content: "▶";
          margin-left: auto;
          font-size: @font-size-11;
        }

        &:hover {
          box-shadow: 0 0 10px @theme-color-highlight inset;
        }

        span.label {
          font-family: "DistressBlack", sans-serif;
          font-size: @font-size-12;
        }

        .current-values,
        .current-specialty,
        .bonus-count {
          font-family: "Roboto", sans-serif;
          font-size: @font-size-11;
          text-transform: none;
          opacity: 0.8;
        }
      }

      &[open] > summary::after {
        content: "▼";
      }

      > div:not(summary) {
        padding: 8px;
        background: fade(@color-chitin-dark, 40%);
      }
    }

    // ── Difficulty section ──────────────────────────────────────────
    .difficulty-controls {
      gap: 12px;

      > .flexcol {
        flex: 1;
        gap: 4px;

        label {
          font-size: @font-size-11;
          color: @color-chitin-dark;
        }
      }
    }

    // ── Specialties section ─────────────────────────────────────────
    .specialty-options {
      gap: 8px;
      flex-wrap: wrap;

      label {
        display: flex;
        align-items: center;
        gap: 4px;
        font-size: @font-size-12;
        font-family: "Roboto", sans-serif;
        text-transform: none;
        color: @color-text-dark-primary;
        cursor: pointer;

        &:hover {
          color: @color-acid-green;
        }
      }

      input[type="radio"] {
        width: 14px;
        height: 14px;
        flex: none;
      }
    }

    // ── Bonuses grid ────────────────────────────────────────────────
    .bonus-grid {
      margin: 0;
      gap: 8px;

      .bonus-item {
        align-items: center;
        gap: 6px;
        padding: 4px 0;

        > label.label {
          font-size: @font-size-11;
          color: @color-text-dark-secondary;
          white-space: nowrap;
        }

        input[type="number"] {
          width: 40px;
          text-align: center;
          padding: 2px;
        }

        input[type="checkbox"] + label {
          font-size: @font-size-12;
          font-family: "Roboto", sans-serif;
          text-transform: none;
          color: @color-text-dark-primary;
        }

        .item-list {
          gap: 4px;

          label {
            align-items: center;
            gap: 4px;
            font-size: @font-size-11;
            font-family: "Roboto", sans-serif;
            text-transform: none;
            color: @color-text-dark-primary;
            cursor: pointer;

            &:hover {
              color: @color-acid-green;
            }
          }

          .tool-bonus,
          .tool-ponctuel {
            font-style: normal;
            font-weight: 700;
            padding: 0 4px;
            border-radius: 3px;
          }

          .tool-bonus {
            color: @color-acid-green;
            background: fade(@color-acid-green, 12%);
          }

          .tool-ponctuel {
            color: @theme-color-dark;
            background: fade(@color-hemolymph, 18%);
          }
        }

        &.full-width {
          grid-column: 1 / -1;
        }
      }

      // Totems sub-section
      .totems-section {
        flex-wrap: wrap;
        gap: 6px;

        > label.label {
          width: 100%;
        }

        .totem-options {
          gap: 12px;
        }

        .totem-option {
          display: flex;
          align-items: center;
          gap: 4px;
          color: @color-text-dark-primary;
          font-size: @font-size-12;
          font-family: "Roboto", sans-serif;
          text-transform: none;
          cursor: pointer;

          &:hover {
            color: @color-acid-green;
          }

          small {
            opacity: 0.7;
          }
        }

        .totem-hint {
          width: 100%;
          font-size: @font-size-11;
          color: @color-text-dark-secondary;
          opacity: 0.8;
          font-style: italic;
        }
      }
    }

    // ── Combat dialog (attaque) ──────────────────────────────────────
    .combat-mode-label {
      margin: 0;
      text-align: center;
      font-size: @font-size-14;
      color: @color-hemolymph;
      text-transform: uppercase;
    }

    .traits-reminder {
      margin: 4px 0 0;
      font-family: "Roboto", sans-serif;
      font-size: @font-size-11;
      font-style: italic;
      color: @theme-color-accent;

      i { color: @color-hemolymph; }
    }

    .locked-value {
      flex: 1;
      display: flex;
      align-items: center;
      min-height: 28px;
      padding: 0 8px;
      font-size: @font-size-12;
      color: @color-chitin-dark;
      background: @color-text-light-0;
      border-radius: 3px;
      .custom-select-style();
    }

    .combat-dialog-weapon {
      border: 1px solid @color-hemolymph;
      padding: 6px 8px;
      background: fade(@color-chitin-dark, 40%);

      .weapon-block-header {
        align-items: center;
        gap: 6px;

        .weapon-icon { color: @color-hemolymph; }

        .weapon-name {
          font-family: "DistressBlack", sans-serif;
          text-transform: uppercase;
          font-size: @font-size-12;
          font-weight: 900;
          color: @theme-color-dark;
        }
      }

      .weapon-details {
        gap: 4px 12px;
        flex-wrap: wrap;

        .weapon-detail {
          font-family: "Roboto", sans-serif;
          font-size: @font-size-11;
          color: @color-text-dark-primary;

          strong { text-transform: uppercase; }
        }
      }
    }

    .combat-difficulty-options {
      flex-wrap: wrap;
      gap: 8px;

      .difficulty-option {
        display: flex;
        align-items: center;
        gap: 4px;
        font-family: "Roboto", sans-serif;
        text-transform: none;
        font-size: @font-size-12;
        color: @color-text-dark-primary;
        cursor: pointer;

        input[type="radio"] { flex: none; }

        &.locked {
          opacity: 0.8;
          font-style: italic;
        }
      }
    }

    .combat-targets {
      display: flex;
      align-items: center;
      flex-wrap: wrap;
      gap: 6px;
      padding: 4px 2px;

      .label {
        font-size: @font-size-11;
        color: @color-text-light-2;
      }

      .combat-target-tag {
        padding: 2px 8px;
        font-size: @font-size-11;
        font-family: "Roboto", sans-serif;
        color: @color-text-dark-header;
        background: fade(@color-hemolymph, 20%);
        border: 1px solid fade(@color-hemolymph, 50%);
        border-radius: 3px;
      }
    }

    // ── Phase d'Expérience ───────────────────────────────────────────
    .exp-phase-characters {
      flex: 1;
      overflow-y: auto;
      display: flex;
      flex-direction: column;
      gap: 8px;
      min-height: 0;

      details > div:not(summary) {
        padding: 8px;
        background: fade(@color-chitin-dark, 30%);
      }
    }

    // ── Dialogue d'apprentissage ─────────────────────────────────────
    .learning-summary {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 6px 8px;
      border: 1px solid @color-hemolymph;
      background: fade(@color-hemolymph, 10%);

      .label {
        font-size: @font-size-12;
        color: @color-text-light-2;
      }

      .exp-value {
        font-family: "DistressBlack", sans-serif;
        font-size: @font-size-20;
        color: @color-acid-green;
      }
    }

    .learning-type {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      padding: 6px 2px;

      label {
        display: flex;
        align-items: center;
        gap: 4px;
        font-family: "Roboto", sans-serif;
        text-transform: none;
        font-size: @font-size-12;
        color: @color-text-dark-primary;
        cursor: pointer;

        input[type="radio"] { flex: none; }

        &:hover { color: @color-acid-green; }
      }
    }

    .learning-targets {
      display: flex;
      flex-direction: column;
      gap: 6px;
      padding: 8px;
      border: 1px solid @color-border-dark-4;
      background: fade(@color-chitin-dark, 30%);

      .learning-hint {
        margin: 0;
        font-size: @font-size-11;
        font-style: italic;
        color: @color-text-dark-secondary;
        opacity: 0.8;
      }
    }

    .learning-result {
      display: flex;
      flex-wrap: wrap;
      gap: 8px 16px;
      padding: 8px;
      border: 1px solid @color-hemolymph;
      background: fade(@color-hemolymph, 8%);

      .context-item {
        display: flex;
        align-items: center;
        gap: 6px;

        .context-label {
          font-family: "DistressBlack", sans-serif;
          text-transform: uppercase;
          font-size: @font-size-11;
          color: @color-text-light-2;
        }

        .context-value {
          font-family: "Roboto", sans-serif;
          font-size: @font-size-13;
          font-weight: 700;
          color: @color-text-dark-primary;
        }
      }
    }

    // ── Transfert de Dés d'Expérience ─────────────────────────────────
    .experience-section {
      .experience-controls {
        gap: 8px;
        padding: 8px;

        .experience-group {
          font-size: @font-size-11;
          color: @color-text-dark-secondary;
          opacity: 0.8;

          #exp-group {
            font-weight: 700;
            color: @color-acid-green;
          }
        }

        button[data-action="giveToGroup"] {
          font-family: "DistressBlack", sans-serif;
          text-transform: uppercase;
          font-size: @font-size-11;
          padding: 3px 12px;
          cursor: pointer;
          color: @theme-color-dark;
          background: fade(@color-acid-green, 15%);
          border: 1px solid @color-acid-green;
          border-radius: 3px;
          .transition();

          &:hover:not(:disabled) {
            color: @theme-color-dark;
            background: @color-acid-green;
          }

          &:disabled {
            opacity: 0.6;
            cursor: default;
          }
        }
      }
    }

    // ── Total dice pool section ─────────────────────────────────────
    .total-section {
      align-items: center;
      padding: 10px;
      border-top: 1px solid @color-border-dark-4;
      margin-top: 4px;
      gap: 10px;
      background: fade(@color-chitin-dark, 50%);

      .label {
        font-family: "DistressBlack", sans-serif;
        text-transform: uppercase;
        font-size: @font-size-16;
        color: @color-text-light-0;
      }

      .total-value {
        font-family: "DistressBlack", sans-serif;
        font-size: @font-size-28;
        color: @color-text-light-0;
        text-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
      }

      .totem-selector {
        font-size: @font-size-11;
        color: @color-text-light-0;
        opacity: 0.7;
        margin-left: auto;

        select {
          font-size: @font-size-11;
          padding: 1px 4px;
          width: auto;
          display: inline;
        }
      }
    }
  }

  // ── Footer buttons ───────────────────────────────────────────────
  .sheet-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 8px 10px;
    margin-top: auto;
    border-top: 1px solid @color-border-dark-4;
    background: fade(@color-chitin-dark, 60%);

    button {
      font-family: "DistressBlack", sans-serif;
      text-transform: uppercase;
      font-size: @font-size-13;
      padding: 6px 20px;
      border: none;
      background: 50% 0% / cover no-repeat url("@{ui-path}/scotch.webp");
      box-shadow: 0px 0px 3px rgba(31, 26, 26, 0.979) inset;
      cursor: pointer;
      color: @theme-color-dark;
      .transition();
      display: flex;
      align-items: center;
      gap: 6px;

      &:hover {
        box-shadow: 0 0 10px @theme-color-highlight inset;
      }

      i {
        font-size: @font-size-14;
      }
    }
  }
}

// ── Achat d'Adaptation/Mutation ───────────────────────────────────────
.application.buy-evolution .bonus-item {
  align-items: center;
  gap: 8px;

  > label.label {
    flex: none;
    font-size: @font-size-12;
    color: @color-text-light-2;
    white-space: nowrap;
  }

  input[type="text"] {
    flex: 1 1 auto;
    min-width: 0;
  }

  select {
    flex: 1 1 auto;
    min-width: 0;
    width: auto;
  }

  input[type="checkbox"] {
    flex: none;
    width: 18px;
    height: 18px;
  }
}

// ── Gestion des Dés de Totems ─────────────────────────────────────────
.application.totem-dice .totem-dice-state {
  gap: 12px;
  padding: 6px 8px;
  border: 1px solid @color-hemolymph;
  background: fade(@color-hemolymph, 8%);

  .totem-state {
    display: flex;
    align-items: center;
    gap: 6px;

    .label {
      font-family: "DistressBlack", sans-serif;
      text-transform: uppercase;
      font-size: @font-size-12;
      color: @color-text-light-2;
      white-space: nowrap;
    }

    &.totem-human .label { color: @color-text-light-2; }
    &.totem-adapted .label { color: @color-text-light-2; }

    .value {
      font-family: "Roboto", sans-serif;
      font-size: @font-size-14;
      font-weight: 700;
      color: @color-text-dark-header;
    }
  }
}

.application.totem-dice .totem-influence {
  font-size: @font-size-16;
}

.application.totem-dice .totem-actions {
  gap: 8px;

  button {
    flex: 1 1 100%;
    font-family: "DistressBlack", sans-serif;
    text-transform: uppercase;
    font-size: @font-size-12;
    padding: 6px 10px;
    cursor: pointer;
    color: @theme-color-dark;
    background: fade(@color-hemolymph, 15%);
    border: 1px solid @color-hemolymph;
    border-radius: 3px;
    .transition();

    &:hover {
      color: @theme-color-dark;
      background: @color-hemolymph;
    }
  }
}
