/* Configurações gerais */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    background-color: #f5f7f5;
    color: #26332b;
}

/* Cabeçalho */
header {
    background-color: #287a55;
    color: white;
    text-align: center;
    padding: 30px 20px;
}

header h1 {
    font-size: 26px;
    margin-bottom: 8px;
}

header p {
    font-size: 14px;
}

/* Conteúdo principal */
main {
    max-width: 650px;
    margin: 25px auto;
    padding: 0 16px;
}

/* Abas de navegação */
nav {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 6px;
    margin-bottom: 25px;
}

nav button {
    background-color: white;
    border: 1px solid #d6dfd8;
    border-radius: 8px;
    padding: 12px 4px;
    cursor: pointer;
    font-size: 13px;
    color: #287a55;
}

nav button:hover {
    background-color: #e0f0e6;
}

/* Área de produtos */
section {
    background-color: white;
    border-radius: 12px;
    padding: 20px;
    min-height: 200px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

section h2 {
    font-size: 20px;
    margin-bottom: 20px;
}

#lista-produtos {
    list-style: none;
}

/* Botão adicionar */
#adicionar-produto {
    display: block;
    width: 100%;
    margin-top: 20px;
    padding: 15px;
    background-color: #287a55;
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
}

#adicionar-produto:hover {
    background-color: #1e6042;
}

/* Ajustes para celulares */
@media (max-width: 480px) {
    header h1 {
        font-size: 23px;
    }

    nav button {
        font-size: 11px;
        padding: 12px 2px;
    }

    section {
        padding: 15px;
    }
}

/* Destaque da aba selecionada */
nav button.ativo {
    background-color: #287a55;
    color: white;
    border-color: #287a55;
    font-weight: bold;
}

nav button.ativo:hover {
    background-color: #1e6042;
}

#reiniciar-compras {
    display: block;
    width: 100%;
    margin-top: 15px;
    padding: 13px;
    background-color: white;
    color: #287a55;
    border: 1px solid #287a55;
    border-radius: 10px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

#reiniciar-compras:hover {
    background-color: #e0f0e6;
}

#reiniciar-compras[hidden] {
    display: none;
}

#resumo-compras {
    font-size: 14px;
    color: #66756b;
    margin-top: -10px;
    margin-bottom: 15px;
}

#buscar-produto {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 18px;
    border: 1px solid #d6dfd8;
    border-radius: 8px;
    font-size: 15px;
    color: #26332b;
    background-color: #ffffff;
    outline: none;
}

#buscar-produto:focus {
    border-color: #287a55;
    box-shadow: 0 0 0 2px rgba(40, 122, 85, 0.12);
}

#buscar-produto::placeholder {
    color: #8a958d;
}

#progresso-compras {
    display: block;
    width: 100%;
    height: 10px;
    margin-bottom: 18px;
    border: none;
    border-radius: 10px;
    overflow: hidden;
    accent-color: #287a55;
}

#progresso-compras::-webkit-progress-bar {
    background-color: #e0e8e2;
    border-radius: 10px;
}

#progresso-compras::-webkit-progress-value {
    background-color: #287a55;
    border-radius: 10px;
}

#progresso-compras::-moz-progress-bar {
    background-color: #287a55;
    border-radius: 10px;
}

/* Formulário de cadastro de produtos */

#formulario-produto {
    background-color: white;
    padding: 20px;
    margin-top: 15px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#formulario-produto[hidden] {
    display: none;
}

#formulario-produto h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #26332b;
}

#formulario-produto label {
    display: block;
    font-size: 14px;
    font-weight: bold;
    margin-bottom: 6px;
}

#formulario-produto input,
#formulario-produto select {
    display: block;
    width: 100%;
    padding: 12px;
    margin-bottom: 18px;
    border: 1px solid #d6dfd8;
    border-radius: 8px;
    font-size: 15px;
    background-color: white;
    color: #26332b;
}

#formulario-produto input:focus,
#formulario-produto select:focus {
    outline: none;
    border-color: #287a55;
    box-shadow: 0 0 0 2px rgba(40, 122, 85, 0.12);
}

.acoes-formulario {
    display: flex;
    gap: 10px;
}

.acoes-formulario button {
    flex: 1;
    padding: 13px 8px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: bold;
    cursor: pointer;
}

#cancelar-cadastro {
    background-color: white;
    color: #287a55;
    border: 1px solid #287a55;
}

#salvar-produto {
    background-color: #287a55;
    color: white;
    border: 1px solid #287a55;
}

#cancelar-cadastro:hover {
    background-color: #e0f0e6;
}

#salvar-produto:hover {
    background-color: #1e6042;
}

/* Modal de cadastro */

#modal-produto {
    width: min(440px, calc(100% - 32px));
    margin: auto;
    max-height: calc(100dvh - 32px);
    padding: 0;
    border: none;
    border-radius: 12px;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

#modal-produto::backdrop {
    background-color: rgba(0, 0, 0, 0.55);
}

#modal-produto #formulario-produto {
    margin: 0;
    box-shadow: none;
}

/* Identificação da periodicidade */

.categoria-produto {
    display: block;
    width: fit-content;
    margin-top: 5px;
    padding: 3px 8px;
    border-radius: 5px;
    background-color: #e0f0e6;
    color: #287a55;
    font-size: 11px;
    font-weight: bold;
    text-decoration: none;
}

/* Organização dos produtos em colunas */

.cabecalho-produtos,
.linha-produto {
    display: grid;
    grid-template-columns: 22px minmax(0, 1fr) 40px 48px 104px;
    align-items: center;
    gap: 8px;
}

.cabecalho-produtos {
    padding: 12px 8px;
    background-color: #e0f0e6;
    border-radius: 8px 8px 0 0;
    color: #287a55;
    font-size: 12px;
    font-weight: bold;
}

.linha-produto {
    padding: 12px 8px;
    border-bottom: 1px solid #eeeeee;
    font-size: 14px;
}

.nome-produto {
    min-width: 0;
    overflow-wrap: anywhere;
}

.quantidade-item,
.unidade-item {
    text-align: center;
    font-size: 13px;
}

.acoes-produto {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 2px;
}

/* Organização em telas pequenas */

@media (max-width: 480px) {

    .cabecalho-produtos,
    .linha-produto {
        grid-template-columns: 20px minmax(0, 1fr) 36px 52px;
        gap: 6px;
    }

    .cabecalho-produtos span:last-child {
        display: none;
    }

    .acoes-produto {
        grid-column: 2 / -1;
        justify-self: end;
    }

    .linha-produto {
        padding: 12px 4px;
    }
}

/* Centralização das colunas da tabela */

.cabecalho-produtos span:nth-child(3),
.cabecalho-produtos span:nth-child(4),
.cabecalho-produtos span:nth-child(5) {
    text-align: center;
}

.acoes-produto {
    justify-content: center;
}

.quantidade-item,
.unidade-item {
    text-align: center;
}

/* Identidade visual do aplicativo */

.identidade-app {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 15px;
}

.logo-app {
    width: 68px;
    height: 68px;
    flex-shrink: 0;
    object-fit: contain;
    border-radius: 16px;
}

.textos-app {
    text-align: left;
}

.textos-app h1 {
    margin-bottom: 6px;
}

@media (max-width: 480px) {
    .identidade-app {
        gap: 10px;
    }

    .logo-app {
        width: 55px;
        height: 55px;
        border-radius: 13px;
    }

    .textos-app h1 {
        font-size: 21px;
    }

    .textos-app p {
        font-size: 11px;
    }
}