/* Copyright (c) 2025. Jericho Crosby (Chalwk) */

:root {
    --primary: #4a6fa5;
    --secondary: #6b8cbc;
    --accent: #ff9e44;
    --light: #f5f7fa;
    --dark: #2c3e50;
    --text: #333;
    --text-light: #666;
    --border: #e1e5eb;
    --success: #2ecc71;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--light);
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

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

header {
    text-align: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

footer {
    text-align: center;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

h1 {
    color: var(--primary);
    margin-bottom: 10px;
}

.subtitle {
    color: var(--text-light);
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.search-container {
    margin: 20px 0;
    display: flex;
    justify-content: center;
}

#searchInput {
    width: 100%;
    max-width: 500px;
    padding: 12px 20px;
    border: 1px solid var(--border);
    border-radius: 30px;
    font-size: 1rem;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

#searchInput:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74, 111, 165, 0.2);
}

.controls {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.control-btn {
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow);
}

.control-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.control-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 5px;
}

.dropdown-toggle::after {
    content: '◌';
    font-size: 0.8rem;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: white;
    min-width: 200px;
    box-shadow: var(--shadow);
    border-radius: 8px;
    z-index: 100;
    top: 100%;
    left: 0;
    margin-top: 5px;
    flex-direction: column;
    overflow: hidden;
}

.dropdown-content .control-btn {
    border: none;
    border-radius: 0;
    text-align: left;
    padding: 12px 16px;
    width: 100%;
    margin: 0;
    box-shadow: none;
    border-bottom: 1px solid var(--border);
}

.dropdown-content .control-btn:last-child {
    border-bottom: none;
}

.dropdown-content .control-btn:hover {
    background-color: var(--light);
}

.dropdown.active .dropdown-content {
    display: flex;
}

.dropdown.active .dropdown-toggle {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.category-section {
    margin-bottom: 40px;
}

.category-title {
    color: var(--primary);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.category-toggle {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 5px;
}

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

.category-edit, .category-delete {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 1rem;
    padding: 5px;
    transition: var(--transition);
}

.category-edit:hover {
    color: var(--primary);
}

.category-delete:hover {
    color: #e74c3c;
}

.grocery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.grocery-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: var(--shadow);
    transition: var(--transition);
    border-left: 4px solid var(--primary);
    display: flex;
    flex-direction: column;
    position: relative;
}

.grocery-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.grocery-card.hidden {
    display: none;
}

.grocery-card.needed {
    opacity: 0.7;
    background-color: #f9f9f9;
}

.grocery-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.grocery-name {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.grocery-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.grocery-actions {
    display: flex;
    gap: 5px;
}

.grocery-edit, .grocery-delete {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.9rem;
    padding: 2px;
    transition: var(--transition);
}

.grocery-edit:hover {
    color: var(--primary);
}

.grocery-delete:hover {
    color: #e74c3c;
}

.grocery-details {
    color: var(--text-light);
    font-size: 0.9rem;
    margin-top: 10px;
}

.grocery-price {
    font-weight: bold;
    color: var(--primary);
    margin-top: 5px;
}

.grocery-store {
    font-style: italic;
    margin-top: 5px;
}

.grocery-description {
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.no-results {
    text-align: center;
    padding: 40px;
    color: var(--text-light);
    font-style: italic;
    grid-column: 1 / -1;
}

.stats {
    display: flex;
    justify-content: space-between;
    margin: 20px 0;
    padding: 15px;
    background: white;
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--primary);
}

.stat-label {
    font-size: 0.9rem;
    color: var(--text-light);
}

.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 20px;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 10px;
}

.close:hover {
    color: black;
}

.modal h2 {
    margin-bottom: 20px;
    color: var(--primary);
}

.modal label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}

.modal input, .modal select, .modal textarea {
    width: 100%;
    padding: 10px;
    margin-bottom: 15px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
}

.modal textarea {
    resize: vertical;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

.modal-buttons button {
    padding: 8px 16px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.modal-buttons button[type="submit"] {
    background-color: var(--primary);
    color: white;
}

.modal-buttons button[type="submit"]:hover {
    background-color: var(--secondary);
}

.modal-buttons button[type="button"] {
    background-color: #f1f1f1;
    color: var(--text);
}

.modal-buttons button[type="button"]:hover {
    background-color: #e1e1e1;
}

@media (max-width: 768px) {
    .grocery-grid {
        grid-template-columns: 1fr;
    }

    .stats {
        flex-direction: column;
        gap: 15px;
    }

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

    .control-btn, .dropdown {
        width: 100%;
        max-width: 200px;
    }

    .dropdown-content {
        position: static;
        margin-top: 10px;
        box-shadow: none;
        border: 1px solid var(--border);
        min-width: auto;
        width: 100%;
    }

    .dropdown.active .dropdown-content {
        display: flex;
        position: static;
    }
}