:root {
    --navbar-height: 60px;
    --sidebar-width: 250px;
    --primary-color: #3880ff; /* Ionic Blue */
    --tert-color: #f3b83a; /* Ionic Blue */
    --secondary-color: #2dd36f; /* Ionic Success/Green for highlighting */
    --text-color: hsl(0,0%,90%);
    --header-text-color:white;
    --bg-color: hsl(0,0%,20%);
}

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

body {
    font-family: Arial, sans-serif;
    background-color: hsl(0,0%,20%);
}

/* --- App Layout (Desktop View) --- */
/* On desktop, the sidebar and main content live side-by-side */
#app-container {
    display: grid;
    /* Two columns: 250px for sidebar, rest for main content */
    grid-template-columns: var(--sidebar-width) 1fr; 
    height: 100vh;
}

#sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    width: auto;
    overflow-y: auto;
    transition: transform 0.3s ease-out;
}

/* Hide the close button on desktop where the sidebar is always open */
#close-sidebar-btn {
    display: none; 
}

#main-content {
    overflow-y: auto;
}

/* --- Top Navigation Bar --- */
#top-navbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    height: var(--navbar-height);
    background-color: var(--bg-color);
    padding: 0 15px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-container {
    display: flex;
    flex-grow: 1; /* Allows it to take up available space */
    max-width: 600px;
    margin-left: auto;
    position: relative;
}

.search-container .search-results{
    position: absolute;
    display: none;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: var(--bg-color);
    border-bottom-left-radius: 1em;
    border-bottom-right-radius: 1em;
    overflow: hidden;
    
}
.search-container input:focus ~ .search-results {
    display: block;
}
.search-container:hover .search-results {
    display: block;
}
.search-container .search-results a{
    color: white;
    text-decoration: none;
    display: block;
    padding: 1em;
    border-bottom: 1px solid hsl(0, 0%, 30%);
}
.search-container .search-results a span{
    padding-bottom: 10px;
    display: block;
}
.search-container .search-results a:hover{
    background-color: hsl(0, 0%, 30%);
}

.search-container input {
    flex-grow: 1;
    padding: 8px 15px;
    border-radius: 5px 0 0 5px;
    outline: none;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    font-size: 16px;
    background-color: var(--bg-color);
    min-width: 0; /* Important for flex layout */
}

/* Styling for all buttons with icons */
.icon-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-color);
    padding: 8px;
    margin-right: 5px;
}

.icon-btn ion-icon {
    font-size: 24px;
    vertical-align: middle;
}

.search-btn {
    background-color: var(--primary-color);
    color: white;
    border-radius: 0 5px 5px 0;
    padding: 8px 12px;
}

/* Hide hamburger on desktop */
#toggle-sidebar-btn {
    display: none; 
}

/* --- Sidebar Content Styling --- */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}
#sidebar a.title{
    color: white;
    font-size: 1.5em;
    padding: 1em;
    display: block;
    border: none;
    width: 100%;
    text-decoration: none;
}
#sidebar a.title:hover{
    background-color: var(--bg-color);
}
#sidebar nav{
    padding-bottom: 1em;
    flex: 1;
}
#sidebar ul li a ion-icon{
    padding-right: 1.5em;
    font-size: 1.5em;
}
#sidebar ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 1em;
    height: 100%;
}
.bottom-links{
    margin-top: auto;
}

#sidebar a {
    text-decoration: none;
    color: var(--text-color);
    display: flex;
    align-items: center;
    transition: 0.2s;
    padding: 20px 2em;
    border-bottom-right-radius: 2em;
    border-top-right-radius: 2em;
    white-space: nowrap;
    /* border-bottom: 1px solid lightgray; */
}
#sidebar a:hover {
    color: var(--text-color);
    background-color: rgba(0,0,0,0.2);
}

