* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 900px;
    margin: 0 auto;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: white;
    font-size: 2.5rem;
    margin-bottom: 20px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.2);
}

/* Tabs */
.tabs {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.tab-btn {
    padding: 12px 30px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 1rem;
    cursor: pointer;
    border-radius: 25px;
    transition: all 0.3s ease;
}

.tab-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.tab-btn.active {
    background: white;
    color: #667eea;
    font-weight: 600;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Card */
.card {
    background: white;
    border-radius: 15px;
    padding: 25px;
    margin-bottom: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

h2 {
    color: #333;
    margin-bottom: 20px;
    font-size: 1.5rem;
}

h3 {
    color: #555;
    margin-bottom: 10px;
    font-size: 1.1rem;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

input[type="text"],
select {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus,
select:focus {
    outline: none;
    border-color: #667eea;
}

/* Ingredient Input Group */
.ingredient-input-group {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 10px;
    align-items: center;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
}

.btn-primary {
    background: #667eea;
    color: white;
    width: 100%;
}

.btn-primary:hover {
    background: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #e0e0e0;
    color: #333;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

.btn-danger {
    background: #ff6b6b;
    color: white;
}

.btn-danger:hover {
    background: #ee5a52;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* List Header */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.list-actions {
    display: flex;
    gap: 10px;
}

/* Sort Controls */
.sort-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.sort-label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
}

.sort-btn {
    padding: 6px 12px;
    border: 2px solid #e0e0e0;
    background: white;
    color: #555;
    border-radius: 6px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sort-btn:hover {
    border-color: #667eea;
    background: #f8f9ff;
}

.sort-btn.active {
    border-color: #667eea;
    background: #667eea;
    color: white;
    font-weight: 600;
}

/* Grocery List */
.grocery-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.grocery-item {
    display: flex;
    align-items: center;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 10px;
    transition: all 0.3s ease;
}

.grocery-item:hover {
    background: #e9ecef;
}

.grocery-item.purchased {
    opacity: 0.6;
}

.grocery-item.purchased .item-details {
    text-decoration: line-through;
}

.grocery-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin-right: 15px;
    cursor: pointer;
}

.item-details {
    flex: 1;
}

.item-name {
    font-weight: 600;
    font-size: 1.1rem;
    color: #333;
}

.item-quantity {
    color: #666;
    font-size: 0.9rem;
}

.item-category {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-left: 10px;
    font-weight: 500;
}

.item-store {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.75rem;
    margin-left: 5px;
    font-weight: 500;
    background: #e3f2fd;
    color: #1565c0;
}

.category-produce { background: #d4edda; color: #155724; }
.category-dairy { background: #d1ecf1; color: #0c5460; }
.category-meat { background: #f8d7da; color: #721c24; }
.category-bakery { background: #fff3cd; color: #856404; }
.category-pantry { background: #e2e3e5; color: #383d41; }
.category-other { background: #e7e7e7; color: #555; }

.delete-btn {
    background: none;
    border: none;
    color: #ff6b6b;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px 10px;
    transition: color 0.3s ease;
}

.delete-btn:hover {
    color: #ee5a52;
}

/* Recipes */
.recipes-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 15px;
}

.recipe-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 20px;
    transition: all 0.3s ease;
}

.recipe-card:hover {
    background: #e9ecef;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.recipe-header {
    margin-bottom: 15px;
}

.recipe-name {
    font-weight: 600;
    font-size: 1.2rem;
    color: #333;
    margin-bottom: 5px;
}

.recipe-info {
    color: #666;
    font-size: 0.9rem;
}

.recipe-ingredients {
    margin-bottom: 15px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    max-height: 150px;
    overflow-y: auto;
}

.recipe-ingredient {
    padding: 5px 0;
    font-size: 0.9rem;
    color: #555;
    border-bottom: 1px solid #f0f0f0;
}

.recipe-ingredient:last-child {
    border-bottom: none;
}

.recipe-actions {
    display: flex;
    gap: 10px;
}

#recipe-ingredients-list {
    margin-bottom: 15px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.temp-ingredient {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px;
    background: white;
    border-radius: 5px;
    margin-bottom: 5px;
}

.temp-ingredient-info {
    flex: 1;
}

.temp-ingredient button {
    background: none;
    border: none;
    color: #ff6b6b;
    cursor: pointer;
    font-size: 1rem;
}

/* Empty Messages */
.empty-message {
    text-align: center;
    color: #999;
    padding: 40px 20px;
    font-style: italic;
}

/* Settings Section */
.settings-section {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.add-item-form {
    display: flex;
    gap: 10px;
    align-items: center;
}

.add-item-form input {
    flex: 1;
}

.add-item-form .btn {
    width: auto;
}

.manage-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.manage-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.manage-item:hover {
    background: #e9ecef;
}

.manage-item span {
    font-weight: 500;
    color: #333;
}

/* Responsive Design */
@media (max-width: 768px) {
    h1 {
        font-size: 1.8rem;
    }

    .ingredient-input-group {
        grid-template-columns: 1fr;
    }

    .list-actions {
        flex-direction: column;
        width: 100%;
    }

    .list-actions button {
        width: 100%;
    }

    .recipes-list {
        grid-template-columns: 1fr;
    }

    .sort-controls {
        flex-direction: column;
        align-items: flex-start;
    }

    .sort-btn {
        flex: 1;
        width: 100%;
    }
}
