:root {
    --primary-color: #4CAF50; /* Green */
    --secondary-color: #FF9800; /* Orange */
    --accent-color: #ff5722; /* Deep Orange */
    --light-bg: #f5f5f5;
    --dark-bg: #1a1a1a;
    --text-color-light: #333;
    --text-color-dark: #eee;
    --card-bg-light: #ffffff;
    --card-bg-dark: #2c2c2c;
    --gradient-hero: linear-gradient(135deg, #44a08d, #093637);
    --gradient-product: linear-gradient(145deg, #e0f7fa, #aecdd5);
    --gradient-dealer: linear-gradient(145deg, #e0f7fa, #c8e6c9);
    --gradient-rewards-display: linear-gradient(145deg, #81C784, #4CAF50); /* Lighter green to primary green for rewards display */
    --gradient-navbar: linear-gradient(to right, #1a1a1a, #333333);
    --gradient-footer: linear-gradient(to right, #333333, #1a1a1a);
}

body {
    font-family: 'Segoe UI', sans-serif;
    margin: 0;
    padding: 0;
    background: var(--light-bg);
    color: var(--text-color-light);
    transition: background 0.4s, color 0.4s;
}
.dark-mode {
    background: var(--dark-bg);
    color: var(--text-color-dark);
}
.dark-mode .navbar {
    background: var(--gradient-navbar);
    color: var(--text-color-dark);
    box-shadow: 0 2px 15px rgba(0,0,0,0.4);
}
.dark-mode .footer {
    background: var(--gradient-footer);
    color: var(--text-color-dark);
    box-shadow: 0 -2px 15px rgba(0,0,0,0.4);
}
.dark-mode .product-card {
    background: var(--card-bg-dark);
    color: var(--text-color-dark);
    box-shadow: 0 6px 20px rgba(0,0,0,0.6);
}
.dark-mode .dealer-card {
    background: var(--card-bg-dark);
    color: var(--text-color-dark);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}
/* Removed .dark-mode .rewards-box styles */
.dark-mode .modal-content {
    background-color: var(--card-bg-dark);
    color: var(--text-color-dark);
    box-shadow: 0 10px 30px rgba(0,0,0,0.7);
}
.dark-mode .modal-content input {
    background-color: #444;
    color: var(--text-color-dark);
    border: 1px solid #555;
}
.dark-mode .modal-content input:focus {
    border-color: var(--secondary-color);
}
.dark-mode .close-button:hover,
.dark-mode .close-button:focus {
    color: var(--text-color-dark);
}
.dark-mode #purchaseHistory th {
    background-color: #388e3c;
}
.dark-mode #purchaseHistory tbody tr:nth-child(even) {
    background-color: #333;
}
.dark-mode #purchaseHistory tbody tr:hover {
    background-color: #444;
}
.dark-mode #purchaseHistory p.no-history {
    color: #bbb;
}
.dark-mode #invoiceDetails hr {
    border-top: 1px dashed #555;
}
.dark-mode #invoiceItemList li {
    border-bottom: 1px dotted #444;
}
.dark-mode .filter-btn {
    background-color: #444;
    color: var(--text-color-dark);
    border-color: #555;
}
.dark-mode .filter-btn:hover {
    background-color: #555;
}
.dark-mode .filter-btn.active {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.6);
}
.dark-mode .total-rewards-display {
    background: var(--gradient-rewards-display);
    box-shadow: 0 5px 15px rgba(46, 125, 50, 0.5);
}


.navbar {
    background: var(--gradient-navbar);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1em 2em;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 999;
}
.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5em;
}
.nav-links {
    list-style: none;
    display: flex;
    gap: 1.5em;
    margin: 0;
    padding: 0;
}
.nav-links li a {
    color: #fff;
    text-decoration: none;
    transition: color 0.3s ease, transform 0.2s ease;
    position: relative;
}
.nav-links li a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 0;
    background-color: var(--secondary-color);
    transition: width 0.3s ease-in-out;
}
.nav-links li a:hover::after {
    width: 100%;
}
.nav-links li a:hover {
    color: var(--secondary-color);
    transform: translateY(-2px);
}
.logo {
    font-size: 2rem;
    font-weight: bold;
    letter-spacing: 1px;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
    background: linear-gradient(45deg, #ff5722, #ff9800);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.icon-btn {
    background: none;
    border: none;
    color: white;
    padding: 0.5em;
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.3s, transform 0.2s ease, box-shadow 0.3s ease;
    font-size: 1.8em;
    display: flex;
    align-items: center;
    justify-content: center;
}
.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
/* Cart Icon specific styles */
#cartIcon {
    position: relative;
    margin-right: 0.5em;
}
#cartItemCount {
    position: absolute;
    top: -8px;
    right: -8px;
    background-color: red;
    color: white;
    border-radius: 50%;
    padding: 2px 6px;
    font-size: 0.7em;
    min-width: 18px;
    text-align: center;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}


