/* =========================================
   GLOBAL RESET & BASE STYLES
   ========================================= */
* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: sans-serif; 
}

body { 
    padding: 0 20px 20px 20px; 
    background-color: #ffffff; 
}

.container {
    width: 100%;
    padding: 0; 
}

/* =========================================
   HEADER & SEARCH LAYOUT
   ========================================= */
.main-header {
    display: flex;
    align-items: flex-start; 
    justify-content: space-between; 
    gap: 30px; 
    padding: 0 0 15px 0;
    width: 100%;
    margin-top: 0;
    min-height: 130px; 
    box-sizing: border-box;
}

.logo { 
    display: flex; 
    align-items: center;
    flex-shrink: 0; 
    min-width: 180px; 
}

.logo img {
    max-width: 300px; 
    width: 100%;      
    height: auto;     
}

.header-center-column {
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    gap: 15px;
    margin-top: 4px;
}

.top-banner-placeholder {
    width: 100%;
    height: 90px;
    display: flex;
    gap: 20px;
    justify-content: flex-start; 
    align-items: center;
    background: transparent; 
    border: none; 
}

.top-banner-placeholder img {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.search-form {
    display: flex;
    gap: 5px;
    width: 100%;
}

.search-form input {
    padding: 12px 15px;
    border: 1px solid #ccc;
    border-radius: 4px;
    flex-grow: 1; 
    font-size: 16px;
}

.search-form input:focus {
    border-color: #003366;
    outline: none;
}

.search-form button {
    padding: 12px 25px;
    background: #003366;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    transition: background-color 0.2s;
}

.search-form button:hover {
    background: #002244;
}

/* =========================================
   NAVIGATION & CATEGORY PILLS
   ========================================= */
.main-nav {
    display: flex;
    justify-content: space-between; 
    align-items: center; 
    padding-top: 0; 
    padding-bottom: 0; 
    margin-top: 5px; 
    margin-bottom: 25px !important;
}

.nav-categories {
    display: flex;
    flex-wrap: wrap; 
    gap: 10px;
}

.nav-pill {
    background-color: #f4f4f4;
    color: #333;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s;
    border: 1px solid #ddd;
}

.nav-pill:hover {
    background-color: #e0e0e0;
}

.nav-user-actions {
    width: 220px; 
    flex-shrink: 0; 
    display: flex; 
    flex-direction: column; 
    gap: 6px; 
    align-items: stretch; 
    justify-content: center; 
    margin-top: 15px; 
    box-sizing: border-box;
}

/* =========================================
   MAIN GRID LAYOUT & CARDS
   ========================================= */
.main-layout {
    display: grid;
    grid-template-columns: 200px 1fr 200px;
    gap: 10px;
}

.product-grid > div {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 10px 10px;
    width: 100%;
}

.card {
    border: 1px solid #e0e0e0; 
    background: #fff;
    display: flex;
    flex-direction: column;
    border-radius: 8px; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05); 
    overflow: hidden; 
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    text-decoration: none; 
}

.card:hover {
    transform: translateY(-4px); 
    box-shadow: 0 6px 12px rgba(0,0,0,0.1);
}

.card-img {
    width: 100%;
    height: 180px;
    object-fit: contain; 
    background-color: transparent; 
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
}

.card-content {
    padding: 15px;
    min-width: 0;
}

