:root {
    --primary-color-light: #ffffff;
    --secondary-color-light: #244784;
    --accent-color-light: #0b1a33;
    --background-color-light: #f5f5f7;
    --card-background-light: #ffffff;
    --text-color-light: #1d1d1f;
    --subtle-text-color-light: #86868b;
    --card-shadow-light: 0 1px 2px rgba(0,0,0,0.05), 0 2px 5px rgba(0,0,0,0.05);

    --primary-color-dark: #0b1a33;
    --secondary-color-dark: #ffffff;
    --accent-color-dark: #25D366;
    --background-color-dark: #000000;
    --card-background-dark: #1c1c1e;
    --text-color-dark: #f5f5f7;
    --subtle-text-color-dark: #8d8d92;
    --card-shadow-dark: 0 1px 2px rgba(0,0,0,0.2), 0 2px 5px rgba(0,0,0,0.2);
}

[data-theme="light"] {
    --primary-color: var(--primary-color-light);
    --secondary-color: var(--secondary-color-light);
    --accent-color: var(--accent-color-light);
    --background-color: var(--background-color-light);
    --card-background: var(--card-background-light);
    --text-color: var(--text-color-light);
    --subtle-text-color: var(--subtle-text-color-light);
    --card-shadow: var(--card-shadow-light);
}

[data-theme="dark"] {
    --primary-color: var(--primary-color-dark);
    --secondary-color: var(--secondary-color-dark);
    --accent-color: var(--accent-color-dark);
    --background-color: var(--background-color-dark);
    --card-background: var(--card-background-dark);
    --text-color: var(--text-color-dark);
    --subtle-text-color: var(--subtle-text-color-dark);
    --card-shadow: var(--card-shadow-dark);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    width: 90%;
    max-width: 1100px;
    margin: 0 auto;
}

header {
    background-color: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid rgba(0,0,0,0.05);
}

[data-theme="dark"] header {
    background-color: rgba(28, 28, 30, 0.8);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.home-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--secondary-color-light);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

[data-theme="dark"] .home-link {
    background: var(--accent-color-dark);
    color: var(--primary-color-dark);
}

.home-link:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.logo {
    width: 40px;
    height: 40px;
    transition: transform 0.3s ease;
}

.logo-link {
    text-decoration: none;
}

.slogan {
    flex-grow: 1;
    text-align: center;
    color: var(--subtle-text-color);
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0 1rem;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.cart-icon-container {
    position: relative;
    cursor: pointer;
}

.cart-icon-container .material-icons {
    font-size: 1.8rem;
    color: var(--text-color);
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background-color: var(--accent-color);
    color: var(--primary-color);
    border-radius: 50%;
    padding: 0.2em 0.5em;
    font-size: 0.7rem;
    font-weight: 500;
}

main {
    padding: 2rem 0;
}

main h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 2rem;
    font-weight: 600;
}

.controls-container {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    padding: 1.5rem;
    background-color: var(--card-background);
    border-radius: 18px;
    box-shadow: var(--card-shadow);
}

.search-container {
    position: relative;
}

.search-container .material-icons {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--subtle-text-color);
}

#search-input {
    width: 100%;
    padding: 0.8rem 0.8rem 0.8rem 3rem;
    border-radius: 12px;
    border: 1px solid var(--subtle-text-color);
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

#search-input:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.3);
}

[data-theme="light"] #search-input:focus {
     box-shadow: 0 0 0 3px rgba(36, 71, 132, 0.3);
}