.hero-section {
    background: var(--gradient-hero);
    color: white;
    text-align: center;
    padding: 4em 2em;
    animation: fadeIn 1s ease-out;
    border-bottom-left-radius: 50% 10%;
    border-bottom-right-radius: 50% 10%;
}
.hero-section h1 {
    font-size: 3.5em;
    margin-bottom: 0.5em;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
    animation: slideInFromTop 1s ease-out;
}
.hero-section p {
    font-size: 1.3em;
    max-width: 700px;
    margin: 0 auto 1.5em auto;
    animation: fadeIn 1.5s ease-out;
}
.btn {
    background: var(--accent-color);
    color: white;
    padding: 0.75em 1.5em;
    border: none;
    margin-top: 1em;
    cursor: pointer;
    border-radius: 5px;
    transition: background 0.3s, transform 0.2s ease, box-shadow 0.3s ease;
    text-decoration: none;
    display: inline-block;
    font-weight: bold;
    animation: pulse 2s infinite ease-in-out;
}
.btn:hover {
    background: #e64a19;
    transform: translateY(-5px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.3);
    animation: none;
}

.dashboard-section {
    padding: 2em;
    text-align: center;
}
.dashboard-section h2 {
    font-size: 2.5em;
    color: var(--primary-color);
    margin-bottom: 1em;
    position: relative;
    display: inline-block;
}
.dashboard-section h2::after {
    content: '';
    position: absolute;
    width: 60%;
    height: 4px;
    background: var(--secondary-color);
    bottom: -10px;
    left: 20%;
    border-radius: 2px;
    animation: expandLine 1s ease-out;
}

/* Product filter styles */
.product-filter-container {
    margin-top: 2em;
    margin-bottom: 3em; /* Space between filters and products */
    text-align: center;
}
.product-filter-container h3 {
    font-size: 2em;
    color: var(--primary-color);
    margin-bottom: 1em;
}

.filter-buttons {
    display: flex;
    justify-content: center;
    gap: 1em;
    flex-wrap: wrap; /* Allow wrapping on small screens */
}
.filter-btn {
    background-color: #eee;
    color: var(--text-color-light);
    border: 1px solid #ccc;
    padding: 0.8em 1.5em;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 120px; /* Ensure buttons have a consistent minimum width */
}
.filter-btn:hover {
    background-color: #ddd;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
.filter-btn.active {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
    transform: translateY(-3px);
}


.product-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5em;
    margin-top: 2em;
}
.product-card {
    background: var(--gradient-product);
    border: 1px solid #ddd;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    padding: 1em;
    padding-bottom: 60px; /* Increased padding to make space for aligned button */
    text-align: center;
    width: 220px;
    position: relative;
    transition: transform 0.4s ease, box-shadow 0.3s ease;
    overflow: hidden;
    display: flex; /* Use flexbox for internal alignment */
    flex-direction: column; /* Stack children vertically */
    justify-content: space-between; /* Push button to the bottom */
}
.product-card::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    transition: width 0.4s ease, height 0.4s ease;
    z-index: 0;
}
.product-card:hover::before {
    width: 200%;
    height: 200%;
}
.product-card * {
    position: relative;
    z-index: 1;
}
.product-card img {
    max-width: 100%;
    border-radius: 10px;
    height: 150px;
    object-fit: cover;
    margin-bottom: 10px;
    transition: transform 0.3s ease;
}
.product-card:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
}
.product-card:hover img {
    transform: scale(1.02);
}

.product-card h3 {
    margin-top: 0.5em;
    margin-bottom: 0.2em;
}
.product-card p {
    margin-bottom: 0.5em;
    flex-grow: 1; /* Allows content to push button down */
}

.offer-text {
    color: rgb(5, 185, 5);
    transition: transform 0.3s ease, color 0.3s ease;
    font-weight: bold;
    margin-top: 10px;
    margin-bottom: 15px; /* Add some space below offer text */
}
.product-card:hover .offer-text {
    transform: scale(1.1);
    color: #008000;
}

