/* Global Styles */
:root {
    --primary-color: #ff9900;
    --secondary-color: #146eb4;
    --background-color: #f8f8f8;
    --text-color: #333;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--background-color);
}

.container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

a {
    color: var(--secondary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Header Styles - body > header = site banner only; .post-header in blog is not affected */
body > header {
    background: linear-gradient(135deg, var(--secondary-color), #003366);
    color: white;
    padding: 2rem 0;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.header-brand {
    text-align: left;
}

.header-tagline {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem 1rem;
}

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

.header-nav::before {
    content: "·";
    opacity: 0.8;
}

.header-nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    opacity: 0.95;
    transition: var(--transition);
}

.header-nav a:hover {
    opacity: 1;
    text-decoration: none;
}

.header-nav a.active {
    opacity: 1;
    text-decoration: underline;
}

.header-logo {
    color: white;
    text-decoration: none;
}

.header-logo:hover {
    text-decoration: none;
    opacity: 0.95;
}

body > header h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.header-brand p {
    font-size: 1.2rem;
    opacity: 0.9;
}

.header-ad {
    flex-shrink: 0;
}

/* Search Section */
.search-section {
    background-color: white;
    padding: 1.5rem 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.search-container {
    display: flex;
    max-width: 600px;
    margin: 0 auto 1rem;
}

#search-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #ddd;
    border-radius: 4px 0 0 4px;
    font-size: 1rem;
}

#search-button {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 0 20px;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transition: var(--transition);
}

#search-button:hover {
    background-color: #e68a00;
}

.category-filters {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 1rem;
}

.category-btn {
    background-color: #eee;
    border: none;
    padding: 8px 15px;
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.9rem;
}

.category-btn:hover {
    background-color: #ddd;
}

.category-btn.active {
    background-color: var(--secondary-color);
    color: white;
}

/* Products Grid */
main {
    padding: 2rem 0;
}

.main-with-sidebar {
    display: flex;
    align-items: flex-start;
    gap: 1.5rem;
}

.main-content {
    flex: 1;
    min-width: 0;
}

.sidebar-ad {
    flex-shrink: 0;
    width: 160px;
    position: sticky;
    top: 6rem;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 25px;
    margin-top: 1rem;
}

.product-card {
    background-color: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.product-image {
    height: 200px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #f5f5f5;
}

.product-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.product-details {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.product-price {
    color: var(--primary-color);
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 10px;
}

.product-rating {
    display: flex;
    align-items: center;
    margin-bottom: 15px;
}

.stars {
    color: #ffc107;
    margin-right: 5px;
}

.review-count {
    color: #777;
    font-size: 0.9rem;
}

.product-category {
    font-size: 0.8rem;
    color: #666;
    background-color: #f0f0f0;
    padding: 3px 8px;
    border-radius: 12px;
    display: inline-block;
    margin-bottom: 10px;
}

.product-link {
    margin-top: auto;
    background-color: var(--primary-color);
    color: white;
    text-align: center;
    padding: 10px;
    border-radius: 4px;
    font-weight: 500;
    transition: var(--transition);
}

.product-link:hover {
    background-color: #e68a00;
    text-decoration: none;
}

/* Loading Spinner */
.loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 0;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error Message */
.error-message {
    background-color: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 4px;
    margin: 1rem 0;
    display: none;
}

/* API Info Section */
.api-info {
    background-color: white;
    padding: 2rem 0;
    margin-top: 2rem;
    border-top: 1px solid #eee;
}

.api-info h2 {
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

.api-info ol {
    margin: 1rem 0 1rem 1.5rem;
}

.api-info li {
    margin-bottom: 0.5rem;
}

/* Blog */
.blog-main {
    padding: 2rem 0;
}

.blog-posts {
    max-width: 720px;
    margin: 0 auto;
}

.blog-article {
    background-color: white;
    padding: 2.5rem;
    border-radius: 8px;
    box-shadow: var(--card-shadow);
    margin-bottom: 2rem;
}

.blog-article:last-child {
    margin-bottom: 0;
}

.post-header {
    margin: 0 0 2rem 0;
    padding: 1.25rem 1.5rem;
    border-radius: 8px;
    border-bottom: 1px solid #e0e0e0;
    background: transparent;
}

.post-header h2 {
    color: var(--text-color);
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.3;
    margin: 0 0 1rem 0;
    display: block;
}

.post-meta {
    display: block;
    font-size: 0.875rem;
    color: #666;
    margin: 0;
    padding: 0;
    font-weight: 500;
}

.post-meta i {
    color: #666;
    margin-right: 0.4rem;
}


.post-content p {
    margin-bottom: 1rem;
}

.post-content p:last-child {
    margin-bottom: 0;
}

/* Footer */
footer {
    background-color: #333;
    color: white;
    padding: 1.5rem 0;
    text-align: center;
    margin-top: 2rem;
}

/* Responsive Styles */
@media (max-width: 1024px) {
    .sidebar-ad {
        display: none;
    }
}

@media (max-width: 768px) {
    .header-inner {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .header-brand {
        text-align: center;
    }

    header h1 {
        font-size: 2rem;
    }
    
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
}

@media (max-width: 480px) {
    .category-filters {
        flex-wrap: nowrap;
        overflow-x: auto;
        padding-bottom: 10px;
        justify-content: flex-start;
    }
    
    .category-btn {
        flex: 0 0 auto;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
    }
}
