/* app/static/css/products.css */
/* SAMMANSLAGNA VERSION - Både layout och styling för produktlistor */
/* För /produkter (listor, kategorisidor, sökresultat) */

:root {
    --primary-color: #007533;
    --secondary-color: #f8f8f8;
    --text-color: #333;
    --text-light: #666;
    --border-color: #e0e0e0;
    --badge-color: #e74c3c;
    --hover-color: #006a33;
    --card-bg: #ffffff;
    --light-bg: #f8f8f8;
    --shadow-sm: 1px 2px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 2px 3px 3px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s ease;
}

/* ========================================
   LAYOUT - Grid structure
   ======================================== */

.product-layout {
    display: grid;
    grid-template-columns: 240px 1fr;
    gap: 30px;
    margin: 0px 0;
    align-items: start;
}

.product-main-content {
    min-width: 0; /* Fix for grid overflow */
    background-color: #ffffff;
}

/* ========================================
   BREADCRUMB
   ======================================== */

.breadcrumb {
    background-color: #ffffff;
    padding: 0px 0;
    max-width: 1200px;
    padding:10px 10px 10px;
    margin: 0 auto;
}

.breadcrumb a {
    color: var(--text-color);
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: color 0.2s;
}

.breadcrumb a:hover {
    color: var(--primary-color);
}

.breadcrumb a.active {
    color: var(--primary-color);
}

.breadcrumb .separator {
    margin: 0 8px;
    color: var(--text-light);
}

/* ========================================
   PAGE HEADER
   ======================================== */

.product-list-header {
    margin-bottom: 10px;
}

.product-list-header h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 10px 0;
}

.search-results-info {
    background-color: var(--light-bg);
    padding: 12px 16px;
    border-radius: 6px;
    margin-top: 15px;
}

.search-results-info p {
    margin: 0;
    color: var(--text-light);
    font-size: 14px;
}

.result-count {
    color: var(--text-light);
    font-size: 14px;
}

/* ========================================
   SIDEBAR (Desktop)
   ======================================== */

.sidebar {
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--secondary-color);
}

.sidebar::-webkit-scrollbar {
    width: 6px;
}

.sidebar::-webkit-scrollbar-track {
    background: var(--secondary-color);
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

/* Search Box in Sidebar */
.search-box {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
}

.search-box h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.search-box .form-group {
    margin-bottom: 12px;
}

.search-box input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    transition: var(--transition);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 140, 69, 0.1);
}

.btn-search {
    width: 100%;
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.btn-search:hover {
    background-color: var(--hover-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

/* Category Tree in Sidebar */
.category-tree {
    background-color: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
}

.category-tree h3 {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.category-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.category-item {
    margin-bottom: 2px;
}

.category-list > .category-item > a {
    display: block;
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-color);
    text-decoration: none;
    border-radius: 6px;
    transition: var(--transition);
    font-weight: 500;
}

.category-list > .category-item > a:hover,
.category-list > .category-item > a.active {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

.subcategory-list {
    list-style: none;
    padding-left: 16px;
    margin: 8px 0;
    display: none;
}

.category-item.active > .subcategory-list,
.category-item.expanded > .subcategory-list {
    display: block;
}

.subcategory-list a {
    display: block;
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-light);
    text-decoration: none;
    border-radius: 6px;
    transition: var(--transition);
}

.subcategory-list a:hover,
.subcategory-list a.active {
    background-color: var(--secondary-color);
    color: var(--primary-color);
}

.sidebar-loading {
    padding: 20px;
    text-align: center;
    color: var(--text-light);
    font-size: 14px;
}

/* ========================================
   CATEGORY OVERVIEW SECTION
   ======================================== */

.category-overview-section {
    margin-bottom: 40px;
}

.category-overview-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 20px 0;
}

/* ========================================
   PRODUCTS SECTION
   ======================================== */

.products-section {
    margin-top: 10px;
}

.products-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border-color);
}

.products-section-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.product-count {
    color: var(--text-light);
    font-size: 14px;
}
 
/* ========================================
   PRODUCT GRID
   ======================================== */

.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 12px;
    margin-bottom: 40px;
}

/* ========================================
   PRODUCT CARD
   ======================================== */

.product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    background-color: var(--card-bg);
    border-radius: 6px;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
    border-color: #eeeeee;
    border-style: solid;
    border-width: 1px;    

}

.product-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
}

.product-link {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
    text-decoration: none;
}

/* Product Image - WHITE background */
.product-image {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    overflow: hidden;
}

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