.badge {
    position: absolute;
    top: -10px;
    right: -10px;
    background: red;
    color: white;
    padding: 5px 10px;
    font-size: 0.75rem;
    border-radius: 8px;
    animation: pop 0.6s ease-in-out;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 10;
    /* Ensure visibility on light and dark backgrounds */
    border: 2px solid white; /* Add a white border for contrast */
    box-shadow: 0 0 8px rgba(255,0,0,0.5); /* Add a glow */
}
.buy-btn {
    background: var(--primary-color);
    width: calc(100% - 2em); /* Make button span full width minus padding */
    position: absolute; /* Position it at the bottom */
    bottom: 1em; /* Distance from the bottom */
    left: 1em; /* Distance from the left */
    margin-top: 0; /* Override default margin-top */
}
.buy-btn:hover {
    background: #388e3c;
}

.dealer-section {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5em;
    justify-content: center;
}
.dealer-card {
    flex: 1 1 300px;
    background: var(--gradient-dealer);
    padding: 1em;
    border-radius: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    max-width: 400px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    position: relative;
    overflow: hidden;
}
.dealer-card::before {
    content: '';
    position: absolute;
    top: -10px;
    left: -10px;
    right: -10px;
    bottom: -10px;
    border: 2px solid transparent;
    border-radius: 15px;
    animation: pulseBorder 2s infinite ease-out;
    opacity: 0;
    z-index: 0;
}
.dealer-card:hover::before {
    opacity: 1;
}

.dealer-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.dealer-distance {
    font-weight: bold;
    color: #00796b;
    transition: color 0.3s ease;
}
.dealer-card:hover .dealer-distance {
    color: #004d40;
}

.footer {
    text-align: center;
    padding: 1em;
    background: var(--gradient-footer);
    color: white;
    margin-top: 2em;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

/* Modal Styles */
.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.6);
    justify-content: center;
    align-items: center;
}

.modal-content {
    background-color: var(--card-bg-light);
    padding: 30px;
    border-radius: 10px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 8px 25px rgba(0,0,0,0.2);
    position: relative;
    text-align: center;
    animation: fadeInScale 0.4s ease-out;
}

.close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s ease;
}

.close-button:hover,
.close-button:focus {
    color: #000;
    text-decoration: none;
}

.modal-content input {
    margin-bottom: 15px;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    width: calc(100% - 22px);
    box-sizing: border-box;
    transition: border-color 0.3s ease;
}
.modal-content input:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.modal-content .btn {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
}

.signup-link {
    margin-top: 15px;
    font-size: 0.9em;
}

.signup-link a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.3s;
}

.signup-link a:hover {
    color: #0056b3;
}

/* Removed Reward Box Specific Styles and Animation as it's moved */

/* Purchase History Section */
#purchaseHistory {
    display: none;
    margin-top: 2em;
    padding: 2em;
    background: var(--light-bg);
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}
.dark-mode #purchaseHistory {
    background: var(--card-bg-dark);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
}

#purchaseHistory h2 {
    color: var(--primary-color);
    margin-bottom: 1.5em;
}

#purchaseHistory table {
    width: 80%;
    margin: 0 auto;
    border-collapse: collapse;
    font-size: 1.1em;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    border-radius: 8px;
    overflow: hidden;
}

#purchaseHistory th, #purchaseHistory td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

#purchaseHistory th {
    background-color: var(--primary-color);
    color: white;
    font-weight: bold;
    text-transform: uppercase;
}

#purchaseHistory tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}
.dark-mode #purchaseHistory tbody tr:nth-child(even) {
    background-color: #333;
}

#purchaseHistory tbody tr:hover {
    background-color: #f1f1f1;
    transform: scale(1.01);
    transition: background-color 0.3s ease, transform 0.2s ease;
}
.dark-mode #purchaseHistory tbody tr:hover {
    background-color: #444;
}

#purchaseHistory p.no-history {
    color: #888;
    font-style: italic;
    margin-top: 1em;
}
.dark-mode #purchaseHistory p.no-history {
    color: #bbb;
}

/* Total Rewards Display in Purchase History */
.total-rewards-display {
    margin: 2em auto 1em auto;
    background: var(--gradient-rewards-display);
    padding: 1em 2em;
    border-radius: 12px;
    width: fit-content;
    font-weight: bold;
    color: white;
    font-size: 1.2em;
    box-shadow: 0 5px 15px rgba(0, 128, 0, 0.3);
    text-align: center;
    animation: rewardPop 0.8s ease-out forwards;
}
.total-rewards-display:hover {
    transform: scale(1.02);
    box-shadow: 0 8px 20px rgba(0, 128, 0, 0.5);
}


