/* ==============================
   RESET
   ============================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ==============================
   BODY
   ============================== */

body {
    background-color: #000000;
    color: #c4b395;
    font-family: Arial, sans-serif;
}

header,
legend,
button,
label {
    font-family: "Cinzel", serif;
}

/* ==============================
   HEADER
   ============================== */

header {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    padding: 25px 20px;
    margin-bottom: 10px;

    border-bottom: 1px solid #6b552c;
}

header h1 {
    font-size: 60px;
    font-weight: 700;
    letter-spacing: 2px;
    text-align: center;
}

header h1 i {
    color: #c9952e;
    font-size: 0.8em;
}

header p {
    margin-top: 5px;
    color: #c4b395;
    font-family: "Cinzel", serif;
    font-size: 14px;
    text-align: center;
}

/* ==============================
   MAIN / FORM
   ============================== */

main {
    display: flex;
    justify-content: center;
    align-items: center;

    width: 100%;
    max-width: 1200px;

    margin: 0 auto;
    padding: 20px;

    border: 1px solid #6b552c;
    border-radius: 10px;
}

form {
    width: 100%;
}

/* ==============================
   FIELDSETS
   ============================== */

fieldset {
    min-width: 0;
    margin: 10px;
    padding: 20px;

    border: 1px solid #6b552c;
    border-radius: 8px;

    background-color: #111111;
}

legend {
    padding: 5px 15px;

    color: #c9952e;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: 1px;
}

label {
    display: block;

    margin-bottom: 10px;

    font-size: 16px;
    font-weight: 500;
}

/* ==============================
   BUTTONS
   ============================== */

button {
    padding: 10px;

    border: 1px solid #3f3c35;
    border-radius: 5px;

    background-color: #1b1714;
    color: #e0caa5;

    font-size: 18px;
    font-weight: 600;

    transition: 0.2s;
}

button:hover {
    border-color: #c9952e;
    background-color: #2a241e;
    cursor: pointer;
}

/* ==============================
   CHARACTER INFORMATION
   ============================== */

.character-info-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
}

.character-field {
    flex: 0 0 calc(50% - 8px);
    margin-bottom: 5px;
    color: #d6b56d;
}

.character-info {
    width: 100%;
    padding: 10px;

    border: 1px solid #33322e;
    border-radius: 8px;

    background-color: #0a0a0a;
    color: #85817e;
}

.character-info:focus {
    outline: none;
    border-color: #c9952e;
}

/* ==============================
   PHOTO
   ============================== */

.photo-field {
    width: 100%;
    margin-top: 10px;
}

.photo-field input {
    width: 100%;
    margin-top: 5px;
}

.photo-field input[type="file"] {
    width: 100%;
    padding: 8px;

    border: 1px solid #33322e;
    border-radius: 6px;

    background-color: #0a0a0a;
    color: #c4b395;
}

.photo-field input[type="file"]::file-selector-button {
    margin-right: 10px;
    padding: 6px 12px;

    border: 1px solid #6b552c;
    border-radius: 5px;

    background-color: #1b1714;
    color: #e0caa5;

    font-family: "Cinzel", serif;
    cursor: pointer;
}

.photo-field input[type="file"]::file-selector-button:hover {
    border-color: #c9952e;
    background-color: #2a241e;
}

.photo-title {
    color: #c9952e;
    font-size: 18px;
    letter-spacing: 1px;
}

/* ==============================
   ERRORS
   ============================== */

#ageError,
#attributeError,
#photoError {
    margin-top: 5px;

    color: #b85c5c;
    font-size: 14px;
}

/* ==============================
   BIOGRAPHY
   ============================== */

.biography-input {
    width: 100%;
    min-height: 250px;
    padding: 15px;

    border: 1px solid #33322e;
    border-radius: 8px;

    background-color: #0a0a0a;
    color: #85817e;

    resize: vertical;
}

.biography-input:focus {
    outline: none;
    border-color: #c9952e;
}

.bio-label{
    color: #d6b56d;
}

/* ==============================
   GENERIC INPUTS
   ============================== */

.attribute,
.item-field input {
    padding: 10px;

    border: 1px solid #33322e;
    border-radius: 6px;

    background-color: #0a0a0a;
    color: #c4b395;
}