.filters-container, .sorting-container {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filters-container select, .sorting-container select {
    width: 100%;
    padding: 0.8rem;
    border-radius: 12px;
    border: 1px solid var(--subtle-text-color);
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: 1rem;
    cursor: pointer;
}

.price-filter {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.price-filter input {
    width: 100px;
    padding: 0.8rem;
    border-radius: 12px;
    border: 1px solid var(--subtle-text-color);
    background-color: var(--background-color);
    color: var(--text-color);
    font-size: 1rem;
    -moz-appearance: textfield;
    appearance: textfield;
}

.price-filter input::-webkit-outer-spin-button,
.price-filter input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.price-filter-icon {
    cursor: pointer;
    color: var(--secondary-color);
    background-color: var(--primary-color);
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.price-filter-icon:hover {
    background-color: var(--secondary-color);
    color: var(--primary-color);
    transform: scale(1.1);
}

.price-filter span {
    color: var(--subtle-text-color);
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: var(--primary-color);
    padding: 0.8rem;
}

.sorting-container {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
}

.sorting-container label {
    white-space: nowrap;
    color: var(--subtle-text-color);
}

.product-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
}

.product-card {
    background-color: transparent;
    border-radius: 18px;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.6s ease-out, transform 0.6s ease-out;
    perspective: 1000px;
    min-height: 420px;
}

.product-card.visible {
    opacity: 1;
    transform: translateY(0);
}

.product-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.8s;
    transform-style: preserve-3d;
}

.product-card-inner.is-flipped {
    transform: rotateY(180deg);
}

.product-card-front, .product-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden; /* Safari */
    backface-visibility: hidden;
    background-color: var(--card-background);
    border-radius: 18px;
    box-shadow: var(--card-shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.4s ease;
}

.product-card-front:hover {
     transform: translateY(-8px);
     box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

[data-theme="dark"] .product-card-front:hover {
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.3), 0 10px 10px -5px rgba(0,0,0,0.2);
}

.product-card-back {
    transform: rotateY(180deg);
    justify-content: center;
}

.product-card:hover {
    transform: none;
    box-shadow: none;
}

[data-theme="dark"] .product-card:hover {
    box-shadow: none;
}

.product-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.product-info {
    padding: 1.25rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-info-back {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
    text-align: left;
}

.product-info-back .description {
    font-size: 0.9rem;
    margin-bottom: 1rem;
    flex-grow: 1;
    overflow-y: auto; /* For long descriptions */
}

.predefined-filters-container {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.predefined-filters-container h3 {
    flex-basis: 100%;
    text-align: center;
    color: var(--text-color);
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
}

.predefined-filter-btn {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border-radius: 20px;
}

.predefined-filter-btn i {
    font-size: 1.2rem;
    margin-right: 0.5rem;
}

.predefined-filter-btn:hover {
    background-color: var(--primary-color);
    color: var(--text-color);
    border-color: var(--primary-color);
}

.predefined-filter-btn.active {
    background-color: var(--primary-color);
    color: var(--text-color);
    border-color: var(--primary-color);
    font-weight: bold;
}

.btn {
    display: inline-block;
    padding: 0.6rem 1.2rem;
    border: 1px solid transparent;
    border-radius: 12px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: all 0.3s ease;
    font-weight: 500;
    margin-top: auto;
}

.card-buttons {
    display: flex;
    gap: 0.5rem;
    margin-top: auto; /* Pushes buttons to the bottom */
}

.card-buttons .btn {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.6rem;
}

.btn-primary {
    background-color: var(--accent-color);
    color: var(--primary-color);
}

.add-to-cart.in-cart {
    background-color: #4caf50; /* Green to indicate success */
    cursor: default;
}

.btn-info {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

.btn-info:hover {
    opacity: 0.9;
    transform: scale(1.03);
}

.btn-primary:hover {
    background-color: #20b856;
    transform: scale(1.03);
}

/* Theme Switcher */
.theme-switcher {
    display: flex;
    align-items: center;
    background-color: var(--card-background);
    border-radius: 20px;
    padding: 4px;
    cursor: pointer;
}

.theme-switcher .material-icons {
    font-size: 1.2rem;
    color: var(--subtle-text-color);
    transition: color 0.3s ease;
    padding: 2px;
}

.theme-switcher .material-icons.active {
    color: var(--accent-color);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.6);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.modal-content {
    background-color: var(--card-background);
    margin: 10vh auto;
    padding: 2rem;
    border-radius: 18px;
    max-width: 500px;
    width: 90%;
    position: relative;
    animation: slide-in 0.5s cubic-bezier(0.165, 0.84, 0.44, 1);
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
}

.modal-content h2 {
    text-align: center;
    margin-bottom: 1rem;
}

.cart-success-message {
    background-color: #4caf50;
    color: white;
    text-align: center;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-weight: 500;
}

@keyframes slide-in {
    from { transform: translateY(-30px) scale(0.98); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}

.close-button {
    color: var(--subtle-text-color);
    position: absolute;
    top: 1rem;
    right: 1rem;
    font-size: 1.8rem;
    font-weight: normal;
    cursor: pointer;
    transition: color 0.3s ease, transform 0.3s ease;
}

.close-button:hover {
    color: var(--text-color);
    transform: rotate(90deg);
}

#cart-items {
    margin-top: 1.5rem;
    margin-bottom: 2rem;
}

.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid var(--subtle-text-color);
    position: relative;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-item-info p {
    margin: 0;
    color: var(--text-color);
}

.cart-item-info .price {
    color: var(--subtle-text-color);
    font-size: 0.9rem;
}

.remove-item {
    color: #ef4444;
    cursor: pointer;
    transition: color 0.3s ease, transform 0.2s ease;
}

.remove-item:hover {
    color: #dc2626;
    transform: scale(1.1);
}

.remove-item.confirm-delete {
    color: #f44336;
    transform: scale(1.2);
}

.delete-tooltip {
    position: absolute;
    bottom: 100%;
    right: 0;
    transform: translateY(-5px);
    background-color: var(--card-background);
    color: var(--text-color);
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 0.8rem;
    white-space: nowrap;
    box-shadow: var(--card-shadow);
    z-index: 10;
    opacity: 0;
    animation: fadeIn 0.3s forwards;
    pointer-events: none;
}

@keyframes fadeIn {
    to {
        opacity: 1;
    }
}

#whatsapp-button {
    width: 100%;
    padding: 0.8rem;
    font-size: 1rem;
}

/* Tablet and Desktop Styles */
@media (min-width: 640px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .slogan {
        display: none;
    }
    
    .header-left {
        gap: 0.5rem;
    }
    
    .home-link {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .home-link .material-icons {
        font-size: 1.1rem;
    }
}

@media (min-width: 768px) {
    .controls-container {
        grid-template-columns: repeat(2, 1fr);
    }

    .filters-container {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }
}

@media (min-width: 1024px) {
    main h2 {
        font-size: 2.5rem;
    }

    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .controls-container {
        grid-template-columns: 1fr 1.5fr 1fr;
        align-items: center;
    }
}

/* Footer Styles */
footer {
    background-color: var(--card-background);
    padding: 3rem 0;
    border-top: 1px solid rgba(0,0,0,0.05);
    margin-top: 3rem;
    color: var(--subtle-text-color);
}

[data-theme="dark"] footer {
    border-top: 1px solid rgba(255,255,255,0.1);
}

.footer-columns {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-column h4 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: var(--text-color);
    font-weight: 600;
}

.footer-column ul {
    list-style: none;
    padding: 0;
}

.footer-column ul li {
    margin-bottom: 0.75rem;
}

.footer-column ul li a {
    color: var(--subtle-text-color);
    text-decoration: none;
    transition: color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.footer-column ul li a:hover {
    color: var(--accent-color);
}

.footer-column ul li a i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.footer-bottom {
    text-align: center;
    padding-top: 2rem;
    border-top: 1px solid rgba(0,0,0,0.05);
}

[data-theme="dark"] .footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.1);
}

.footer-bottom p {
    font-size: 0.9rem;
}
