* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f4f9;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    padding: 15px;
}

header {
    background: #4CAF50;
    color: #fff;
    padding: 0.75rem 0;
    text-align: center;
    margin-bottom: 1rem;
    border-radius: 5px;
}

header h1 {
    font-size: 1.5rem;
}

#form-toggle-header {
    background: #fff;
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 0; /* Remove margin when expanded */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: margin-bottom 0.4s ease;
}

#form-toggle-header.collapsed {
    margin-bottom: 1rem; /* Add margin when form is collapsed */
}

#form-toggle-header h2 {
    font-size: 1.1rem;
    font-weight: 500;
}

#add-item-form {
    background: #fff;
    padding: 15px;
    border-radius: 0 0 5px 5px; /* Round bottom corners */
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    overflow: hidden;
    max-height: 500px; /* Arbitrary large height for transition */
    transition: max-height 0.4s ease-in-out, padding 0.4s ease-in-out;
    border-top: 1px solid #f0f0f0;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

#add-item-form.collapsed {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-top: none;
}

#form-chevron {
    border: solid #555;
    border-width: 0 2px 2px 0;
    display: inline-block;
    padding: 3px;
    transform: rotate(45deg); /* Down arrow */
    transition: transform 0.4s ease-in-out;
}

#form-chevron.collapsed {
    transform: rotate(-135deg); /* Up arrow */
}



.form-grid input {
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
    width: 100%;
}

.grid-span-2 { grid-column: span 2; }

.photo-section {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.photo-section label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modal-action-btn {
    height: 35px;
    padding: 0 12px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.9rem;
    box-sizing: border-box;
    transition: background-color 0.2s;
    text-align: center;
    line-height: 33px; /* Set line-height to height minus borders (35px - 2px) */
}

.file-upload-label {
    background-color: #f0f0f0;
    border: 1px solid #ddd;
    color: #555;
}

.file-upload-label:hover {
    background-color: #e9e9e9;
}

.camera-toggle-container {
    display: flex;
    align-items: center;
    gap: 8px;
}

.camera-label {
    font-size: 0.9rem;
    color: #555;
}

/* The switch - a box around the slider */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

/* Hide default HTML checkbox */
.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

/* The slider */
.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 28px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: #4CAF50;
}

input:checked + .slider:before {
    transform: translateX(22px);
}

/* Hide number input arrows */
input[type=number]::-webkit-inner-spin-button, 
input[type=number]::-webkit-outer-spin-button { 
  -webkit-appearance: none; 
  margin: 0; 
}

input[type=number] { -moz-appearance: textfield; }

#add-item-form button {
    width: 100%;
    padding: 12px;
    border: none;
    background: #4CAF50;
    color: white;
    cursor: pointer;
    border-radius: 5px;
    font-size: 1rem;
}

#refresh-container {
    margin-bottom: 1rem;
}

#refresh-button {
    width: 100%;
    padding: 12px;
    border: 1px solid #ff9800;
    background: #fffbe6;
    color: #ff9800;
    cursor: pointer;
    border-radius: 5px;
    font-size: 1rem;
    font-weight: 500;
}
#shopping-list {
    list-style: none;
}

#shopping-list li {
    background: #fff;
    padding: 15px;
    margin-bottom: 8px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    transition: opacity 0.3s ease;
    display: flex;
    flex-direction: column;
}

#shopping-list li.purchased {
    opacity: 0.6;
}

#shopping-list li.purchased .item-text {
    text-decoration: line-through;
    color: #888;
}

.item-row {
    display: flex;
    align-items: center;
    width: 100%;
}

.item-row-1 {
    gap: 15px;
    margin-bottom: 10px;
}

.item-name-text {
    font-weight: 500;
    font-size: 1.1rem;
}

.item-row-2 {
    justify-content: space-between;
}

.item-meta {
    display: flex;
    align-items: center;
    gap: 15px;
}

.item-image, .item-image-placeholder {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 5px;
    background-color: #f0f0f0;
    flex-shrink: 0;
}

.item-quantity {
    font-weight: normal;
    color: #555;
}

.item-price {
    font-size: 0.9rem;
    color: #333;
    background-color: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
}

.item-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.item-row-3 {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
}

.item-description {
    font-size: 0.9rem;
    color: #777;
    line-height: 1.4;
}

.status-checkbox {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    cursor: pointer;
}

.delete-btn {
    background: #f44336;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Modal / Lightbox Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    padding-top: 60px;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.9);
}

.modal-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
}

#modal-caption {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
    text-align: center;
    color: #ccc;
    padding: 10px 0;
    height: 150px;
}

.modal-close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1;
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

.favorite-btn {
    font-size: 22px;
    cursor: pointer;
    color: #ccc;
    transition: color 0.2s ease-in-out;
    line-height: 1; /* Helps with vertical alignment */
}

.favorite-btn.is-favorite {
    color: #ffc107; /* A nice gold/yellow color */
}

.edit-btn {
    background: transparent;
    color: #2196F3; /* Blue */
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Edit Modal Styles */
.modal-form-container {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 90%;
    max-width: 500px;
    border-radius: 5px;
    position: relative;
}

.modal-form-container h2 {
    margin-top: 0;
    margin-bottom: 15px;
}

#edit-item-form label {
    display: block;
    margin-top: 10px;
    margin-bottom: 5px;
    font-weight: 500;
}

#edit-item-form input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 1rem;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.modal-buttons button {
    padding: 10px 15px;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    font-size: 1rem;
}

#edit-modal-save-btn {
    background-color: #4CAF50; /* Green */
    color: white;
}

#edit-modal-cancel-btn {
    background-color: #f0f0f0;
}

#edit-modal-delete-btn {
    margin-right: auto; /* Pushes this button to the far left */
    background-color: #f44336; /* Red */
    color: white;
}

#edit-photo-container {
    margin-top: 5px;
}

#edit-item-photo-preview {
    max-width: 100px;
    max-height: 100px;
    border-radius: 5px;
    object-fit: cover;
    margin-bottom: 10px;
    border: 1px solid #ddd;
}

.edit-photo-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

#edit-modal-remove-photo-btn {
    background-color: #f44336;
    border: 1px solid #f44336;
    color: white;
}