.attribute:focus,
.item-field input:focus {
    outline: none;
    border-color: #c9952e;
}

/* ==============================
   ATTRIBUTES
   ============================== */

.attributes-container {
    display: flex;
    flex-direction: column;

    border: 1px solid #33322e;
    border-radius: 6px;

    overflow: hidden;
}

.attributes-header {
    display: flex;
    align-items: center;

    padding: 10px;

    border-bottom: 1px solid #33322e;

    background-color: #1b1714;
    color: #c9952e;

    font-family: "Cinzel", serif;
    font-weight: 600;
}

.attributes-header > :nth-child(1) {
    flex: 1;
}

.attributes-header > :nth-child(2) {
    flex: 3;
}

.attributes-header > :nth-child(3) {
    flex: 0.5;
}

.attributes-header > :nth-child(2),
.attributes-header > :nth-child(3) {
    padding-left: 10px;
}

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

    padding: 8px 10px;

    border-bottom: 1px solid #33322e;

    background-color: #0a0a0a;
}

.attribute-row:last-child {
    border-bottom: none;
}

.attribute-row > :nth-child(1) {
    flex: 1;
}

.attribute-row > :nth-child(2) {
    flex: 3;
}

.attribute-row > :nth-child(3) {
    flex: 0.5;
}

.attribute-row > :nth-child(2),
.attribute-row > :nth-child(3) {
    padding-left: 10px;
}

.attribute-span{
    font-family: "Cinzel", serif;
    font-size: 16px;
    font-weight: bold;
    color: #d6b56d;
}


/* ==============================
   ITEMS
   ============================== */

.items-container {
    display: flex;
    flex-direction: column;

    border: 1px solid #33322e;
    border-radius: 6px;

    overflow: hidden;
}

/* Cabeçalho e linhas usam exatamente
   as mesmas cinco colunas. */

.items-header {
    display: grid;
    grid-template-columns:
        40px
        minmax(0, 2fr)
        90px
        minmax(0, 3fr)
        50px;

    align-items: center;

    padding: 10px;

    border-bottom: 1px solid #33322e;

    background-color: #1b1714;
    color: #c9952e;

    font-family: "Cinzel", serif;
    font-weight: 600;
}

.item-row {
    display: grid;
    grid-template-columns:
        40px
        minmax(0, 2fr)
        90px
        minmax(0, 3fr)
        50px;

    align-items: center;

    padding: 8px 10px;

    border-bottom: 1px solid #33322e;

    background-color: #0a0a0a;
}

.item-row:last-child {
    border-bottom: none;
}

/* ------------------------------
   Coluna #
   ------------------------------ */

.items-header > :nth-child(1),
.item-row > :nth-child(1) {
    min-width: 0;
}

/* ------------------------------
   Coluna Nome
   ------------------------------ */

.items-header > :nth-child(2),
.item-row > :nth-child(2) {
    min-width: 0;

    padding-left: 10px;
    padding-right: 10px;

    border-right: 1px solid #33322e;
}

/* ------------------------------
   Coluna Qtd.
   ------------------------------ */

.items-header > :nth-child(3),
.item-row > :nth-child(3) {
    min-width: 0;

    padding-left: 10px;

    border-right: 1px solid #33322e;
}

.item-field:nth-child(3) .number-input {
    width: 70px;
}

/* ------------------------------
   Coluna Descrição
   ------------------------------ */

.items-header > :nth-child(4),
.item-row > :nth-child(4) {
    min-width: 0;

    padding-left: 10px;
    padding-right: 10px;

    border-right: 1px solid #33322e;
}

/* ------------------------------
   Coluna Lixeira
   ------------------------------ */

.items-header > :nth-child(5),
.item-row > :nth-child(5) {
    min-width: 0;
}

.item-row > button {
    width: calc(100% - 8px);

    transform: translateX(8px);

    padding: 7px 0;

    font-size: 16px;
}

.item-row > button:nth-child(5) {
    padding: 9px 0 10px;

    display: grid;
    place-items: center;
}

.item-row > button:hover {
    border-color: #8b3a3a;
    background-color: #2a1717;
}