.product-image picture {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.no-image {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background-color: var(--secondary-color);
    color: #999;
    font-size: 13px;
    font-style: italic;
}

/* Product Badges */
.product-badges {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    z-index: 10;
}

.product-badge {
    display: inline-block;
    color: white;
    font-size: 11px;
    padding: 5px 10px;
    border-radius: 3px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    text-align: center;
    min-width: 70px;
}

.badge-new {
    background: linear-gradient(135deg, #3459fa 0%, #0401da 100%);
}

.badge-sale {
    background: linear-gradient(135deg, #fa4242 0%, #fa0101 100%);
}

.product-badge {
    position: absolute;
    top: 20px;
    right: 20px;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: white;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.product-badge.inline {
    position: static;
    display: inline-block;
    margin-bottom: 15px;
}

.product-card:hover .product-badge {
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

/* Product Info */
.product-info {
    padding: 15px;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    background-color: #ffffff;
}

.product-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0 0 8px 0;
    line-height: 1.3;
    color: var(--text-color);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.6em;
}

.product-description {
    font-size: 14px;
    color: var(--text-light);
    margin-bottom: 10px;
    line-height: 1.4;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Product Meta */
.product-meta {
    font-size: 12px;
    color: var(--text-light);
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.product-meta-inline {
    display: flex;
    gap: 10px;
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.product-meta-inline .manufacturer-number {
    font-weight: 600;
    color: #333;
}

.product-meta-inline .internal-number {
    color: #999;
    font-size: 12px;
}

.article-number {
    display: block;
    margin-bottom: 4px;
    font-weight: 500;
}

.manufacturer-number {
    display: block;
    font-size: 11px;
    color: #999;
}

/* Stock Status */
.stock-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
/*    padding: 4px 8px; */
    border-radius: 4px;
}

.stock-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.stock-status.in-stock {
    color: #008035;

}
.stock-status.on-the-way {
    color: #c2bf00;
}
.stock-status.on-the-way .stock-indicator {
    background-color: #f39c12;
    box-shadow: 0 0 0 2px rgba(243, 156, 18, 0.2);
    animation: pulse-yellow 2s ease-in-out infinite;
}

@keyframes pulse-yellow {
    0%, 100% {
        box-shadow: 0 0 0 2px rgba(243, 156, 18, 0.2);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(243, 156, 18, 0.4);
    }
}
.stock-status.in-stock .stock-indicator {
    background-color: #27ae60;
    box-shadow: 0 0 0 2px rgba(39, 174, 96, 0.2);
}

.stock-status.out-of-stock {
    color: #bd1300;

}

.stock-status.out-of-stock .stock-indicator {
    background-color: #e74c3c;
    box-shadow: 0 0 0 2px rgba(231, 76, 60, 0.2);
}

/* ========================================
   NO RESULTS
   ======================================== */

.no-results {
    text-align: center;
    padding: 60px 20px;
    background-color: var(--light-bg);
    border-radius: 12px;
    margin-top: 40px;
}

.no-results svg {
    color: var(--text-light);
    margin-bottom: 20px;
}

.no-results h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 10px 0;
}

.no-results p {
    color: var(--text-light);
    margin: 0;
}

/* ========================================
   PAGINATION
   ======================================== */

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin-top: 40px;
    flex-wrap: wrap;
}

.pagination-link,
.pagination-current {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
}

.pagination-link {
    background-color: var(--card-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.pagination-link:hover {
    background-color: var(--secondary-color);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.pagination-current {
    background-color: var(--primary-color);
    color: white;
    border: 1px solid var(--primary-color);
}

.pagination-link.prev,
.pagination-link.next {
    padding: 0 16px;
}

.pagination-numbers {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    color: var(--text-light);
}

@media (min-width: 1200px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr);  /* Fast 5 kolumner på stora skärmar */
    }
}

@media (min-width: 992px) and (max-width: 1199px) {
    .product-grid {
        grid-template-columns: repeat(4, 1fr);  /* 4 kolumner på mellanska skärmar */
    }
}

/* ========================================
   RESPONSIVE - Tablet
   ======================================== */

@media (max-width: 992px) {
    .product-layout {
        grid-template-columns: 220px 1fr;
        gap: 13px;
    }
    
    .product-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
        gap: 12px;
        margin-bottom: 40px;
        justify-items: start;  
    }
    
    .sidebar {
        top: 80px;
    }
    
    .product-list-header h1 {
        font-size: 24px;
    }
}

@media (max-width: 991px) and (min-width: 768px) {
    .product-image {
        padding: 15px;
    }
    
    .product-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    }
}

/* ========================================
   RESPONSIVE - Mobile
   ======================================== */

@media (max-width: 768px) {
    .product-layout {
        grid-template-columns: 1fr;
        gap: 0;
    }
    
    .sidebar-navigation {
        display: none; /* Hidden on mobile, use mobile sidebar instead */
    }
    
    .sidebar {
        position: static;
        max-height: none;
        margin-bottom: 30px;
    }
    
    .breadcrumb {
        padding: 10px 0;
    }
    
    .breadcrumb a {
        font-size: 13px;
    }
    
    .product-list-header h1 {
        font-size: 22px;
    }
    
    .products-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    /* Mobile Sidebar Toggle */
    .sidebar-toggle {
        display: block;
        width: 100%;
        background-color: var(--primary-color);
        color: white;
        border: none;
        padding: 12px 16px;
        border-radius: 8px;
        font-size: 14px;
        font-weight: 500;
        margin-bottom: 15px;
        cursor: pointer;
        text-align: left;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .sidebar-content {
        display: none;
    }
    
    .sidebar-content.active {
        display: block;
    }
    
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 12px;
    }
    
    .product-image {
        padding: 8px;
        aspect-ratio: 1 / 1;
    }
    
    .product-title {
        font-size: 14px;
    }
    
    .product-description {
        font-size: 14px;
    }
    
    .product-info {
        padding: 10px;
    }
    
    .product-meta {
        font-size: 11px;
    }
    
    .pagination {
        gap: 4px;
    }
    
    .pagination-link,
    .pagination-current {
        min-width: 36px;
        height: 36px;
        font-size: 13px;
    }
}

/* ========================================
   RESPONSIVE - Small Mobile
   ======================================== */

@media (max-width: 576px) {
    .product-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .product-card {
        max-width: 100%;
    }
    
    .product-image {
        padding: 8px;
    }
    
    .product-list-header h1 {
        font-size: 20px;
    }
    
    .breadcrumb {
        font-size: 12px;
    }
    
    .breadcrumb .separator {
        margin: 0 4px;
    }
}

@media (max-width: 480px) {
    .product-image {
        padding: 15px;
        aspect-ratio: 1 / 1;
    }
    
    .product-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus styles for keyboard navigation */
a:focus,
button:focus,
input:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .sidebar-navigation,
    .mobile-sidebar,
    .mobile-menu-toggle,
    .breadcrumb {
        display: none;
    }
    
    .product-layout {
        grid-template-columns: 1fr;
    }
}
.category-text-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin: 8px 0 10px 0;
}

/* ========================================
   CATEGORY TEXT BLOCK (Badge-Style)
   ======================================== */

.category-text-block {
    display: inline-block;
    padding: 6px 10px;
    background-color: white;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.2s ease;
    cursor: pointer;
    
    /* Flexibel bredd - anpassar sig efter innehåll */
    min-width: auto;
    max-width: 100%;
    
    /* Typography */
    font-size: 14px;
    font-weight: 500;
    line-height: 1.3;
    text-align: center;
    
    /* Prevents text selection issues */
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.category-text-name {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 250px; /* Förhindrar för långa namn */
}

/* Hover State */
.category-text-block:hover {
    background-color: var(--hover-bg);
    border-color: var(--hover-border);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 117, 51, 0.15);
}

/* Active/Pressed State (for mobile) */
.category-text-block:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(0, 117, 51, 0.2);
}

/* Focus State (keyboard navigation) */
.category-text-block:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* ========================================
   SECTION STYLING
   ======================================== */

.category-overview-section {
    margin-bottom: 20px;
}

.category-overview-section h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
    margin: 0 0 16px 0;
    padding-bottom: 4px;
    border-bottom: 2px solid var(--border-color);
}

