/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --green: #2e7d32;
    --green-light: #4caf50;
    --green-bg: #e8f5e9;
    --red: #c62828;
    --red-light: #ffebee;
    --grey-50: #fafafa;
    --grey-100: #f5f5f5;
    --grey-200: #eeeeee;
    --grey-400: #bdbdbd;
    --grey-500: #9e9e9e;
    --grey-700: #616161;
    --grey-900: #212121;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --radius: 12px;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--grey-100);
    color: var(--grey-900);
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
}

/* === Login === */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 1.5rem;
    background: linear-gradient(135deg, var(--green) 0%, #1b5e20 100%);
}

.login-card {
    background: white;
    border-radius: 1rem;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 380px;
    box-shadow: var(--shadow-md);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.5rem;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--grey-900);
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--grey-700);
    margin-bottom: 0.4rem;
}

.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%;
    padding: 0.85rem 1rem;
    border: 2px solid var(--grey-200);
    border-radius: 0.6rem;
    font-size: 1rem;
    transition: border-color 0.2s;
    outline: none;
}

.form-group input:focus {
    border-color: var(--green-light);
}

.remember {
    margin-bottom: 1.5rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--grey-700);
}

.checkbox-label input[type="checkbox"] {
    width: 1.2rem;
    height: 1.2rem;
    accent-color: var(--green);
}

.flash {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.flash.error {
    background: var(--red-light);
    color: var(--red);
}

/* === Buttons === */
.btn {
    border: none;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.6rem;
    transition: background 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--green);
    color: white;
    padding: 0.85rem 1.5rem;
}

.btn-primary:hover {
    background: #256b29;
}

.btn-full {
    width: 100%;
}

/* === App Layout === */
.app-container {
    max-width: 600px;
    margin: 0 auto;
    padding-bottom: 2rem;
}

.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: var(--green);
    color: white;
    position: sticky;
    top: 0;
    z-index: 100;
}

.app-header h1 {
    font-size: 1.25rem;
    font-weight: 700;
}

.btn-logout {
    background: none;
    border: none;
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 0.4rem;
    transition: background 0.2s;
    display: flex;
    align-items: center;
}

.btn-logout:hover {
    background: rgba(255,255,255,0.15);
    color: white;
}

/* === Add Form === */
.add-form {
    padding: 1rem 1.25rem;
    background: white;
    border-bottom: 1px solid var(--grey-200);
    position: sticky;
    top: 56px;
    z-index: 90;
}

.add-inputs {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

.input-wrapper input,
.qty-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--grey-200);
    border-radius: 0.6rem;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.input-wrapper input:focus,
.qty-input:focus {
    border-color: var(--green-light);
}

.qty-input {
    width: 5rem;
    flex-shrink: 0;
    text-align: center;
}

.btn-add {
    background: var(--green);
    color: white;
    border: none;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.1s;
    box-shadow: var(--shadow-sm);
}

.btn-add:hover {
    background: #256b29;
}

.btn-add:active {
    transform: scale(0.93);
}

/* === Autocomplete === */
.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 2px solid var(--grey-200);
    border-top: none;
    border-radius: 0 0 0.6rem 0.6rem;
    max-height: 200px;
    overflow-y: auto;
    z-index: 200;
    display: none;
    box-shadow: var(--shadow-md);
}

.suggestions.visible {
    display: block;
}

.suggestion-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background 0.15s;
    text-transform: capitalize;
}

.suggestion-item:hover,
.suggestion-item:active {
    background: var(--green-bg);
}

/* === Items === */
.items-section {
    padding: 0.75rem 1.25rem 0;
}

.item-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: white;
    padding: 0.9rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    box-shadow: var(--shadow-sm);
    transition: opacity 0.3s, transform 0.2s;
}

.item-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
    flex: 1;
}

.item-name {
    font-size: 1.05rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.item-qty {
    font-size: 0.8rem;
    color: var(--grey-500);
    font-weight: 500;
}

.item-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.2s, transform 0.1s;
}

.btn-icon:active {
    transform: scale(0.9);
}

.btn-check {
    color: var(--green);
}

.btn-check:hover {
    background: var(--green-bg);
}

.btn-delete {
    color: var(--grey-400);
}

.btn-delete:hover {
    color: var(--red);
    background: var(--red-light);
}

.btn-undo {
    color: var(--grey-500);
}

.btn-undo:hover {
    color: var(--green);
    background: var(--green-bg);
}

/* === Bought Section === */
.bought-section {
    padding: 0.5rem 1.25rem 0;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--grey-500);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.75rem 0 0.5rem;
}

.item-card.bought {
    opacity: 0.55;
}

.item-card.bought .item-name {
    text-decoration: line-through;
    color: var(--grey-500);
}

.item-time {
    font-size: 0.75rem;
    color: var(--grey-400);
}

/* === Empty State === */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--grey-500);
}

.empty-icon {
    font-size: 3rem;
    display: block;
    margin-bottom: 0.75rem;
}

.empty-state p {
    font-size: 1rem;
}

/* === Responsive fine-tuning === */
@media (min-width: 600px) {
    .login-card {
        padding: 3rem 2.5rem;
    }

    .app-header {
        border-radius: 0 0 var(--radius) var(--radius);
    }

    .app-container {
        padding-top: 1rem;
    }
}
