@import "mixins";

// ─── Character sheet specifics ───────────────────────────────────────────────

.fvtt-celestopol.character {

  // Attributs perso (Entregent, Fortune, Rêve, Vision)
  .perso-attributs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;

    .perso-attr {
      display: flex;
      flex-direction: column;
      align-items: center;
      background: rgba(0,0,0,0.25);
      border: 1px solid var(--cel-orange);
      border-radius: 4px;
      padding: 4px 8px;
      min-width: 60px;

      label {
        font-size: 0.6em;
        text-transform: uppercase;
        color: var(--cel-orange-light);
      }

      .attr-display, .attr-val, .attr-max {
        color: var(--cel-orange);
        font-family: var(--cel-font-title);
        font-size: 1em;
        font-weight: bold;
      }

      input.attr-val, input.attr-max {
        width: 28px;
        text-align: center;
        background: transparent;
        border: none;
        border-bottom: 1px solid var(--cel-orange-light);
        color: var(--cel-orange);
      }
    }
  }

  // Stats × Domaines grid
  .stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    padding: 8px 0;

    .stat-block {
      border: 1px solid var(--cel-border);
      border-radius: 4px;
      overflow: hidden;

      .stat-header {
        background: var(--cel-green);
        background-image: url("../assets/ui/fond_cadrille.jpg");
        background-blend-mode: soft-light;
        color: var(--cel-orange);
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 5px 8px;
        border-bottom: 1px solid rgba(196,154,26,0.4);

        .stat-name {
          font-family: var(--cel-font-title);
          font-weight: bold;
          font-size: 1em;
          text-transform: uppercase;
          letter-spacing: 0.05em;
        }

        .stat-res {
          display: flex;
          align-items: center;
          gap: 4px;
          font-size: 0.8em;

          label { color: var(--cel-orange-light); }
          input[type="number"] { width: 30px; .cel-input-std(); }
          .stat-res-value {
            font-size: 1.3em;
            font-weight: bold;
            min-width: 24px;
            text-align: center;
          }
        }
      }

      .skills-list {
        background: var(--cel-cream);

        .skill-row {
          display: flex;
          align-items: center;
          justify-content: space-between;
          padding: 3px 8px;
          border-bottom: 1px solid rgba(122,92,32,0.18);
          font-size: 0.85em;

          // Alternating cream-dark rows for legibility
          &:nth-child(even) { background: var(--cel-cream-dark); }

          &.rollable { .cel-rollable(); }

          .skill-name { flex: 1; }
          .skill-value {
            font-weight: bold;
            min-width: 24px;
            text-align: center;
            color: var(--cel-orange);
          }
          .skill-value-input {
            width: 36px;
            .cel-input-std();
            text-align: center;
          }

          // Track de niveau (cases à cocher Art Déco)
          .skill-checkboxes-container {
            .skill-checkboxes {
              display: flex;
              gap: 3px;
              align-items: center;
            }
            .skill-checkbox-wrapper {
              line-height: 0;
              cursor: pointer;
              .skill-level-checkbox {
                appearance: none;
                -webkit-appearance: none;
                display: inline-block;
                width: 13px;
                height: 13px;
                border: 1px solid var(--cel-border);
                border-radius: 1px;
                background: rgba(255,255,255,0.3);
                cursor: pointer;
                vertical-align: middle;
                transition: background 0.1s, border-color 0.1s;
                &:checked {
                  background: var(--cel-orange);
                  border-color: var(--cel-border);
                }
                &:disabled { cursor: default; }
                &:disabled:checked {
                  background: var(--cel-orange);
                  border-color: var(--cel-border);
                  opacity: 1;
                }
              }
            }
          }
        }
      }
    }
  }

  // Items (anomalies, aspects, attributs)
  .items-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0;

    .items-group {
      .items-header {
        .cel-section-header();
        display: flex;
        justify-content: space-between;
        align-items: center;
        a { color: var(--cel-orange); cursor: pointer; }
      }

      .item-row { .cel-item-row(); }
    }
  }

  // Tracks (Blessures, Destin, Spleen)
  .track-section {
    border: 1px solid var(--cel-border);
    border-radius: 4px;
    margin-bottom: 12px;
    overflow: hidden;

    .track-header {
      background: var(--cel-green);
      background-image: url("../assets/ui/fond_cadrille.jpg");
      background-blend-mode: soft-light;
      color: var(--cel-orange);
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 5px 8px;
      border-bottom: 1px solid rgba(196,154,26,0.4);

      .track-title {
        font-family: var(--cel-font-title);
        font-weight: bold;
        text-transform: uppercase;
        font-size: 0.9em;
      }
    }

    .track-boxes {
      display: flex;
      padding: 8px;
      gap: 8px;
      flex-wrap: wrap;
      background: var(--cel-cream);

      .track-box {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;

        input[type="checkbox"] { .cel-box(); accent-color: var(--cel-orange); }
        .box-label {
          font-size: 0.65em;
          color: var(--cel-border);
        }

        &.checked input[type="checkbox"] {
          accent-color: var(--cel-orange);
        }
      }
    }

    .track-level {
      display: flex;
      align-items: center;
      gap: 6px;
      padding: 4px 8px;
      background: rgba(139,115,85,0.1);
      font-size: 0.85em;
      label { color: var(--cel-border); }
      input[type="number"] { width: 40px; .cel-input-std(); }
    }
  }

  // Factions table
  .factions-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;

    thead tr {
      background: var(--cel-green);
      background-image: url("../assets/ui/fond_cadrille.jpg");
      background-blend-mode: soft-light;
      color: var(--cel-orange);
      th { padding: 5px 8px; font-family: var(--cel-font-title); letter-spacing: 0.06em; }
    }

    .faction-row {
      &:nth-child(odd) td { background: rgba(122,92,32,0.06); }
      &:nth-child(even) td { background: var(--cel-cream-dark); }
      td { padding: 4px 8px; border-bottom: 1px solid rgba(122,92,32,0.2); }
      &.custom td { font-style: italic; color: #666; }

      .faction-value input[type="number"] {
        width: 50px;
        .cel-input-std();
        text-align: center;
      }
    }
  }

  // Biography / Equipment
  .equipments-section {
    margin-bottom: 12px;
    .section-header { .cel-section-header(); display: flex; justify-content: space-between; }
    .item-row { .cel-item-row(); }
    .item-qty { font-size: 0.8em; color: var(--cel-border); }
  }

  .biography-section, .notes-section {
    margin-bottom: 12px;
    .section-header { .cel-section-header(); }
    .enriched-html { font-size: 0.9em; line-height: 1.6; }
  }

  // ── Bloc Anomalie sur l'onglet Domaines ──────────────────────────────────
  .anomaly-block {
    border: 1px solid rgba(196,154,26,0.5);
    border-radius: 4px;
    margin-bottom: 12px;
    overflow: hidden;

    .anomaly-block-header {
      background: var(--cel-green);
      background-image: url("../assets/ui/fond_cadrille.jpg");
      background-blend-mode: soft-light;
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 5px 10px;
      border-bottom: 2px solid var(--cel-orange);

      .anomaly-block-title {
        font-family: var(--cel-font-title);
        font-size: 0.85em;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: var(--cel-orange);
      }
      a { color: var(--cel-orange-light); &:hover { color: var(--cel-orange); } }
    }

    .anomaly-empty {
      padding: 12px;
      text-align: center;
      color: var(--cel-border);
      font-style: italic;
      font-size: 0.85em;
      display: flex;
      align-items: center;
      justify-content: center;
      gap: 6px;
      i { font-size: 1.1em; }
    }

    .anomaly-content {
      padding: 8px 10px;
      background: rgba(240,232,212,0.06);

      .anomaly-info-row {
        display: flex;
        align-items: center;
        gap: 8px;
        margin-bottom: 7px;

        .anomaly-icon {
          width: 40px;
          height: 40px;
          object-fit: cover;
          border: 1px solid var(--cel-orange);
          border-radius: 3px;
        }

        .anomaly-details {
          flex: 1;
          .anomaly-name {
            font-family: var(--cel-font-title);
            font-size: 1em;
            color: var(--cel-orange);
            font-weight: bold;
          }
          .anomaly-subtype {
            font-size: 0.75em;
            color: var(--cel-orange-light);
            text-transform: uppercase;
            letter-spacing: 0.05em;
          }
        }

        .anomaly-controls {
          display: flex;
          gap: 6px;
          a { color: var(--cel-border); font-size: 0.9em; &:hover { color: var(--cel-orange); } }
        }
      }

      .anomaly-level-row {
        display: flex;
        align-items: center;
        gap: 6px;
        margin-bottom: 6px;

        .anomaly-level-label {
          font-size: 0.72em;
          text-transform: uppercase;
          color: var(--cel-orange-light);
          white-space: nowrap;
        }

        .anomaly-level-dots {
          display: flex;
          gap: 4px;
          .anomaly-level-dot {
            width: 10px;
            height: 10px;
            border-radius: 50%;
            border: 2px solid var(--cel-orange);
            &.active { background: var(--cel-orange); }
            &.inactive { background: transparent; border-color: rgba(196,154,26,0.25); }
          }
        }
      }

      .anomaly-uses-row {
        display: flex;
        align-items: center;
        gap: 6px;
        flex-wrap: wrap;

        .anomaly-uses-label {
          font-size: 0.72em;
          text-transform: uppercase;
          color: var(--cel-orange-light);
          white-space: nowrap;
        }

        .anomaly-uses-dots {
          display: flex;
          gap: 4px;
          .anomaly-dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
            border: 2px solid var(--cel-orange);
            &.available { background: var(--cel-orange); }
            &.spent     { background: transparent; }
            &.inactive  { background: transparent; border-color: rgba(196,154,26,0.25); }
          }
        }

        .anomaly-use-btn {
          background: var(--cel-green);
          border: 1px solid var(--cel-orange);
          color: var(--cel-orange);
          font-size: 0.72em;
          padding: 2px 8px;
          cursor: pointer;
          font-family: var(--cel-font-title);
          text-transform: uppercase;
          letter-spacing: 0.04em;
          border-radius: 2px;
          transition: background 0.15s;
          &:hover:not(:disabled) { background: var(--cel-green-light); }
          &:disabled { opacity: 0.4; cursor: default; }
        }

        .anomaly-reset-btn {
          color: var(--cel-border);
          font-size: 0.9em;
          &:hover { color: var(--cel-orange); }
        }
      }

      .anomaly-skills {
        margin-top: 6px;
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        align-items: center;

        .anomaly-skills-label {
          font-size: 0.7em;
          color: var(--cel-border);
          text-transform: uppercase;
        }

        .anomaly-skill-chip {
          background: rgba(196,154,26,0.1);
          border: 1px solid rgba(196,154,26,0.3);
          border-radius: 3px;
          padding: 1px 5px;
          font-size: 0.7em;
          color: var(--cel-orange-light);
        }
      }
    }
  }
}
