// Character Main Sheet V2 - Based on PNG character sheet design
.character-main-v2 {
  .sheet-common();
  padding: 0;
  margin: 0;

  .character-sheet-wrapper {
    background-image: url("../assets/ui/prism_rpg_background.webp");
    background-size: cover;
    background-position: center;
    padding: 2px 4px;
    min-height: auto;
  }

  // Character Header with Banner
  .character-header {
    position: relative;
    margin-bottom: 3px;

    .character-name-banner {
      background-image: url("../assets/sheet/banner-bg.png");
      background-size: contain;
      background-repeat: no-repeat;
      background-position: center;
      height: 42px;
      display: flex;
      align-items: center;
      justify-content: center;

      input {
        background: transparent;
        border: none;
        text-align: center;
        font-family: "Cinzel", serif;
        font-size: 20px;
        font-weight: bold;
        color: #2c2c2c;
        width: 500px;
        text-shadow: 1px 1px 2px rgba(255, 255, 255, 0.5);
        padding: 2px 0;
      }
    }

    .character-toggle-controls {
      position: absolute;
      top: 6px;
      right: 10px;
    }
  }

  // Main Grid Layout
  .character-main-grid {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 12px;
    align-items: start;
  }

  // Left Column - Portrait, Attributes, HP
  .character-left-column {
    display: grid;
    grid-template-columns: 200px 1fr;
    grid-template-rows: auto auto;
    column-gap: 12px;
    row-gap: 8px;
    align-items: start;
    min-width: 0;

    .portrait-hp-column {
      display: flex;
      flex-direction: column;
      gap: 12px;
      width: 200px;
      grid-column: 1;
      grid-row: 1 / 3;
    }

    .character-portrait {
      width: 200px;
      height: 200px;
      border: 3px solid #6b6b6b;
      border-radius: 8px;
      overflow: hidden;
      background: #d4d4d4;

      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
      }
    }

    // HP Shields - below portrait, same width
    .hp-shields-section {
      width: 200px;

      .hp-shields {
        display: flex;
        flex-direction: column;
        gap: 6px;

        .hp-item {
          display: flex;
          flex-direction: row;
          align-items: center;
          gap: 8px;

          .hp-label {
            font-family: "Cinzel", serif;
            font-size: 12px;
            font-weight: bold;
            color: #2c2c2c;
            text-transform: uppercase;
            width: 55px;
            flex-shrink: 0;
          }

          .hp-value {
            input {
              width: 40px;
              height: 28px;
              text-align: center;
              font-size: 14px;
              font-weight: bold;
              background: rgba(255, 255, 255, 0.9);
              border: 2px solid #6b6b6b;
              border-radius: 4px;
            }
          }

          .hp-separator {
            font-family: "Cinzel", serif;
            font-size: 14px;
            font-weight: bold;
            color: #2c2c2c;
          }

          .hp-max {
            input {
              width: 40px;
              height: 28px;
              text-align: center;
              font-size: 14px;
              font-weight: bold;
              background: rgba(200, 220, 255, 0.5);
              border: 2px solid #6b6b6b;
              border-radius: 4px;
            }
          }

          &.hp-temp-item {
            .hp-value input {
              background: rgba(255, 230, 160, 0.85);
              border-color: #b8860b;
            }
          }
        }
      }
    }

    .character-attributes {
      display: flex;
      flex-direction: column;
      gap: 6px;
      grid-column: 2;
      grid-row: 1;
      min-width: 0;

      .attribute-shield {
        position: relative;
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 8px;
        padding: 6px 12px;
        background: rgba(255, 255, 255, 0.3);
        border: 2px solid #6b6b6b;
        border-radius: 4px;
        height: auto;

        .attribute-label {
          font-family: "Cinzel", serif;
          font-size: 11px;
          font-weight: bold;
          color: #2c2c2c;
          text-transform: uppercase;
          margin: 0;
          min-width: 40px;
          display: flex;
          align-items: center;

          a.rollable {
            display: flex;
            align-items: center;
            gap: 4px;
            color: #2c2c2c;
            text-decoration: none;
            cursor: pointer;
            transition: all 0.2s;

            i {
              font-size: 12px;
              color: #6b6b6b;
            }

            &:hover {
              color: #000;
              text-shadow: 0 0 4px rgba(0, 0, 0, 0.3);

              i {
                color: #2c2c2c;
              }
            }
          }
        }

        .attribute-value {
          display: flex;
          align-items: center;

          input {
            width: 45px;
            height: 32px;
            text-align: center;
            font-size: 16px;
            font-weight: bold;
            background: rgba(255, 255, 255, 0.9);
            border: 2px solid #6b6b6b;
            border-radius: 4px;
          }
        }

        .attribute-save {
          margin-left: auto;
          display: flex;
          align-items: center;

          a.save-rollable {
            display: contents;
            cursor: pointer;

            i {
              margin-right: 6px;
            }

            &:hover input {
              background: rgba(200, 220, 255, 0.8);
              border-color: #4a4a4a;
            }
          }

          input {
            width: 45px;
            height: 32px;
            text-align: center;
            font-size: 14px;
            font-weight: bold;
            background: rgba(200, 220, 255, 0.5);
            border: 2px solid #6b6b6b;
            border-radius: 4px;
            color: #2c2c2c;
            cursor: pointer;
            transition: all 0.2s;
          }
        }
      }
    }
  }

  // Right Column - Race, Classes
  .character-right-column {
    display: flex;
    flex-direction: column;
    gap: 15px;

    .section-title {
      font-family: "Cinzel", serif;
      font-size: 14px;
      font-weight: bold;
      color: #2c2c2c;
      text-transform: uppercase;
      margin-bottom: 8px;
      padding: 5px 10px;
      background: rgba(255, 255, 255, 0.6);
      border: 2px solid #6b6b6b;
      border-radius: 4px;
      text-align: center;
    }

    .race-section {
      .race-box {
        padding: 6px;
        background: rgba(255, 255, 255, 0.5);
        border: 2px solid #6b6b6b;
        border-radius: 6px;
        min-height: 50px;

        .race-label {
          font-family: "Cinzel", serif;
          font-size: 10px;
          color: #6b6b6b;
          text-align: center;
          margin-bottom: 3px;
        }

        .section-title {
          font-family: "Cinzel", serif;
          font-size: 11px;
          font-weight: bold;
          color: #2c2c2c;
          text-transform: uppercase;
          margin: 0 0 4px 0;
          padding: 3px;
          background: rgba(255, 255, 255, 0.6);
          border: 2px solid #6b6b6b;
          border-radius: 4px;
          text-align: center;
        }

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

          .item-img {
            width: 30px;
            height: 30px;
            border: 2px solid #6b6b6b;
            border-radius: 4px;
            object-fit: cover;
            cursor: pointer;
          }

          .race-name {
            flex: 1;
            font-family: "Cinzel", serif;
            font-size: 12px;
            font-weight: bold;
            color: #2c2c2c;
            text-align: center;
          }

          .controls {
            display: flex;
            gap: 6px;

            a {
              color: #6b6b6b;
              cursor: pointer;
              transition: color 0.2s;

              &:hover {
                color: #2c2c2c;
              }

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

        .no-race {
          text-align: center;
          font-family: "Crimson Text", serif;
          font-size: 11px;
          color: #6b6b6b;
          font-style: italic;
          padding: 5px;
        }

        input {
          width: 100%;
          background: transparent;
          border: none;
          font-family: "Cinzel", serif;
          font-size: 14px;
          text-align: center;
        }
      }
    }

    .classes-section {
      display: flex;
      flex-direction: column;
      gap: 8px;

      .class-box {
        padding: 6px;
        background: rgba(255, 255, 255, 0.5);
        border: 2px solid #6b6b6b;
        border-radius: 6px;

        .class-label {
          font-family: "Cinzel", serif;
          font-size: 10px;
          color: #6b6b6b;
          text-align: center;
          margin-bottom: 3px;
        }

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

            .item-img {
              width: 28px;
              height: 28px;
              border: 2px solid #6b6b6b;
              border-radius: 4px;
              object-fit: cover;
              cursor: pointer;
            }

            .class-name {
              flex: 1;
              font-family: "Cinzel", serif;
              font-size: 11px;
              font-weight: bold;
              color: #2c2c2c;
              text-align: center;
            }

            .controls {
              display: flex;
              gap: 6px;

              a {
                color: #6b6b6b;
                cursor: pointer;
                transition: color 0.2s;

                &:hover {
                  color: #2c2c2c;
                }

                i {
                  font-size: 12px;
                }
              }
            }
          }

          .no-class {
            text-align: center;
            font-family: "Crimson Text", serif;
            font-size: 11px;
            color: #6b6b6b;
            font-style: italic;
            padding: 5px;
          }
        }

        .class-input {
          input {
            width: 100%;
            background: transparent;
            border: none;
            font-family: "Cinzel", serif;
            font-size: 14px;
            text-align: center;
          }
        }
      }
    }

    .origin-section {
      .origin-box {
        padding: 15px;
        background: rgba(255, 255, 255, 0.5);
        border: 3px solid #6b6b6b;
        border-radius: 8px;
        min-height: 350px;

        textarea {
          width: 100%;
          min-height: 320px;
          background: transparent;
          border: none;
          font-family: "Crimson Text", serif;
          font-size: 13px;
          line-height: 1.6;
          resize: vertical;
        }
      }
    }
  }
}

