:root {
    --primary-color: #2c3e50;
    --accent-color: #3498db;
    --text-color: #333;
    --light-bg: #f8f9fa;
    --border-color: #dee2e6;
    --white: #ffffff;
    --shadow: 0 4px 6px rgba(0,0,0,0.1);
    --transition: all 0.3s ease;
}

/* Layout Structure */
.flanges-layout {
    display: flex;
    max-width: 1400px;
    margin: 40px auto;
    padding: 0 20px;
    gap: 40px;
}

/* Sidebar / TOC */
.flanges-sidebar {
    flex: 0 0 28%;
    max-width: 350px;
}

.toc-sticky {
    position: sticky;
    top: 100px;
    background: var(--white);
    padding: 25px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.toc-sticky h3 {
    margin-top: 0;
    margin-bottom: 20px;
    font-size: 1.2rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--accent-color);
    padding-bottom: 10px;
}

.toc-menu {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: calc(100vh - 200px);
    overflow-y: auto;
}

.toc-menu li {
    margin-bottom: 8px;
}

.toc-menu a {
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.95rem;
    display: block;
    padding: 8px 12px;
    border-radius: 4px;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.toc-menu a:hover {
    background: var(--light-bg);
    color: var(--accent-color);
}

.toc-menu a.active {
    background: var(--light-bg);
    color: var(--accent-color);
    border-left-color: var(--accent-color);
    font-weight: 600;
}

/* Main Content Area */
.flanges-content {
    flex: 1;
    min-width: 0; /* Prevents flex items from overflowing */
}

/* Product Cards */
.product-card-block {
    background: var(--white);
    border-radius: 8px;
    padding: 30px;
    margin-bottom: 40px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

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

.product-card-block h2, 
.product-card-block h3 {
    color: var(--primary-color);
    margin-top: 0;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

/* Fastener List Styling */
.fastener-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.fastener-item {
    background: var(--light-bg);
    padding: 10px 15px;
    border-radius: 4px;
    text-decoration: none;
    color: var(--text-color);
    font-size: 0.9rem;
    border: 1px solid var(--border-color);
    transition: var(--transition);
    text-align: center;
}

.fastener-item:hover {
    background: var(--accent-color);
    color: var(--white);
    border-color: var(--accent-color);
}

/* Specs Grid */
.specs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.spec-item {
    background: var(--light-bg);
    padding: 20px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
}

.spec-item h4 {
    margin-top: 0;
    color: var(--accent-color);
    font-size: 1rem;
    margin-bottom: 10px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .flanges-layout {
        flex-direction: column;
    }
    
    .flanges-sidebar {
        width: 100%;
        max-width: none;
        flex: none;
    }
    
    .toc-sticky {
        position: relative;
        top: 0;
        margin-bottom: 30px;
    }
    
    .toc-menu {
        max-height: 200px;
    }
}

@media (max-width: 768px) {
    .toc-sticky {
        padding: 15px;
    }
    
    .toc-menu {
        display: none; /* Hide by default on small screens */
    }
    
    .toc-sticky.active .toc-menu {
        display: block;
        margin-top: 15px;
    }
    
    .toc-toggle {
        display: flex;
        justify-content: space-between;
        align-items: center;
        cursor: pointer;
    }
    
    .toc-toggle::after {
        content: '\f078';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        transition: transform 0.3s;
    }
    
    .toc-sticky.active .toc-toggle::after {
        transform: rotate(180deg);
    }
}

/* TOC Toggle (hidden on desktop) */
.toc-toggle {
    display: none;
    font-weight: bold;
    color: var(--primary-color);
}
/* Applications Grid */
.applications-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.application-item {
    background: var(--light-bg);
    padding: 20px;
    border-radius: 6px;
    border-left: 4px solid var(--accent-color);
    transition: var(--transition);
}

.application-item:hover {
    transform: translateX(5px);
    box-shadow: var(--shadow);
}

.application-item h4 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1rem;
}

.application-item p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-color);
}

/* Flange Types Grid */
.flange-types-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 12px;
}

.flange-type {
    background: var(--accent-color);
    color: var(--white);
    padding: 12px 15px;
    border-radius: 4px;
    text-align: center;
    font-size: 0.9rem;
    font-weight: 500;
    transition: var(--transition);
    cursor: default;
}

.flange-type:hover {
    background: #2980ba;
    transform: translateY(-2px);
}

/* CTA Section */
.cta-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: var(--white);
    text-align: center;
}

.cta-section h3,
.cta-section p {
    color: var(--white);
}

.cta-buttons {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin: 25px 0;
    flex-wrap: wrap;
}

.cta-button {
    display: inline-block;
    padding: 12px 30px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    font-size: 1rem;
    transition: var(--transition);
    cursor: pointer;
    border: 2px solid transparent;
}

.cta-button.primary {
    background: var(--white);
    color: var(--primary-color);
}

.cta-button.primary:hover {
    background: transparent;
    color: var(--white);
    border-color: var(--white);
}

.cta-button.secondary {
    background: transparent;
    color: var(--white);
    border-color: var(--white);
}

.cta-button.secondary:hover {
    background: var(--white);
    color: var(--accent-color);
    border-color: var(--white);
}

.contact-info {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid rgba(255,255,255,0.3);
}

.contact-info p {
    margin: 8px 0;
    font-size: 0.95rem;
}

/* Related Products Section */
.related-products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
}

.related-product-card {
    background: var(--light-bg);
    padding: 20px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-color);
    transition: var(--transition);
    display: block;
}

.related-product-card:hover {
    background: var(--white);
    box-shadow: var(--shadow);
    border-color: var(--accent-color);
    transform: translateY(-5px);
}

.related-product-card h4 {
    color: var(--accent-color);
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1rem;
}

.related-product-card p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-color);
}