/* Clear History Button */
.clear-history-btn {
    background-color: #f44336; /* Red for destructive action */
    margin-top: 2em; /* More space from table */
}
.clear-history-btn:hover {
    background-color: #d32f2f;
}

/* Invoice Modal Specific Styles */
#invoiceModal .modal-content {
    max-width: 500px;
    text-align: left;
    padding: 2em;
}

#invoiceModal h3 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 1em;
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 0.5em;
}

#invoiceDetails p {
    margin-bottom: 0.5em;
}

#invoiceDetails hr {
    border: 0;
    border-top: 1px dashed #ccc;
    margin: 1em 0;
}
.dark-mode #invoiceDetails hr {
    border-top: 1px dashed #555;
}

#invoiceItemList {
    list-style: none;
    padding: 0;
    margin-bottom: 1em;
}

#invoiceItemList li {
    display: flex;
    justify-content: space-between;
    padding: 0.5em 0;
    border-bottom: 1px dotted #eee;
}
.dark-mode #invoiceItemList li {
    border-bottom: 1px dotted #444;
}

#invoiceItemList li:last-child {
    border-bottom: none;
}

.invoice-rewards { /* Style for reward points in invoice */
    font-weight: bold;
    color: var(--primary-color);
    margin-top: 1.5em;
    font-size: 1.1em;
    text-align: center;
}

.print-invoice-btn {
    margin-top: 1.5em;
    background-color: #007bff;
}
.print-invoice-btn:hover {
    background-color: #0056b3;
}


/* Keyframe Animations */
@keyframes pop {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInScale {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes slideInFromTop {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 rgba(255, 87, 34, 0.4); }
    50% { transform: scale(1.02); box-shadow: 0 0 15px rgba(255, 87, 34, 0.7); }
    100% { transform: scale(1); box-shadow: 0 0 0 rgba(255, 87, 34, 0.4); }
}

@keyframes expandLine {
    from { width: 0%; }
    to { width: 60%; }
}

@keyframes rewardPop {
    0% { transform: scale(0.5) translateY(20px); opacity: 0; box-shadow: 0 0 0 rgba(0, 128, 0, 0); }
    50% { transform: scale(1.1) translateY(-5px); opacity: 1; box-shadow: 0 5px 25px rgba(0, 128, 0, 0.4); }
    100% { transform: scale(1) translateY(0); opacity: 1; box-shadow: 0 5px 15px rgba(0, 128, 0, 0.3); }
}

@keyframes glowingBorder {
    0% { box-shadow: 0 0 5px var(--secondary-color), 0 0 10px var(--secondary-color); border-color: var(--secondary-color); }
    100% { box-shadow: 0 0 15px var(--accent-color), 0 0 25px var(--accent-color); border-color: var(--accent-color); }
}

@keyframes pulseBorder {
    0% { border-color: transparent; opacity: 0; transform: scale(0.8); }
    50% { border-color: var(--primary-color); opacity: 1; transform: scale(1.05); }
    100% { border-color: transparent; opacity: 0; transform: scale(1.2); }
}


/* Responsive Adjustments */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        padding: 1em;
    }
    .nav-right {
        flex-direction: column;
        gap: 1em;
        margin-top: 1em;
    }
    .nav-links {
        flex-direction: column;
        align-items: center;
        gap: 0.5em;
    }
    .hero-section {
        padding: 3em 1em;
        border-bottom-left-radius: 30% 5%;
        border-bottom-right-radius: 30% 5%;
    }
    .hero-section h1 {
        font-size: 2.5em;
    }
    .hero-section p {
        font-size: 1em;
    }
    .product-card {
        width: 90%;
    }
    .dealer-card {
        flex-direction: column;
        text-align: center;
        gap: 0.5em;
    }
    /* Removed .rewards-box responsive style */
    #purchaseHistory table {
        width: 100%;
        font-size: 0.9em;
    }
    #purchaseHistory th, #purchaseHistory td {
        padding: 8px 10px;
    }
    .filter-buttons {
        gap: 0.5em;
        justify-content: space-around;
    }
    .filter-btn {
        min-width: unset; /* Remove min-width on small screens */
        flex: 1 1 auto; /* Allow buttons to share space */
        padding: 0.7em 1em;
    }
    .total-rewards-display {
        font-size: 1em;
        padding: 0.8em 1.5em;
    }
}