/* ------------------------------
   Campos dos itens
   ------------------------------ */

.item-field {
    display: flex;
    flex-direction: column;
    gap: 5px;

    min-width: 0;
}

.item-field input {
    width: 100%;
    min-width: 0;
}

.item-field label {
    display: none;
}

/* ==============================
   ADD ITEM
   ============================== */

#addItem {
    margin-top: 15px;
    padding: 8px 12px;
    color: #d6b56d;

    font-size: 16px;
}

/* ==============================
   SUBMIT
   ============================== */

button[type="submit"] {
    width: 100%;
    margin-top: 15px;
    padding: 12px;

    border: 1px solid #c9952e;

    background-color: #b8862c;
    color: #f5e6c8;

    font-size: 20px;
}

button[type="submit"]:hover {
    border-color: #e0caa5;
    background-color: #c9952e;
}

/* ==============================
   FOOTER
   ============================== */

footer {
    padding: 15px;

    color: #c9952e;

    font-family: "Cinzel", serif;
    font-size: 14px;

    text-align: center;
}

/* ==============================
   NUMBER INPUTS
   ============================== */

#idade,
#nivel {
    appearance: textfield;
    -moz-appearance: textfield;
}

#idade::-webkit-inner-spin-button,
#idade::-webkit-outer-spin-button,
#nivel::-webkit-inner-spin-button,
#nivel::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.attribute,
.item-field input[type="number"] {
    appearance: textfield;
    -moz-appearance: textfield;
}

.attribute::-webkit-inner-spin-button,
.attribute::-webkit-outer-spin-button,
.item-field input[type="number"]::-webkit-inner-spin-button,
.item-field input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ==============================
   CUSTOM NUMBER CONTROLS
   ============================== */

.number-input {
    display: flex;
    align-items: stretch;

    width: 100%;
}

.number-input input {
    width: 100%;
    min-width: 0;

    border-radius: 6px 0 0 6px;
    border-right: 0;
}

.number-controls {
    display: flex;
    flex-direction: column;

    width: 24px;
}

.number-controls button {
    flex: 1;

    width: 24px;
    min-height: 0;

    padding: 0;

    border-radius: 0;

    font-size: 10px;
    line-height: 1;
}

.number-controls button:first-child {
    border-radius: 0 6px 0 0;
}

.number-controls button:last-child {
    border-top: 0;
    border-radius: 0 0 6px 0;
}

.number-controls button:hover {
    border-color: #c9952e;
    background-color: #2a241e;
}

/* ==============================
   TOAST
   ============================== */

.toast {
    position: fixed;
    right: 20px;
    bottom: 20px;

    padding: 15px 20px;

    border: 1px solid #c9952e;
    border-radius: 8px;

    background-color: #1b1714;
    color: #e0caa5;

    font-family: "Cinzel", serif;
    font-weight: 600;

    opacity: 0;
    visibility: hidden;

    transition:
        opacity 0.3s ease,
        visibility 0.3s ease;
}

.toast.show {
    opacity: 1;
    visibility: visible;
}

/* ==============================
   MOBILE
   ============================== */

@media (max-width: 510px) {
    header h1 {
        font-size: 28px;
    }

    header p {
        font-size: 12px;
    }

    main {
        padding: 10px;
    }

    .character-field {
        flex: 1 1 100%;
    }

    /* No mobile, a linha de item volta
       para o comportamento vertical. */

    .item-row {
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }
    
    .item-row > * {
        flex: none;
    }

    .item-row > button {
        width: 100%;
        transform: none;
        margin-top: 10px;
    }

    .item-field >label{
        margin: 15px 0 -3px 0;
    }
    
    .item-field label {
        display: block;
        color: #d6b56d;
    }

    .items-header {
        display: none;
    }

    .attribute-row {
        position: relative;

        display: flex;
        flex-direction: column;
        align-items: stretch;
    }

    .attribute-row > :nth-child(3) {
        width: 70px;
        align-self: flex-end;
    }

    .attributes-header {
        display: none;
    }


    .toast {
        left: 10px;
        right: 10px;
        bottom: 10px;

        text-align: center;
    }
}

@media (max-width: 350px) {
    header h1 {
        font-size: 24px;
    }
}
