body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #e9ecef;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 20px;
    color: #343a40;
}

.container {
    background-color: #ffffff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 700px;
}

h1 {
    text-align: center;
    color: #007bff;
    margin-bottom: 30px;
    font-weight: 600;
}

h2 {
    color: #343a40;
    margin-top: 25px;
    margin-bottom: 15px;
    font-size: 1.3em;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
}

/* List Management Section */
.list-management-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background-color: #f0f8ff; /* Light blue background */
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.list-selector-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-grow: 1;
}

.list-selector-group label {
    font-weight: bold;
    color: #007bff;
    white-space: nowrap; /* Impede que o label quebre a linha */
}

#listSelector {
    padding: 8px 10px;
    border: 1px solid #007bff;
    border-radius: 5px;
    font-size: 16px;
    flex-grow: 1;
    min-width: 120px;
    background-color: white;
    cursor: pointer;
}

.list-action-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap; /* Para responsividade */
}

.list-action-buttons button {
    padding: 8px 12px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
    color: white;
}

#newListBtn {
    background-color: #28a745; /* Green */
}
#newListBtn:hover {
    background-color: #218838;
}

#renameListBtn {
    background-color: #ffc107; /* Yellow */
    color: #333;
}
#renameListBtn:hover {
    background-color: #e0a800;
}

#deleteListBtn {
    background-color: #dc3545; /* Red */
}
#deleteListBtn:hover {
    background-color: #c82333;
}

/* HORIZONTAL RULE */
hr {
    border: 0;
    height: 1px;
    background-image: linear-gradient(to right, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.15), rgba(0, 0, 0, 0));
    margin: 30px 0;
}

/* Frequent Items Section */
.frequent-items-section {
    background-color: #f8f9fa; /* Lighter background */
    padding: 20px;
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

.frequent-item-input {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 20px;
}

.frequent-item-input input[type="text"],
.frequent-item-input input[type="number"] {
    flex: 1;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 15px;
    min-width: 100px;
}

.frequent-item-input button {
    padding: 10px 15px;
    background-color: #6f42c1; /* Roxo para "Adicionar Frequente" */
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 15px;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

.frequent-item-input button:hover:not(:disabled) {
    background-color: #5b359f;
}
.frequent-item-input button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.7;
}

#frequentItemsList {
    list-style: none;
    padding: 0;
}

#frequentItemsList li {
    background-color: #ffffff;
    padding: 12px 15px;
    margin-bottom: 8px;
    border-radius: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}

#frequentItemsList li .item-info {
    flex-grow: 1;
}

#frequentItemsList li .item-name {
    font-weight: bold;
    color: #495057;
}

#frequentItemsList li .item-details {
    font-size: 0.9em;
    color: #6c757d;
}

#frequentItemsList li .item-actions {
    display: flex;
    gap: 5px;
}

#frequentItemsList li .item-actions button {
    padding: 6px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85em;
    color: white;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 3px;
}

#frequentItemsList li .item-actions .add-to-list-btn {
    background-color: #007bff; /* Azul para adicionar à lista */
}
#frequentItemsList li .item-actions .add-to-list-btn:hover {
    background-color: #0056b3;
}

#frequentItemsList li .item-actions .remove-frequent-btn {
    background-color: #6c757d; /* Cinza para remover do frequente */
}
#frequentItemsList li .item-actions .remove-frequent-btn:hover {
    background-color: #5a6268;
}


/* Input Section (existing styles) */
.input-section {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 25px;
    position: relative;
}

.input-section h2 span {
    color: #007bff;
    font-size: 1em;
}

