:root {
    --bg-color: #0f172a;
    --surface-color: #1e293b;
    --surface-hover: #334155;
    --primary-color: #38bdf8;
    --primary-gradient: linear-gradient(135deg, #38bdf8 0%, #818cf8 100%);
    --success-color: #22c55e;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --danger: #ef4444;
    --border-radius: 16px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    font-family: var(--font-family);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 20px;
}

.app-container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 4px;
}

h1 {
    font-size: 1.75rem;
    font-weight: 800;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.03em;
}

.icon-btn {
    color: var(--text-muted);
    cursor: pointer;
    padding: 10px;
    border-radius: 50%;
    transition: all 0.2s ease;
    display: flex;
    /* Fix icon alignment */
}

.icon-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.input-area {
    display: flex;
    gap: 12px;
    position: relative;
    z-index: 10;
}

.input-wrapper {
    flex: 1;
    position: relative;
    background-color: var(--surface-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-main);
    padding: 16px 20px;
    font-size: 1rem;
    font-family: inherit;
    outline: none;
}

input::placeholder {
    color: var(--text-muted);
}

/* Autocomplete Suggestions */
.suggestions-box {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background-color: var(--surface-hover);
    border-radius: 12px;
    margin-top: 8px;
    overflow: hidden;
    display: none;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 20;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.95rem;
    transition: background 0.2s;
}

.suggestion-item:last-child {
    border-bottom: none;
}

.suggestion-item:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.suggestion-item strong {
    color: var(--primary-color);
}

#add-btn {
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--border-radius);
    width: 56px;
    height: 56px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    transition: transform 0.1s, box-shadow 0.2s;
    flex-shrink: 0;
}

#add-btn:active {
    transform: scale(0.95);
}

/* Lists */
.lists-wrapper {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    /* Reduced gap since headers take space */
}

.category-header {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--primary-color);
    font-weight: 700;
    letter-spacing: 0.05em;
    margin-top: 12px;
    margin-bottom: 4px;
    padding-left: 4px;
    opacity: 0.9;
}

.category-header:first-child {
    margin-top: 0;
}

.list-item {
    background-color: var(--surface-color);
    padding: 14px 16px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    animation: slideIn 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: transform 0.2s, background-color 0.2s;
}

.active-item:hover {
    transform: translateY(-2px);
    background-color: var(--surface-hover);
    box-shadow: var(--shadow-md);
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.item-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    overflow: hidden;
    cursor: pointer;
    /* For restoring history items */
}

.item-icon {
    font-size: 1.5rem;
    line-height: 1;
}

.item-icon.faded {
    opacity: 0.5;
    filter: grayscale(1);
}

.item-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
}

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

.item-name.faded {
    color: var(--text-muted);
}

.text-strikethrough {
    text-decoration: line-through;
    text-decoration-color: rgba(255, 255, 255, 0.3);
}

.item-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.qty-controls {
    display: flex;
    align-items: center;
    background-color: rgba(0, 0, 0, 0.3);
    border-radius: 10px;
    padding: 4px;
}

.qty-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.2s;
}

.qty-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.qty-val {
    font-variant-numeric: tabular-nums;
    min-width: 28px;
    text-align: center;
    font-weight: 600;
    font-size: 0.95rem;
}

.action-btn {
    background: none;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    padding: 8px;
    transition: all 0.2s;
}

.check-btn {
    color: var(--success-color);
    background-color: rgba(34, 197, 94, 0.1);
}

.check-btn:hover {
    background-color: var(--success-color);
    color: #fff;
}

.delete-btn-small {
    color: var(--text-muted);
    padding: 6px;
}

.delete-btn-small:hover {
    color: var(--danger);
    background-color: rgba(239, 68, 68, 0.1);
}

/* History Section */
.history-section {
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 20px;
}

.section-title {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 16px;
    font-weight: 600;
}

.history-item {
    opacity: 0.8;
    background-color: rgba(30, 41, 59, 0.5);
    /* lighter opacity */
    box-shadow: none;
    padding: 12px 16px;
}

.history-item:hover {
    opacity: 1;
    background-color: var(--surface-color);
}

.empty-state {
    text-align: center;
    padding: 50px 20px;
    color: var(--text-muted);
    display: none;
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state p {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-main);
}

.empty-state small {
    display: block;
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Helper for mobile responsiveness */
@media (max-width: 480px) {
    .app-container {
        padding-bottom: 80px;
    }

    .item-controls {
        gap: 8px;
    }

    .qty-controls {
        padding: 2px;
    }

    .qty-btn {
        width: 24px;
        height: 24px;
    }

    .qty-val {
        min-width: 20px;
        font-size: 0.85rem;
    }
}

.header-controls {
    display: flex;
    gap: 8px;
}

/* Print Styles for clean PDF export */
@media print {
    body {
        background-color: white !important;
        color: black !important;
        padding: 0;
    }

    .app-container {
        max-width: 100%;
        padding: 20px;
        width: 100%;
        gap: 12px;
    }

    /* Hide UI elements */
    .input-area,
    #clear-all,
    #export-btn,
    .qty-controls button,
    .action-btn,
    .history-section,
    .empty-state,
    #suggestions-box,
    .item-controls button {
        display: none !important;
    }

    /* Header adjustments */
    header {
        justify-content: center;
        margin-bottom: 20px;
        border-bottom: 2px solid black;
        padding-bottom: 10px;
    }

    h1 {
        background: none !important;
        -webkit-text-fill-color: black !important;
        color: black !important;
        font-size: 24pt;
    }

    /* List Layout */
    ul {
        gap: 0;
    }

    .category-header {
        color: black !important;
        font-size: 14pt;
        border-bottom: 1px solid #ccc;
        margin-top: 20px;
        margin-bottom: 10px;
        font-weight: bold;
    }

    .list-item {
        background-color: transparent !important;
        box-shadow: none !important;
        border: none !important;
        border-bottom: 1px dashed #ddd !important;
        /* Light separator */
        border-radius: 0;
        padding: 8px 0;
        animation: none;
        break-inside: avoid;
    }

    .item-icon {
        font-size: 16pt;
        margin-right: 10px;
        filter: none;
        /* Ensure emojis print clearly if supported */
    }

    .item-content {
        flex-direction: row;
        align-items: center;
        gap: 10px;
    }

    .item-name {
        color: black !important;
        font-size: 12pt;
        overflow: visible;
        white-space: normal;
    }

    /* Print specific checkbox */
    .list-item::before {
        content: "☐";
        font-size: 16pt;
        margin-right: 12px;
        line-height: 1;
        color: black;
    }

    .item-controls {
        display: block;
        /* We need to show qty but hide buttons */
    }

    /* Only show qty value */
    .qty-controls {
        background: none !important;
        padding: 0;
    }

    .qty-val {
        color: black !important;
        font-weight: bold;
        border: 1px solid black;
        border-radius: 4px;
        padding: 2px 6px;
        font-size: 10pt;
    }
}