/* --- Product Grid View --- */
.products{
    background-image:repeating-conic-gradient(var(--bg-color) 0 25%, rgb(63, 63, 63) 0 50%);
    background-size: 10px 10px;
}
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(500px,100%), 1fr)); 
    padding: 1em;
    gap: 5px;
    background-color: transparent;
}

.product-card{
    display: flex;
    background-color: var(--bg-color);
    border-top-right-radius: 1em;
    border-bottom-right-radius: 1em;
    overflow: hidden;
    width: 100%;
    flex-direction: row-reverse;
}
.product-card:nth-child(2n+1){
    border-top-right-radius: 0em;
    border-bottom-right-radius: 0em;
    border-bottom-left-radius: 1em;
    border-top-left-radius: 1em;
    flex-direction: row;
}
.product-card .img {
    height: 100%;
    overflow: hidden;
    max-width:30%;
}
.product-card .img img{
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.product-card .content{
    padding: 1em;
    display: flex;
    flex:1;
    color: var(--text-color);
    flex-direction: column;
}
.product-card .content h2{
    padding: 0.2em;
}
.product-card .content p{
    font-size: 0.8em;
    line-height: 1.5em;
    margin-bottom: 1em;
    padding: 0.2em;
}
.product-card .content a.btn{
    padding: 0.5em 1em;
    text-decoration: none;
    display: block;
    margin-top: 1em;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    width: min-content;
    border-radius: 0.2em;
    transition: 0.2s;
    margin-top: auto;

}
.product-card .content a.btn:hover{
    background-color: var(--text-color);
    color: var(--bg-color);
}
.view-btn {
    display: inline-block;
    padding: 8px 15px;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 5px;
    transition: background-color 0.2s;
}

.view-btn:hover {
    background-color: #306bd1;
}
.featured-products {
    background-color: white;
    background-color:  var(--primary-color);
    color: white;
    border-top-left-radius: 1em;
    border-top-right-radius: 1em;
    padding: 2em;
}

.featured-products h2 {
    color: var(--header-text-color);
    margin-bottom: 15px;
}
.featured-products p{
    line-height: 1.5em;
}
.featured-products a.btn{
    padding: 1em 2em;
    background-color: transparent;
    border: 1px solid var(--text-color);
    color: var(--text-color);
    display: block;
    width: max-content;
    margin-top: 1em;
    /* margin-left: auto; */
    text-decoration: none;
    border-radius: 0.2em;
}
.featured-products a.btn:hover{
    background-color: white;
    color: var(--primary-color);
}
.bg-sec{
    --primary-color:var(--secondary-color);
    background-color: var(--secondary-color);
}
.bg-tert{
    --primary-color:var(--tert-color);
    background-color: var(--tert-color);
}
.content-wrapper{
    padding: 1em 1em 0 1em;
}
footer{
    padding: 1em;
    color: var(--text-color);
    border-bottom: 1px solid lightgray;
}
/* --- 4. Mobile Responsiveness (Screen size < 768px) --- */
@media (max-width: 768px) {
    
    /* Mobile Layout: Sidebar and Main Content stack */
    #app-container {
        grid-template-columns: 1fr; /* Single column layout */
    }

    /* Show the hamburger menu button on mobile */
    #toggle-sidebar-btn {
        display: block; 
        order: -1; /* Move to the left */
        margin-right: 10px;
    }

    /* Show the close button on mobile inside the menu */
    #close-sidebar-btn {
        display: block; 
    }

    /* Mobile Sidebar State */
    #sidebar {
        position: fixed; 
        z-index: 20;
        transform: translateX(-100%);
        box-shadow: 2px 0 5px rgba(0,0,0,0.2);
    }
    #sidebar ul{
        padding-right: 1em;
    }
    .product-grid{
        gap: 1em;
    }
    
    /* Class applied by JavaScript to show the sidebar */
    #sidebar.open {
        transform: translateX(0);
    }

    /* Mobile Search Bar adjustment */
    .search-container {
        margin-left: 0;
    }
    
}