body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f9;
    overflow-y: scroll; /* Allow scrolling */
}

header {
    background-color: #333;
    color: white;
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-controls {
    display: flex;
    gap: 1rem;
}

header input {
    padding: 0.5rem;
    border-radius: 4px;
    border: none;
    width: 300px;
}

#toggle-flier-btn {
    padding: 0.5rem 1rem;
    background-color: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

#main-container {
    display: flex;
    height: calc(100vh - 70px);
}

#product-grid {
    flex-grow: 1;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    padding: 2rem;
    overflow-y: auto;
}

/* Sidebar Styles */
#flier-tray {
    width: 350px;
    background: white;
    border-left: 1px solid #ddd;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 5px rgba(0,0,0,0.1);
    transition: margin-right 0.3s;
}

#flier-tray.hidden {
    margin-right: -350px; /* Hide off-screen */
    display: none;
}

.flier-section {
    margin-bottom: 1rem;
}

.flier-section label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.flier-section textarea {
    width: 100%;
    height: 60px;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#flier-items-list {
    flex-grow: 1;
    overflow-y: auto;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
    padding: 1rem 0;
}

.flier-item {
    background: #f9f9f9;
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.flier-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.flier-item-title {
    font-size: 0.9rem;
    font-weight: bold;
}

.remove-btn {
    background: none;
    border: none;
    color: red;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

.flier-item-price-row {
    display: flex;
    gap: 10px;
}

.price-input-group {
    flex: 1;
}

.price-input-group label {
    display: block;
    font-size: 0.8rem;
    margin-bottom: 2px;
}

.price-input-group input {
    width: 100%;
    padding: 4px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* Product Card */
.product-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    overflow: hidden;
    transition: transform 0.2s;
    display: flex;
    flex-direction: column;
    position: relative;
}

.product-card:hover {
    transform: translateY(-5px);
}

.add-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(255, 255, 255, 0.9);
    border: 1px solid #ddd;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    color: green;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

.add-btn:hover {
    background-color: green;
    color: white;
}

.product-image {
    width: 100%;
    height: 200px;
    object-fit: contain;
    background-color: #fff;
    border-bottom: 1px solid #eee;
}

.product-info {
    padding: 1rem;
    flex-grow: 1;
}

.product-code {
    color: #888;
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.product-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.1rem;
}

.product-category {
    background-color: #e0e0e0;
    color: #555;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.8rem;
    display: inline-block;
}

.product-price {
    font-weight: bold;
    color: #333;
    margin-top: 0.5rem;
    display: block;
}

.variant-list {
    margin-top: 1rem;
    font-size: 0.9rem;
    border-top: 1px solid #eee;
    padding-top: 0.5rem;
}

.variant-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.2rem;
}

.qty-badge {
    font-weight: bold;
}

.qty-ok { color: green; }
.qty-low { color: orange; }
.qty-out { color: red; }

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 200;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    width: 80%;
    max-width: 800px;
    height: 80%;
    padding: 2rem;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
}

#email-preview-frame {
    flex-grow: 1;
    border: 1px solid #ddd;
    background: #fff;
    overflow-y: auto;
    padding: 1rem;
    margin-bottom: 1rem;
}

.close-btn {
    align-self: flex-end;
    font-size: 2rem;
    cursor: pointer;
}

.action-btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

.action-btn.primary { background-color: #007bff; color: white; }
.action-btn.danger { background-color: #dc3545; color: white; }