// Movement Rating + Burden section
.burden-mr-section {
  display: flex;
  flex-direction: row;
  gap: 16px;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 4px;
  grid-column: 2;
  grid-row: 2;

  .burden-mr-item {
    display: flex;
    flex-direction: column;
    gap: 3px;

    .burden-display-row {
      display: flex;
      align-items: center;
      gap: 8px;
      min-height: 22px;
    }

    .burden-edit-row {
      display: flex;
      align-items: center;
      gap: 3px;
      flex-wrap: wrap;
    }

    .burden-label {
      font-weight: bold;
      font-size: 11px;
      letter-spacing: 0.05em;
      min-width: 52px;
      color: #fff;
      cursor: default;
    }

    .burden-sub-attr {
      // formField helper renders a .form-group with label stacked above select.
      // Flatten it so the select sits inline in the flex row.
      .form-group {
        display: contents;
        label { display: none; }
      }
      .form-fields {
        display: contents;
      }
      select {
        font-size: 11px;
        padding: 1px 2px;
        height: 22px;
        max-width: 80px;
        background: rgba(0, 0, 0, 0.3);
        color: #fff;
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 3px;
      }
    }

    .burden-op {
      font-size: 11px;
      color: rgba(255, 255, 255, 0.9);
      flex-shrink: 0;
    }

    .burden-other {
      input[type="number"] {
        width: 32px;
        text-align: center;
        font-size: 11px;
        height: 22px;
        background: rgba(0, 0, 0, 0.3);
        color: #fff;
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 3px;
      }
    }

    .burden-total {
      font-size: 18px;
      font-weight: bold;
      color: #ffe566;
      min-width: 24px;
      text-align: center;
    }

    .burden-used-max {
      display: flex;
      align-items: center;
      gap: 2px;
      font-size: 14px;
      font-weight: bold;

      .burden-used { color: #ffe566; }
      .burden-separator { color: rgba(255, 255, 255, 0.8); }
      .burden-max { color: #e0e0e0; }

      &.burden-overloaded {
        .burden-used { color: #ff5c5c; font-weight: bold; }
      }
    }
  }
}
