@import "mixins";

// ─── Item sheets shared ───────────────────────────────────────────────────────

.fvtt-celestopol.item {

  .item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background-color: var(--cel-green-dark);
    background-image: url("../assets/ui/fond_cadrille.jpg");
    background-blend-mode: soft-light;
    border-bottom: 3px solid var(--cel-orange);
    box-shadow: 0 3px 0 0 rgba(196,154,26,0.2);

    .item-portrait img {
      width: 56px;
      height: 56px;
      object-fit: cover;
      border: 2px solid var(--cel-orange);
      cursor: pointer;
    }

    .item-header-fields {
      flex: 1;
      display: flex;
      flex-direction: column;
      gap: 4px;

      input[type="text"] {
        background: transparent;
        border: none;
        border-bottom: 1px solid var(--cel-orange-light);
        color: var(--cel-orange);
        font-family: var(--cel-font-title);
        font-size: 1.2em;
        font-weight: bold;
        padding: 2px 4px;
      }

      .item-meta {
        display: flex;
        gap: 8px;
        align-items: center;

        select {
          background: transparent;
          border: 1px solid var(--cel-orange-light);
          color: var(--cel-orange);
          font-size: 0.85em;
          option { background: var(--cel-green-dark); color: var(--cel-cream); }
        }
      }

      .item-value-field {
        display: flex;
        align-items: center;
        gap: 4px;
        label { color: var(--cel-orange-light); font-size: 0.75em; text-transform: uppercase; }
        input[type="number"] {
          width: 40px;
          background: transparent;
          border: 1px solid var(--cel-orange-light);
          color: var(--cel-orange);
          text-align: center;
          font-size: 1.1em;
          font-weight: bold;
        }
      }
    }
  }

  .item-tabs {
    display: flex;
    background: var(--cel-green-dark);
    border-top: 1px solid rgba(196,154,26,0.3);
    border-bottom: 2px solid var(--cel-orange);

    .item {
      padding: 5px 12px;
      color: rgba(240,232,212,0.7);
      font-family: var(--cel-font-title);
      font-size: 0.78em;
      text-transform: uppercase;
      letter-spacing: 0.07em;
      cursor: pointer;
      border-right: 1px solid rgba(196,154,26,0.2);
      border-bottom: 3px solid transparent;
      transition: color 0.2s;

      &:hover {
        color: var(--cel-orange-light);
        background: rgba(196,154,26,0.07);
      }

      &.active {
        color: var(--cel-green-dark);
        background: linear-gradient(to bottom, var(--cel-orange-light), var(--cel-orange));
        border-bottom: 3px solid var(--cel-accent);
        font-weight: bold;
        transform: translateY(-1px);
        position: relative;
        z-index: 2;
      }
    }
  }

  // Affichage valeur en mode play
  .item-value-display {
    font-size: 1.1em;
    font-weight: bold;
    color: var(--cel-orange);
    min-width: 28px;
    text-align: center;
  }

  // Champ quantité équipement
  .item-qty {
    display: flex;
    align-items: center;
    gap: 4px;
    label { color: var(--cel-orange-light); font-size: 0.72em; text-transform: uppercase; }
    input[type="number"] {
      width: 44px;
      background: transparent;
      border: 1px solid var(--cel-orange-light);
      color: var(--cel-orange);
      text-align: center;
      font-weight: bold;
    }
  }

  section.tab {
    padding: 8px;
    display: none;
    &.active { display: block; }
  }

  .form-group {
    margin-bottom: 8px;
    label {
      display: block;
      font-size: 0.75em;
      text-transform: uppercase;
      letter-spacing: 0.05em;
      color: var(--cel-border);   // #7a5c20 — contraste WCAG AA sur fond crème
      margin-bottom: 2px;
    }
    input[type="text"], input[type="number"] { .cel-input-std(); width: 100%; box-sizing: border-box; }
  }

  // Scores grid
  .scores-section {
    .scores-header { .cel-section-header(); }

    .scores-grid {
      display: grid;
      grid-template-columns: repeat(2, 1fr);
      gap: 8px;

      .scores-stat-col {
        .scores-stat-name {
          font-family: var(--cel-font-title);
          font-size: 0.75em;
          color: var(--cel-orange);  // gold
          text-transform: uppercase;
          border-bottom: 1px solid var(--cel-border);
          margin-bottom: 4px;
          letter-spacing: 0.06em;
        }

        .score-row {
          display: flex;
          align-items: center;
          gap: 4px;
          padding: 2px 0;
          font-size: 0.8em;
          color: #1a1209;  // texte sombre lisible sur fond crème

          &:nth-child(even) { background: rgba(224,212,184,0.35); border-radius: 2px; }

          .score-skill-name { flex: 1; }
          .score-bonus, .score-malus {
            width: 36px;
            .cel-input-std();
            text-align: center;
          }
          .score-bonus { border-color: #4a7a4a; }
          .score-malus { border-color: var(--cel-accent); }
        }
      }
    }
  }

  // ── Anomaly-specific styles ───────────────────────────────────────────────

  &.anomaly {
    .anomaly-level-field {
      display: flex;
      align-items: center;
      gap: 4px;
      label { color: var(--cel-orange-light); font-size: 0.75em; text-transform: uppercase; }
      .level-input, .anomaly-level-value {
        width: 38px;
        background: transparent;
        border: 1px solid var(--cel-orange-light);
        color: var(--cel-orange);
        text-align: center;
        font-size: 1.1em;
        font-weight: bold;
      }
    }

    .anomaly-uses-row {
      display: flex;
      align-items: center;
      gap: 6px;
      margin-top: 5px;
      padding-top: 4px;
      border-top: 1px solid rgba(196,154,26,0.2);

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

      .anomaly-uses-dots { display: flex; gap: 4px; }

      .uses-number-input {
        width: 34px;
        background: transparent;
        border: 1px solid rgba(196,154,26,0.4);
        color: var(--cel-orange);
        text-align: center;
        font-size: 0.85em;
      }
    }

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

    .anomaly-skills-bar {
      background: var(--cel-green-dark, #0c4c0c);
      border-bottom: 2px solid var(--cel-orange, #e07b00);
      padding: 5px 10px;
      display: flex;
      flex-wrap: wrap;
      gap: 5px;
      align-items: center;

      .anomaly-skills-label {
        color: var(--cel-orange-light, #c49a1a);
        font-size: 0.72em;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        margin-right: 2px;
        white-space: nowrap;
      }

      .anomaly-skill-chip {
        background: rgba(196,154,26,0.18);
        border: 1px solid rgba(196,154,26,0.55);
        border-radius: 3px;
        padding: 1px 7px;
        font-size: 0.72em;
        color: var(--cel-cream, #f0e8d4);
      }
    }

    // Corps principal sans onglets
    .anomaly-body {
      background: var(--cel-cream, #f0e8d4);
      padding: 10px 12px;
      display: flex;
      flex-direction: column;
      gap: 10px;
      overflow-y: auto;
      max-height: 370px;
    }

    .anomaly-section {
      display: flex;
      flex-direction: column;
      gap: 4px;

      .anomaly-section-title {
        font-family: var(--cel-font-title);
        font-size: 0.78em;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: var(--cel-green-dark, #0c4c0c);
        background: linear-gradient(to right, rgba(12,76,12,0.12), transparent);
        border-left: 3px solid var(--cel-orange, #e07b00);
        padding: 2px 6px;
        margin-bottom: 2px;
      }

      .anomaly-editor-wrap {
        background: white;
        border: 1px solid rgba(122,92,32,0.3);
        border-radius: 3px;
        min-height: 60px;
        padding: 4px 6px;
        color: #1a1209;
        font-size: 0.88em;
        line-height: 1.5;

        // ProseMirror reset
        .editor-content, .prosemirror { color: #1a1209; background: transparent; }
        p { margin: 0 0 4px 0; color: #1a1209; }
      }
    }
  }

  // Equipment-specific
  &.equipment {
    .equipment-stats {
      display: grid;
      grid-template-columns: repeat(3, 1fr);
      gap: 6px;
      margin-bottom: 8px;
    }
  }
}