.input-section input[type="text"],
.input-section input[type="number"] {
    flex: 1;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 16px;
    min-width: 120px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-section input[type="text"]:focus,
.input-section input[type="number"]:focus,
.frequent-item-input input[type="text"]:focus,
.frequent-item-input input[type="number"]:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

.input-section button {
    padding: 12px 20px;
    background-color: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    transition: background-color 0.2s ease, opacity 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.input-section button:hover:not(:disabled) {
    background-color: #218838;
}

.input-section button:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.7;
}

.error-message {
    color: #dc3545;
    font-size: 0.85em;
    width: 100%; /* Ocupa a largura total para aparecer abaixo do input */
    margin-top: -8px; /* Ajusta a posição para mais perto do input */
    margin-bottom: 5px;
    height: 1.2em; /* Garante que a altura seja consistente, mesmo quando vazia */
}

/* Filter and Sort Section (existing styles) */
.filter-sort-section {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

#filterInput {
    flex: 2;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    font-size: 16px;
    min-width: 150px;
}

.sort-options {
    flex: 3;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 15px;
    color: #555;
    flex-wrap: wrap; /* Para responsividade */
}

.sort-options button {
    padding: 8px 12px;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.sort-options button:hover {
    background-color: #0056b3;
}

.sort-options button.active-sort {
    background-color: #0056b3;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* List Actions (adjusted to remove "Limpar Toda a Lista" button as it's now covered by "Excluir Lista") */
.list-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap; /* Para responsividade */
}

.clear-list-btn {
    padding: 10px 15px;
    background-color: #dc3545; /* Red para limpar itens da lista atual */
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 15px;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 5px;
}

.clear-list-btn:hover {
    background-color: #c82333;
}

#clearCompletedBtn {
    background-color: #ffc107; /* Yellow para limpar comprados */
    color: #333;
}

#clearCompletedBtn:hover {
    background-color: #e0a800;
}


.list-section ul {
    list-style: none;
    padding: 0;
}

.list-section li {
    background-color: #fefefe;
    padding: 15px;
    margin-bottom: 12px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    transition: transform 0.1s ease-in-out, background-color 0.2s ease;
}

.list-section li:hover {
    transform: translateY(-2px);
}

.item-content {
    display: flex;
    align-items: center;
    flex-grow: 1;
    gap: 15px;
}

.item-content input[type="checkbox"] {
    transform: scale(1.4);
    cursor: pointer;
    margin-right: 5px;
}

.item-details {
    flex-grow: 1;
}

.item-details strong {
    font-size: 1.15em;
    color: #343a40;
    display: block;
    margin-bottom: 2px;
}

.item-details p {
    margin: 0;
    color: #6c757d;
    font-size: 0.95em;
}

.item-details .item-total-price {
    font-weight: bold;
    color: #007bff;
    font-size: 1em;
}

.item-completed {
    background-color: #e2f2e5;
    opacity: 0.8;
    text-decoration: line-through;
}

.item-completed .item-details strong,
.item-completed .item-details p,
.item-completed .item-completed .item-total-price {
    color: #888;
}

.item-actions {
    display: flex;
    gap: 8px;
}

.list-section button {
    background-color: #6c757d;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background-color 0.2s ease;
    display: flex; /* Para ícones */
    align-items: center;
    gap: 5px;
}

.list-section button.edit-btn {
    background-color: #17a2b8;
}

.list-section button.edit-btn:hover {
    background-color: #138496;
}

.list-section button.remove-btn {
    background-color: #dc3545;
}

.list-section button.remove-btn:hover {
    background-color: #c82333;
}

.total-section {
    text-align: right;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e9ecef;
}

.total-section p {
    font-size: 1.5em;
    font-weight: bold;
    color: #343a40;
}

#totalValue {
    color: #28a745;
}

/* Responsividade */
@media (max-width: 600px) {
    .list-management-section,
    .frequent-item-input,
    .input-section,
    .filter-sort-section,
    .list-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .list-selector-group {
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
    }
    .list-selector-group label {
        margin-bottom: 5px;
    }
    #listSelector {
        width: 100%;
    }

    .list-action-buttons {
        width: 100%;
        justify-content: space-between;
    }
    .list-action-buttons button {
        flex: 1;
        margin-bottom: 5px;
    }

    .frequent-item-input input,
    .frequent-item-input button {
        width: 100%;
        min-width: unset;
        margin-bottom: 5px;
    }

    .input-section input,
    .input-section button,
    #filterInput,
    .sort-options button,
    .list-actions button {
        width: 100%;
        min-width: unset;
        margin-bottom: 10px;
    }

    .sort-options {
        flex-direction: column;
        align-items: flex-start;
    }

    .list-section li,
    #frequentItemsList li {
        flex-direction: column;
        align-items: flex-start;
    }

    .item-content,
    #frequentItemsList li .item-info {
        width: 100%;
        margin-bottom: 10px;
    }

    .item-actions,
    #frequentItemsList li .item-actions {
        width: 100%;
        justify-content: flex-end;
    }
}