/*(animations)*/
.fade-in {
    opacity: 0;
    animation: fadeIn 0.5s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateX(0); }
    to { opacity: 0; transform: translateX(50px); }
}

/*(struck-through animation)*/
.struck-animate {
    animation: strikeFade 0.7s ease;
}

@keyframes strikeFade {
    0% { opacity: 1; transform: scale(1) rotate(0deg); background: #fffbe6; }
    40% { opacity: 0.7; transform: scale(1.05) rotate(-2deg); background: #fffbe6; }
    100% { opacity: 0.5; transform: scale(1) rotate(0deg); background: transparent; }
}

/*(base layout)*/
html, body {
    background: #f8f9fa;
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    min-height: 100vh;
    width: 100%;
    text-align: center; /*(center all text except list items)*/
}

#pantryPlanner {
    color: #343a40;
    margin-top: 20px;
    font-size: 2.5em;
    letter-spacing: 1.5px;
    font-weight: bold;
}

/*(main container)*/
.container {
    max-width: 400px;
    margin: 40px auto;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    padding: 32px 20px 24px 20px;
}

/*(section titles)*/
.section-title {
    margin: 0 0 12px 0;
    font-size: 1.2em;
    color: #343a40;
}

/*(input row)*/
#inputRow {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    justify-content: center;
}

#itemInput {
    flex: 1;
    padding: 14px;
    border: 1px solid #bbb;
    border-radius: 6px;
    font-size: 1.1em;
    text-align: center; /*(center placeholder + typed text)*/
}

#itemInput:focus {
    border-color: #007bff;
    outline: none;
}

#button {
    background: #007bff;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 14px 18px;
    font-size: 1.1em;
    cursor: pointer;
}

#button:hover {
    background: #0056b3;
}

/*(main list)*/
#groceries {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left; /*(keep list items readable)*/
}

#groceries li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid #eee;
    font-size: 1.1em;
}

/*(buttons)*/
#undo-btn {
    background: #ffc107;
    color: #222;
    border: none;
    border-radius: 24px;
    padding: 12px 22px;
    font-size: 1.1em;
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 0 auto 18px auto;
}

#undo-btn:hover {
    background: #e0a800;
}

#deletemainlist,
#del-all-btn {
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 24px;
    padding: 12px 22px;
    font-size: 1.1em;
    display: block;
    width: 100%;
    max-width: 300px;
    margin: 18px auto 0 auto;
}

#deletemainlist:hover,
#del-all-btn:hover {
    background: #b52a37;
}

/*(delete button inside list)*/
.delete-btn {
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    cursor: pointer;
}

.delete-btn:hover {
    background: #b52a37;
}

/*(edit button)*/
.edit-btn {
    background: transparent;
    border: none;
    padding: 6px;
    margin-left: 8px;
    cursor: pointer;
    color: #007bff;
}

.edit-btn:hover {
    background: rgba(0,0,0,0.04);
}

.edit-icon {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

/*(inline edit input)*/
.edit-input {
    flex: 1;
    padding: 10px 12px;
    font-size: 1.05em;
    border: 1px solid #ccc;
    border-radius: 6px;
    text-align: center;
}

.edit-input:focus {
    border-color: #007bff;
    outline: none;
}

/*(struck list container)*/
#struckListContainer {
    background: #fff;
    border-radius: 10px;
    padding: 16px 20px 12px 20px;
    max-width: 400px;
    margin: 20px auto;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
}

#struckList {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left; /*(keep acquired items readable)*/
}

/*(dark mode — improved contrast but same palette)*/
body.dark-mode {
    background: #181a1b;
    color: #f1f3f4;
}

body.dark-mode .container,
body.dark-mode #struckListContainer {
    background: #23272a;
    color: #f1f3f4;
    box-shadow: 0 2px 12px rgba(0,0,0,0.25);
}

body.dark-mode #pantryPlanner,
body.dark-mode .section-title {
    color: #f1f3f4;
}

body.dark-mode #itemInput {
    background: #2b2f31;
    color: #f1f3f4;
    border-color: #555;
}

body.dark-mode #itemInput:focus {
    border-color: #66aaff;
}

body.dark-mode #button {
    background: #66aaff;
    color: #181a1b;
}

body.dark-mode #button:hover {
    background: #3388cc;
}

body.dark-mode #groceries li {
    border-bottom: 1px solid #333;
    color: #f1f3f4;
}

body.dark-mode .delete-btn {
    background: #b52a37;
}

body.dark-mode .delete-btn:hover {
    background: #dc3545;
}

body.dark-mode .edit-btn {
    color: #66aaff;
}

body.dark-mode .edit-input {
    background: #2b2f31;
    color: #f1f3f4;
    border-color: #555;
}

body.dark-mode #undo-btn {
    background: #e0a800;
    color: #222;
}

body.dark-mode #undo-btn:hover {
    background: #cc9901;
}

body.dark-mode #deletemainlist,
body.dark-mode #del-all-btn {
    background: #b52a37;
}

body.dark-mode #deletemainlist:hover,
body.dark-mode #del-all-btn:hover {
    background: #dc3545;
}

/*(dark mode toggle)*/
#darkModeToggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #eee;
    color: #222;
    border: none;
    border-radius: 24px;
    padding: 12px 22px;
    cursor: pointer;
}

body.dark-mode #darkModeToggle {
    background: #23272a;
    color: #f1f3f4;
    border: 1px solid #444;
}

/*(responsive)*/
@media (max-width: 500px) {
    .container {
        margin: 0;
        min-height: 100vh;
        border-radius: 0;
        box-shadow: none;
    }

    #inputRow {
        flex-direction: column;
    }

    #darkModeToggle {
        bottom: 12px;
        right: 12px;
    }
}
