/* Reset & Base Styles */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f4f9;
    color: #333;
    padding-bottom: 50px;
}
main { max-width: 600px; margin: 0 auto; padding: 15px; }

/* Header */
header {
    background: #007bff;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.logout-link { color: white; text-decoration: underline; font-size: 0.9rem; }

/* Forms & Buttons */
#add-form { display: flex; gap: 10px; margin-bottom: 20px; align-items: stretch; }
.input-group { display: flex; flex-direction: column; gap: 6px; flex-grow: 1; }
.input-group input { padding: 12px; border: 1px solid #ccc; border-radius: 6px; font-size: 1rem; }
.input-group input#new-item-detail { font-size: 0.85rem; padding: 8px 12px; } /* Smaller detail box */

.btn-primary { background: #28a745; color: white; border: none; padding: 0 20px; border-radius: 6px; font-size: 1rem; cursor: pointer;}
.btn-black { background: #000; color: white; border: none; padding: 15px; border-radius: 6px; font-size: 1.1rem; width: 100%; cursor: pointer; margin-top: 20px; }

/* History Header */
.history-header { background: #e2e3e5; color: #383d41; padding: 12px; border-radius: 6px; margin-top: 15px; margin-bottom: 15px; font-weight: bold; text-align: center; }
#btn-back { width: 100%; padding: 12px; background: #6c757d; }

/* Grocery List */
ul { list-style: none; }
.grocery-item {
    display: flex;
    align-items: center;
    background: white;
    margin-bottom: 2px;
    padding: 3px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Drag Handle */
.drag-handle {
    font-size: 1.5rem;
    color: #aaa;
    padding: 0 15px 0 5px;
    cursor: grab;
    user-select: none;
}
.drag-handle:active { cursor: grabbing; }

/* Qty Controls (Mobile touch friendly) */
.qty-controls { display: flex; align-items: center; margin-right: 15px; }
.btn-minus, .btn-plus {
    width: 36px; height: 36px; font-size: 1.2rem; font-weight: bold;
    background: #e9ecef; border: 1px solid #ced4da; border-radius: 4px;
    cursor: pointer; color: #495057;
}
.btn-minus:active, .btn-plus:active { background: #d3d9df; }
.qty-input {
    width: 45px; height: 36px; text-align: center; font-size: 1.1rem;
    border: 1px solid #ced4da; border-left: none; border-right: none; border-radius: 0;
    -moz-appearance: textfield; 
}
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; } 

/* Read-Only History Qty Box */
.history-qty { width: 30px; font-weight: bold; font-size: 1.2rem; margin-right: 15px; text-align: center; color: #007bff; }

/* Item Text Details */
.item-name-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    word-break: break-word;
}
.item-name { font-size: 1.1rem; }
.item-detail { font-size: 0.85rem; color: #6c757d; margin-top: 2px; }

/* Login Container */
.login-container { max-width: 350px; margin: 100px auto; background: white; padding: 30px; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); }
.login-container h2 { margin-bottom: 20px; text-align: center; }
.login-container input { width: 100%; margin-bottom: 15px; padding: 12px; border: 1px solid #ccc; border-radius: 4px;}
.login-container button { width: 100%; padding: 12px; }

/* Clickable Logs Section */
.logs-section { margin-top: 40px; border-top: 2px solid #ddd; padding-top: 20px; }
.logs-section h3 { margin-bottom: 15px; color: #555; }
#logs-list li {
    font-size: 0.95rem;
    color: #007bff;
    margin-bottom: 8px;
    padding: 10px;
    background: #fff;
    border-radius: 4px;
    border-left: 4px solid #007bff;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    transition: background 0.2s ease;
}
#logs-list li:hover { background: #e9ecef; }
/* Delete / Trash Button */
.btn-delete {
    background: transparent;
    border: none;
    color: #dc3545; /* Red */
    font-size: 1.3rem;
    cursor: pointer;
    padding: 5px 5px 5px 15px;
    margin-left: auto;
    opacity: 0.5;
    transition: opacity 0.2s ease;
    display: flex;
    align-items: center;
}
.btn-delete:hover, .btn-delete:active {
    opacity: 1;
}