// ─── Roll dialog ─────────────────────────────────────────────────────────────

.application.roll-dialog .window-content {
  padding: 0 !important;
}

.application.roll-dialog .dialog-content {
  padding: 0 !important;
  display: block !important;
}

.application.roll-dialog .roll-dialog-content {
  padding: 10px 14px 14px;
  font-family: var(--cel-font-body, "Palatino Linotype", serif);
  min-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0;

  // ── Bloc info acteur ──
  .roll-info-block {
    background: var(--cel-green, #0c4c0c);
    background-image: url("../assets/ui/fond_cadrille.jpg");
    background-blend-mode: soft-light;
    border-bottom: 2px solid var(--cel-orange, #e07b00);
    padding: 10px 14px 12px;
    margin: -10px -14px 12px;
    text-align: center;

    .roll-actor {
      font-family: var(--cel-font-title, "CopaseticNF", serif);
      color: var(--cel-orange-light, #ddb84a);
      font-size: 0.78em;
      letter-spacing: 0.07em;
      text-transform: uppercase;
      opacity: 0.9;
    }

    .roll-skill-line {
      font-family: var(--cel-font-title, "CopaseticNF", serif);
      font-size: 1.25em;
      color: var(--cel-cream, #f0e8d4);
      margin-top: 2px;

      .stat-label { color: var(--cel-orange-light, #ddb84a); }
      .sep { color: rgba(196,154,26,0.45); margin: 0 5px; }
    }

    .roll-dice-summary {
      margin-top: 8px;
      padding: 5px 12px;
      background: rgba(0,0,0,0.28);
      border-radius: 4px;

      .dice-breakdown {
        display: flex;
        align-items: baseline;
        justify-content: center;
        flex-wrap: wrap;
        gap: 4px;
        font-size: 0.82em;
        color: var(--cel-cream, #f0e8d4);

        .dval, .nb-dice {
          font-family: var(--cel-font-title, "CopaseticNF", serif);
          font-size: 1.7em;
          color: var(--cel-orange, #e07b00);
          font-weight: bold;
          line-height: 1;
        }
        .dlabel { font-size: 0.78em; text-transform: uppercase; letter-spacing: 0.04em; opacity: 0.75; }
        .dminus { color: #f0a0a0; font-weight: bold; }
        .deq    { opacity: 0.55; }
        .ddice  { color: var(--cel-orange, #e07b00); }
      }

      .wound-info {
        font-size: 0.73em;
        color: #f0a0a0;
        margin-top: 3px;
      }
    }
  }

  // ── Ligne Dé de la Lune ──
  .form-moon-row {
    border: 1px solid rgba(122,92,32,0.35);
    border-radius: 4px;
    background: rgba(255,255,255,0.3);
    padding: 7px 10px;

    .moon-toggle {
      display: flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;

      input[type="checkbox"] {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
        appearance: none;
        -webkit-appearance: none;
        border: 2px solid var(--cel-border, #7a5c20);
        border-radius: 2px;
        background: white;
        cursor: pointer;
        position: relative;

        &:checked {
          background: var(--cel-orange, #e07b00);
          border-color: var(--cel-orange, #e07b00);
          &::after {
            content: "✦";
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.65em;
            color: white;
          }
        }
      }

      .moon-icon { font-size: 1.2em; flex-shrink: 0; }

      .moon-text {
        font-family: var(--cel-font-title, "CopaseticNF", serif);
        font-size: 0.88em;
        color: var(--cel-green, #0c4c0c);
      }
    }
  }

  // ── Lignes de formulaire ──
  .roll-form-rows {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 10px;
    background: var(--cel-cream, #f0e8d4);
    border: 1px solid rgba(122,92,32,0.3);
    border-radius: 4px;
    padding: 10px 12px;
  }

  .form-row-line {
    display: flex;
    align-items: center;
    gap: 8px;

    label {
      flex: 0 0 110px;
      font-size: 0.78em;
      text-transform: uppercase;
      letter-spacing: 0.04em;
      color: var(--cel-border, #7a5c20);
    }

    select, input[type="number"] {
      flex: 1;
      border: 1px solid rgba(122,92,32,0.5);
      border-radius: 3px;
      padding: 3px 7px;
      background: rgba(255,255,255,0.85);
      font-family: inherit;
      font-size: 0.85em;
      color: #333;

      &:focus { outline: 1px solid var(--cel-orange, #e07b00); }
    }
  }

  .form-two-col {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;

    .form-row-line {
      flex-direction: column;
      align-items: stretch;
      gap: 2px;

      label {
        flex: none;
        text-align: left;
      }

      input { width: 100%; box-sizing: border-box; }
    }
  }

  // ── Ligne Destin ──
  .form-destin-row {
    border: 1px solid var(--cel-orange, #e07b00);
    border-radius: 4px;
    background: rgba(196,154,26,0.08);
    padding: 7px 10px;

    &.destin-disabled {
      border-color: rgba(122,92,32,0.3);
      background: rgba(0,0,0,0.04);
      opacity: 0.7;
    }

    .destin-toggle {
      display: flex;
      align-items: center;
      gap: 8px;
      cursor: pointer;
      width: 100%;

      input[type="checkbox"] {
        width: 16px;
        height: 16px;
        flex-shrink: 0;
        appearance: none;
        -webkit-appearance: none;
        border: 2px solid var(--cel-border, #7a5c20);
        border-radius: 2px;
        background: white;
        cursor: pointer;
        position: relative;

        &:checked {
          background: var(--cel-orange, #e07b00);
          border-color: var(--cel-orange, #e07b00);
          &::after {
            content: "✦";
            position: absolute;
            inset: 0;
            display: flex;
            align-items: center;
            justify-content: center;
            font-size: 0.65em;
            color: white;
          }
        }

        &:disabled { opacity: 0.5; cursor: not-allowed; }
      }

      .destin-icon {
        font-size: 1.1em;
        color: var(--cel-orange, #e07b00);
        flex-shrink: 0;
      }

      .destin-text {
        flex: 1;

        .destin-main {
          font-family: var(--cel-font-title, "CopaseticNF", serif);
          font-size: 0.9em;
          color: var(--cel-green, #0c4c0c);
          display: block;
        }

        .destin-bonus {
          font-size: 0.72em;
          color: var(--cel-border, #7a5c20);
          font-style: italic;
        }
      }

      .destin-count {
        font-size: 0.75em;
        font-weight: bold;
        color: var(--cel-green, #0c4c0c);
        background: rgba(196,154,26,0.2);
        border: 1px solid rgba(196,154,26,0.4);
        border-radius: 10px;
        padding: 1px 8px;
        white-space: nowrap;

        &.no-destin {
          color: #888;
          background: rgba(0,0,0,0.05);
          border-color: rgba(0,0,0,0.1);
        }
      }
    }
  }

  .form-visibility label { color: #888; }

  // ── Prévisualisation ──
  .dice-preview {
    text-align: center;
    padding: 10px 8px;
    background: linear-gradient(160deg, rgba(12,76,12,0.06), rgba(12,76,12,0.12));
    border-radius: 4px;
    border: 1px solid rgba(12,76,12,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;

    .preview-label {
      font-size: 0.7em;
      text-transform: uppercase;
      letter-spacing: 0.07em;
      color: var(--cel-border, #7a5c20);
      opacity: 0.8;
    }

    .preview-formula {
      font-family: var(--cel-font-title, "CopaseticNF", serif);
      font-size: 1.6em;
      color: var(--cel-orange, #e07b00);
      font-weight: bold;
      letter-spacing: 0.04em;
    }
  }
}

// ─── Chat message ─────────────────────────────────────────────────────────────

.celestopol.chat-roll {
  border: 1px solid var(--cel-border, #7a5c20);
  border-radius: 3px;
  overflow: hidden;
  font-family: var(--cel-font-body, "Palatino Linotype", serif);

  // ── En-tête ──
  .roll-header {
    display: flex;
    align-items: center;
    gap: 8px;
    background-color: var(--cel-green, #0c4c0c);
    background-image: url("../assets/ui/fond_cadrille.jpg");
    background-blend-mode: soft-light;
    padding: 6px 8px;
    border-bottom: 2px solid var(--cel-orange, #e07b00);

    .actor-img {
      width: 40px;
      height: 40px;
      object-fit: cover;
      border: 1px solid var(--cel-orange, #e07b00);
      border-radius: 2px;
      flex-shrink: 0;
    }

    .roll-info {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 1px;

      .actor-name {
        font-family: var(--cel-font-title, "CopaseticNF", serif);
        color: var(--cel-orange, #e07b00);
        font-weight: bold;
        letter-spacing: 0.05em;
        font-size: 0.92em;
      }
      .skill-info {
        color: var(--cel-cream, #f0e8d4);
        font-size: 0.77em;
        font-style: italic;
        .stat-lbl { color: var(--cel-orange-light, #ddb84a); }
        .sep { margin: 0 2px; opacity: 0.5; }
      }
      .wound-info { font-size: 0.7em; color: #f0a0a0; }
    }

    .moon-badge { display: none; }
  }

  // ── Zone dés ──
  .dice-zone {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    padding: 8px 10px 5px;
    background: var(--cel-cream, #f0e8d4);
    justify-content: center;

    .die-face {
      display: inline-flex;
      align-items: center;
      justify-content: center;
      width: 32px;
      height: 32px;
      border: 2px solid var(--cel-border, #7a5c20);
      border-radius: 4px;
      background: white;
      font-weight: bold;
      font-size: 1.05em;
      font-family: var(--cel-font-title, "CopaseticNF", serif);
      box-shadow: 1px 1px 2px rgba(0,0,0,0.12);
      color: #222;

      &.max {
        background: var(--cel-green, #0c4c0c);
        color: var(--cel-orange, #e07b00);
        border-color: var(--cel-orange, #e07b00);
        box-shadow: 0 0 5px rgba(224,123,0,0.3);
      }
      &.min {
        background: #fae8e8;
        color: #a03030;
        border-color: #c07070;
      }
    }
  }

  // ── Formule ──
  .formula-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;
    gap: 4px;
    padding: 5px 10px 4px;
    background: var(--cel-cream, #f0e8d4);
    border-top: 1px solid rgba(122,92,32,0.2);
    font-size: 0.83em;
    color: #555;

    .fl-label { color: #999; font-size: 0.88em; text-transform: uppercase; letter-spacing: 0.04em; margin-right: 2px; }
    .fl-ndice { color: var(--cel-green, #0c4c0c); font-weight: bold; }
    .fl-sum   { font-weight: bold; color: #333; }
    .fl-total {
      font-family: var(--cel-font-title, "CopaseticNF", serif);
      font-size: 1.5em;
      color: var(--cel-orange, #e07b00);
      font-weight: bold;
      line-height: 1;
    }
    .fl-mod   { color: #444; font-weight: bold; }
    .fl-asp   { color: var(--cel-orange, #e07b00); font-weight: bold; }
    .fl-sep   { font-weight: bold; color: var(--cel-border, #7a5c20); margin: 0 2px; }
    .fl-eq    { color: #aaa; }
    .fl-op    { color: #aaa; }
  }

  // ── Seuil et marge ──
  .threshold-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 12px 6px;
    background: var(--cel-cream, #f0e8d4);
    border-top: 1px solid rgba(122,92,32,0.2);
    font-size: 0.82em;

    .vs-wrap {
      display: flex;
      align-items: baseline;
      gap: 5px;
    }
    .vs-label  { color: #aaa; text-transform: uppercase; font-size: 0.8em; }
    .diff-label{ font-style: italic; color: var(--cel-green, #0c4c0c); }
    .diff-val  { color: #888; }

    .margin-badge {
      padding: 2px 10px;
      border-radius: 12px;
      font-weight: bold;
      font-size: 1.05em;
      font-family: var(--cel-font-title, "CopaseticNF", serif);
      letter-spacing: 0.05em;

      &.above {
        background: var(--cel-green, #0c4c0c);
        color: var(--cel-orange, #e07b00);
        border: 1px solid var(--cel-orange, #e07b00);
      }
      &.below {
        background: var(--cel-accent, #6b1e28);
        color: #f0d0d0;
        border: 1px solid #8b3e48;
      }
    }
  }

  // ── Destin utilisé ──
  .used-info {
    text-align: center;
    font-size: 0.77em;
    color: var(--cel-orange, #e07b00);
    padding: 3px 8px;
    background: rgba(196,154,26,0.1);
    border-top: 1px dashed var(--cel-border, #7a5c20);

    .used-destin { font-weight: bold; }
  }

  // ── Résultat dé de lune ──
  .moon-die-result {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-top: 1px solid rgba(122,92,32,0.2);
    font-family: var(--cel-font-body, serif);

    .moon-die-face {
      font-size: 1.8em;
      line-height: 1;
      flex-shrink: 0;
    }

    .moon-die-info {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 1px;
    }

    .moon-die-phase {
      font-size: 0.72em;
      opacity: 0.75;
      text-transform: uppercase;
      letter-spacing: 0.05em;
    }

    .moon-die-type {
      font-family: var(--cel-font-title, "CopaseticNF", serif);
      font-size: 1em;
      font-weight: bold;
      letter-spacing: 0.06em;
      text-transform: uppercase;
    }

    .moon-die-desc {
      font-size: 0.72em;
      font-style: italic;
      opacity: 0.85;
      line-height: 1.3;
    }

    // Couleurs par type de résultat
    &.moon-triomphe {
      background: linear-gradient(90deg, rgba(12,76,12,0.12), rgba(12,76,12,0.05));
      .moon-die-type { color: var(--cel-green, #0c4c0c); }
    }
    &.moon-brio {
      background: linear-gradient(90deg, rgba(196,154,26,0.12), rgba(196,154,26,0.04));
      .moon-die-type { color: var(--cel-border, #7a5c20); }
    }
    &.moon-contrecoup {
      background: linear-gradient(90deg, rgba(120,80,0,0.1), rgba(120,80,0,0.03));
      .moon-die-type { color: #7a4a00; }
    }
    &.moon-catastrophe {
      background: linear-gradient(90deg, rgba(107,30,40,0.15), rgba(107,30,40,0.05));
      .moon-die-type { color: #6b1e28; }
    }
  }

  // ── Bandeau résultat ──
  .roll-result-banner {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 7px 8px;
    font-family: var(--cel-font-title, "CopaseticNF", serif);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    border-top: 2px solid rgba(0,0,0,0.1);

    .result-icon {
      font-size: 0.85em;
      opacity: 0.85;
      letter-spacing: 0.15em;
    }
    .result-label { font-size: 1.2em; line-height: 1.2; }
    .result-desc {
      font-size: 0.65em;
      letter-spacing: 0.08em;
      margin-top: 2px;
      opacity: 0.8;
      text-transform: none;
      font-style: italic;
      font-family: var(--cel-font-body, serif);
    }

    &.success {
      background-color: var(--cel-green, #0c4c0c);
      background-image: url("../assets/ui/fond_cadrille.jpg");
      background-blend-mode: soft-light;
      color: var(--cel-orange, #e07b00);
    }

    &.critical-success {
      background: linear-gradient(135deg, #0c4c0c 0%, #1a6e1a 50%, #0c4c0c 100%);
      background-image: url("../assets/ui/fond_cadrille.jpg");
      background-blend-mode: soft-light;
      color: #ffd870;
      border-top: 3px solid var(--cel-orange, #e07b00);
      border-bottom: 3px solid var(--cel-orange, #e07b00);
      text-shadow: 0 0 10px rgba(255,216,112,0.6);
    }

    &.failure {
      background: #4a1520;
      color: #f0c0c0;
    }

    &.critical-failure {
      background: linear-gradient(135deg, #3d0f18 0%, #5c1a25 50%, #3d0f18 100%);
      color: #ffd0d0;
      border-top: 3px solid #8b3e48;
      border-bottom: 3px solid #8b3e48;
    }
  }
}

