/* General Body and Container */
body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f4f4f4;
    color: #333;
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 20px auto;
    background-color: #fff;
    padding: 20px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

h1, h2 {
    color: #0056b3;
    text-align: center;
    margin-bottom: 20px;
}

p {
    text-align: center;
}

/* Table Styling */
table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
}

table th, table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
}

table th {
    background-color: #0056b3;
    color: white;
    font-weight: bold;
}

table tr:nth-child(even) {
    background-color: #f2f2f2;
}

table tr:hover {
    background-color: #ddd;
}

/* Image Thumbnails */
.bill-image-thumbnail img {
    max-width: 80px; /* Smaller for general display */
    max-height: 80px;
    display: block;
    margin: 0 auto;
    cursor: pointer; /* Indicates it's clickable */
    border: 1px solid #ccc;
    padding: 2px;
    border-radius: 4px;
}

/* Filter Form */
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 30px;
    padding: 15px;
    background-color: #e9ecef;
    border-radius: 8px;
    justify-content: center;
    align-items: center;
}

.filter-form label {
    font-weight: bold;
    margin-right: 5px;
}

.filter-form select, .filter-form button {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
}

.filter-form button {
    background-color: #007bff;
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.filter-form button:hover {
    background-color: #0056b3;
}

.filter-form a.add-button { /* For the clear filters button */
    background-color: #6c757d;
    color: white;
    padding: 8px 12px;
    text-decoration: none;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}
.filter-form a.add-button:hover {
    background-color: #5a6268;
}

/* Payment Status Colors */
.status-paid {
    color: green;
    font-weight: bold;
}

.status-unpaid {
    color: red;
    font-weight: bold;
}

.status-paid img, .status-unpaid img {
    width: 24px;
    height: 24px;
    vertical-align: middle;
    margin-right: 5px;
}

/* --- Product Grid Styling (for "Manage Bills Overall") --- */
#product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); /* Responsive grid */
    gap: 20px;
    margin-top: 20px;
}

.product-item {
    background-color: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease-in-out;
    display: flex; /* Use flexbox for internal layout */
    flex-direction: column;
}

.product-item:hover {
    transform: translateY(-5px);
}

.product-item .product-title {
    font-weight: bold;
    font-size: 1.1em;
    padding: 10px;
    background-color: #f8f8f8;
    border-bottom: 1px solid #eee;
}

.product-item .bill-image-thumbnail {
    padding: 15px;
    flex-grow: 1; /* Allows image area to expand */
    display: flex;
    justify-content: center;
    align-items: center;
}

.product-item .bill-image-thumbnail img {
    max-width: 150px; /* Larger image in the grid */
    max-height: 150px;
    width: auto;
    height: auto;
    cursor: pointer;
    border: 1px solid #ccc;
    padding: 5px;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.product-tile-footer {
    padding: 15px;
    background-color: #f8f8f8;
    border-top: 1px solid #eee;
}

.product-tile-footer .product-price {
    font-size: 1em;
    color: #333;
    margin-bottom: 5px;
}

/* Add/Edit/Delete Buttons in Product Grid Footer */
.action-button {
    display: inline-block;
    padding: 8px 15px;
    margin: 5px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.3s ease;
    color: white; /* Default text color */
}

.edit-button {
    background-color: #ffc107; /* Yellow for edit */
}

.edit-button:hover {
    background-color: #e0a800;
}

.delete-button {
    background-color: #dc3545; /* Red for delete */
}

.delete-button:hover {
    background-color: #c82333;
}

.add-button { /* General add button style */
    display: block;
    width: fit-content;
    margin: 20px auto;
    padding: 10px 20px;
    background-color: #28a745; /* Green for add */
    color: white;
    text-align: center;
    border-radius: 5px;
    text-decoration: none;
    font-weight: bold;
    transition: background-color 0.3s ease;
}

.add-button:hover {
    background-color: #218838;
}

/* --- Modal Styles (for enlarged image and bill details) --- */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.9);
    padding-top: 60px; /* Space for the close button */
}

/* Image Modal Content */
.modal-content {
    margin: auto;
    display: block;
    width: 80%;
    max-width: 700px;
}

/* Bill Details Modal Content */
.modal-content-details {
    background-color: #fefefe;
    margin: auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 800px; /* Slightly wider for details */
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
    border-radius: 8px;
    position: relative;
}

.modal-content-details h2 {
    color: #0056b3;
    margin-bottom: 15px;
}

.modal-content-details table {
    margin-top: 20px;
}

/* Close button for both modals */
.close {
    position: absolute;
    top: 15px;
    right: 35px;
    color: #f1f1f1; /* For image modal */
    font-size: 40px;
    font-weight: bold;
    transition: 0.3s;
    cursor: pointer;
}

#billDetailsModal .close { /* Override for bill details modal */
    color: #aaa;
    right: 20px;
    top: 10px;
    font-size: 30px;
}

.close:hover,
.close:focus {
    color: #bbb; /* For image modal */
    text-decoration: none;
    cursor: pointer;
}

#billDetailsModal .close:hover,
#billDetailsModal .close:focus { /* Override for bill details modal */
    color: #000;
}


/* Responsive adjustments */
@media screen and (max-width: 768px) {
    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }
    .filter-form select, .filter-form button, .filter-form a {
        width: 100%;
        box-sizing: border-box; /* Include padding in width */
    }
    .modal-content, .modal-content-details {
        width: 95%;
    }
}