.card-title {
    font-size: 14px; 
    color: #333;
    margin-bottom: 8px;
    line-height: 1.4;
    font-weight: bold;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.card-price {
    font-size: 18px;
    font-weight: bold;
    color: #003366;
}

.card-category {
    font-size: 12px;
    color: #888;
    margin-top: 10px;
}

/* GLOBALIZED AD STYLES: Running outside query caps to secure formatting rules on desktop views */
.ad-card {
    width: 100%;
    margin-bottom: 15px;
    background-color: transparent; 
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none; 
}

.ad-card img {
    width: 100% !important;
    height: auto !important;
    max-height: 100%;
    object-fit: contain !important; /* Forces full image to scale down safely inside column */
    display: block;
    background: transparent;
}

/* =========================================
   SIDEBAR MENU & FORMS
   ========================================= */
.sidebar-menu {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 20px;
    height: fit-content; 
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.sidebar-menu h3 {
    margin-bottom: 15px;
    font-size: 16px;
    color: #003366;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.sidebar-menu ul {
    list-style: none; 
    padding: 0;
}

.sidebar-menu li {
    margin-bottom: 12px;
}

.sidebar-menu a {
    text-decoration: none;
    color: #555;
    font-size: 14px;
    transition: color 0.2s ease;
}

.sidebar-menu a:hover {
    color: #003366;
    font-weight: bold;
}

.form-container {
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.form-container h2 {
    margin-bottom: 20px;
    color: #003366;
    border-bottom: 2px solid #eee;
    padding-bottom: 10px;
}

.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

.form-group label {
    margin-bottom: 8px;
    font-weight: bold;
    color: #333;
    font-size: 14px;
}

.form-group input, 
.form-group select, 
.form-group textarea {
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
    font-family: inherit;
}

.form-group input:focus, 
.form-group select:focus, 
.form-group textarea:focus {
    border-color: #003366;
    outline: none;
}

.btn-submit {
    background-color: #003366;
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    width: 100%;
    transition: background-color 0.2s;
}

.btn-submit:hover {
    background-color: #002244;
}

/* =========================================
   DETAILED LISTING PAGE LAYOUT
   ========================================= */
.listing-page-layout {
    grid-template-columns: 1fr 1fr; 
    gap: 40px;
    background: #fff;
    padding: 30px;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.listing-image-container {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

.main-product-img {
    width: 100%;
    max-height: 500px;
    object-fit: contain; 
    border-radius: 6px;
    background-color: #f9f9f9;
    border: 1px solid #eee;
}

.no-image-placeholder {
    width: 100%;
    height: 350px;
    background: #f4f4f4;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #aaa;
    border-radius: 6px;
}

.listing-details-container {
    display: flex;
    flex-direction: column;
}

.detail-category-badge {
    align-self: flex-start;
    background-color: #f0f0f0;
    color: #666;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 4px;
    margin-bottom: 12px;
    text-transform: uppercase;
    font-weight: bold;
    border: 1px solid #ddd;
}

.detail-title {
    font-size: 28px;
    color: #333;
    margin-bottom: 15px;
    line-height: 1.2;
}

.detail-price {
    font-size: 32px;
    font-weight: bold;
    color: #003366;
    margin-bottom: 20px;
}

.seller-info {
    font-size: 13px;
    color: #777;
    border-bottom: 1px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.detail-description-box h3 {
    font-size: 16px;
    color: #333;
    margin-bottom: 10px;
}

.detail-description-box p {
    font-size: 15px;
    color: #555;
    line-height: 1.6;
    margin-bottom: 30px;
}

.btn-contact {
    display: block;
    text-align: center;
    background-color: #003366;
    color: white;
    text-decoration: none;
    padding: 15px;
    font-size: 16px;
    font-weight: bold;
    border-radius: 4px;
    transition: background-color 0.2s;
    margin-top: auto; 
}

.btn-contact:hover {
    background-color: #002244;
}

/* =========================================
   MOBILE RESPONSIVENESS (MEDIA QUERIES) 
   ========================================= */

/* Tablet / Mid-Sized Desktop Screens */
@media (max-width: 1100px) {
    .product-grid > div {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 768px) {
    .listing-page-layout {
        grid-template-columns: 1fr; 
        gap: 20px;
    }
}

@media (max-width: 900px) {
    .main-layout {
        grid-template-columns: 1fr;
    }
    
    .left-ads, .right-ads {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        margin-bottom: 20px;
    }

    .sponsors-title {
        grid-column: 1 / -1;
    }
}

/* Phones */
@media (max-width: 600px) {
    .main-header {
        flex-direction: column;
        align-items: center; 
        gap: 15px;
    }
    
    .search-bar { width: 100%; }

    nav {
        flex-wrap: wrap; 
        justify-content: center; 
        gap: 8px; 
        padding-bottom: 15px;
    }
    
    nav a {
        font-size: 13px;
        padding: 6px 14px;
    }

    .product-grid > div {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Very Small Phones */
@media (max-width: 400px) {
    .product-grid > div { 
        grid-template-columns: 1fr !important; 
    }
    .left-ads, .right-ads { 
        grid-template-columns: 1fr; 
    }
}

/* =========================================
   FOOTER STYLES (Upgraded Layout)
   ========================================= */
.main-footer {
    background-color: #002244; 
    color: #ffffff;
    margin-top: 50px;
    padding-top: 40px;
    border-top: 4px solid #cc0000; 
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr; 
    gap: 40px;
}

.footer-column:nth-child(2) {
    justify-self: center;
}

.footer-column:last-child {
    justify-self: end;
}

.footer-column h3 {
    font-size: 18px;
    margin-bottom: 20px;
    color: #f4f4f4;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.footer-column p {
    color: #cccccc;
    line-height: 1.6;
    font-size: 14px;
    max-width: 400px; 
}

.footer-column ul {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-column ul li {
    margin-bottom: 12px;
}

.footer-column ul li a {
    color: #cccccc;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s;
}

.footer-column ul li a:hover {
    color: #ffffff;
    text-decoration: underline;
}

@media (max-width: 768px) {
    .footer-container {
        grid-template-columns: 1fr;
    }
    
    .footer-column:nth-child(2),
    .footer-column:last-child {
        justify-self: start;
    }
}

.sponsors-title {
    text-align: center;
    font-size: 12px;
    text-transform: uppercase;
    color: #888888;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 5px;
}

.main-footer a {
    color: #ffffff; 
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease, opacity 0.2s ease;
}

.main-footer a:hover {
    color: #cccccc; 
    text-decoration: underline;
}

.footer-bottom a {
    color: #ffffff;
    font-weight: bold;
}