/* ========================================
   RESPONSIVE - Tablet
   ======================================== */

@media (max-width: 992px) {
    .category-text-grid {
        gap: 10px;
    }
    
    .category-text-block {
        padding: 8px 14px;
        font-size: 14px;
    }
    
    .category-text-name {
        max-width: 200px;
    }
}

/* ========================================
   RESPONSIVE - Mobile
   ======================================== */

@media (max-width: 768px) {
    .category-text-grid {
        gap: 8px;
        margin: 8px 0 10px 0;
    }
    
    .category-text-block {
        padding: 8px 12px;
        font-size: 14px;
    }
    
    .category-text-name {
        max-width: 180px;
    }
    
    .category-overview-section h2 {
        font-size: 18px;
        margin-bottom: 12px;
        padding-bottom: 4px;
    }
}

/* ========================================
   RESPONSIVE - Small Mobile
   ======================================== */

@media (max-width: 576px) {
    .category-text-grid {
        gap: 8px;
    }
    
    .category-text-block {
        padding: 6px 10px;
        font-size: 14px;
    }
    
    .category-text-name {
        max-width: 150px;
    }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {
    .category-text-block {
        transition: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .category-text-block {
        border-width: 3px;
    }
    
    .category-text-block:hover {
        border-width: 3px;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .category-text-grid {
        display: none;
    }
}