/* Kartal Makina Product Plugin Styles - Industrial Black/Yellow Theme */

/* ==================== Layout & Typography ==================== */
:root {
    /* Industrial Palette */
    --km-primary: #FACD05;
    /* Vivid Industrial Yellow */
    --km-primary-dark: #eab308;
    /* Darker yellow for hover */
    --km-accent: #111827;
    /* Deep Black/Charcoal */
    --km-text-main: #1f2937;
    --km-text-muted: #4b5563;
    --km-border: #e5e7eb;
    --km-bg-main: #ffffff;
    --km-bg-light: #f9fafb;
    --km-bg-dark: #111827;

    --km-radius: 4px;
    /* Sharper corners for industrial look */
    --km-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --km-shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    --km-font-sans: 'Inter', system-ui, -apple-system, sans-serif;
}

/* Wrapper */
.km-products-wrapper {
    display: flex;
    gap: 40px;
    margin-bottom: 60px;
    position: relative;
    font-family: var(--km-font-sans);
}

/* ==================== Sidebar (Black & Yellow) ==================== */
.km-category-sidebar {
    flex: 0 0 280px;
    position: sticky;
    top: 30px;
    align-self: flex-start;
    max-height: calc(100vh - 60px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--km-primary) var(--km-accent);
    padding-right: 4px;
}

/* Custom Scrollbar */
.km-category-sidebar::-webkit-scrollbar {
    width: 6px;
}

.km-category-sidebar::-webkit-scrollbar-track {
    background: var(--km-accent);
}

.km-category-sidebar::-webkit-scrollbar-thumb {
    background-color: var(--km-primary);
    border-radius: 0;
}

.km-category-sidebar-inner {
    background: var(--km-bg-main);
    border: 1px solid var(--km-border);
    border-top: 4px solid var(--km-primary);
    /* Yellow accent top */
    border-radius: var(--km-radius);
    padding: 0;
    box-shadow: var(--km-shadow);
    overflow: hidden;
}

.km-category-title {
    background-color: var(--km-accent);
    color: #ffffff;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
    padding: 20px 24px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    display: flex;
    align-items: center;
}

.km-category-title::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background: var(--km-primary);
    margin-right: 12px;
    transform: rotate(45deg);
    /* Diamond shape */
}

/* Main List */
.km-category-list {
    list-style: none;
    margin: 0;
    padding: 12px 0;
}

.km-category-list li {
    margin: 0;
}

/* Category Filter Item */
.km-category-filter {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    /* Override space-between */
    padding: 12px 24px !important;
    text-decoration: none !important;
    color: var(--km-text-main) !important;
    font-size: 0.95rem;
    font-weight: 600;
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
    box-shadow: none !important;
}

.km-category-filter:hover {
    background-color: var(--km-bg-light) !important;
    color: #000 !important;
    border-left-color: var(--km-primary) !important;
    text-decoration: none !important;
}

.km-category-filter.active {
    background-color: var(--km-accent) !important;
    color: var(--km-primary) !important;
    /* Yellow text on black */
    border-left-color: var(--km-primary) !important;
}

.km-category-name {
    flex: 1;
    margin-right: 12px;
    line-height: 1.3;
    display: block;
    /* Ensure it behaves as block for width calc */
}

.km-category-count {
    flex-shrink: 0;
    font-size: 0.75rem;
    padding: 2px 8px;
    background-color: #e5e7eb;
    color: var(--km-text-muted);
    border-radius: 2px;
    font-weight: 700;
    display: inline-block !important;
    /* Ensure visibility */
}

.km-category-filter.active .km-category-count {
    background-color: var(--km-primary) !important;
    color: var(--km-accent) !important;
}

/* Subcategories Tree */
.km-category-sublist {
    list-style: none;
    margin: 0;
    padding: 0;
    background-color: #FAFAFA;
    border-top: 1px solid #eee;
    border-bottom: 1px solid #eee;
}

.km-category-child .km-category-filter {
    padding: 10px 24px 10px 40px !important;
    font-size: 0.9rem;
    color: var(--km-text-muted) !important;
    font-weight: 500;
    border-left: 3px solid transparent;
}

.km-category-child .km-category-filter::before {
    content: "■";
    position: absolute;
    left: 24px;
    color: var(--km-primary);
    font-size: 0.6rem;
    opacity: 0.5;
}

.km-category-child .km-category-filter:hover {
    background-color: #ededed !important;
    color: #000 !important;
    padding-left: 45px !important;
}

.km-category-child .km-category-filter.active {
    background-color: #e5e5e5 !important;
    color: #000 !important;
    border-left-color: transparent !important;
    /* No left border for children, keep it clean */
}

/* ==================== Product Grid ==================== */
.km-product-grid-container {
    flex: 1;
    min-width: 0;
}

.km-product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 24px;
}

.km-product-item {
    background: var(--km-bg-main);
    border: 1px solid var(--km-border);
    border-radius: var(--km-radius);
    padding: 0;
    /* Remove padding to let image fill header */
    transition: all 0.3s ease;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Industrial corner accent */
.km-product-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    right: 0;
    width: 0;
    height: 0;
    border-style: solid;
    border-width: 0 0 20px 20px;
    border-color: transparent transparent var(--km-primary) transparent;
    opacity: 0;
    transition: opacity 0.3s;
}

.km-product-item:hover {
    transform: translateY(-5px);
    box-shadow: var(--km-shadow-hover);
    border-color: var(--km-primary);
}

.km-product-item:hover::after {
    opacity: 1;
}

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

.km-product-image {
    aspect-ratio: 4/3;
    background: #ffffff;
    border-bottom: 2px solid var(--km-primary);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.km-product-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transition: transform 0.4s ease;
}

.km-product-item:hover .km-product-image img {
    transform: scale(1.1);
}

.km-product-content {
    padding: 24px !important;
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100% !important;
    box-sizing: border-box !important;
    align-items: flex-start !important;
}

/* High specificity override for theme conflicts */
.km-product-item .km-product-link .km-product-content {
    padding: 24px !important;
}

.km-product-grid .km-product-item .km-product-content {
    padding: 24px !important;
}

.km-product-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--km-accent);
    margin: 0 0 12px 0 !important;
    line-height: 1.3;
    text-transform: uppercase;
    width: 100%;
    text-align: left !important;
}

/* High specificity override for theme conflicts */
.km-product-item .km-product-link .km-product-content .km-product-title {
    margin: 0 0 12px 0 !important;
    padding: 0 !important;
}

.km-product-grid .km-product-item .km-product-title {
    margin: 0 0 12px 0 !important;
}

.km-product-meta {
    margin-top: auto;
    font-size: 0.85rem;
    color: var(--km-text-main);
    background: #f3f4f6;
    padding: 8px 12px;
    border-left: 3px solid var(--km-primary);
    font-family: monospace;
    width: 100%;
    /* Force width */
    box-sizing: border-box;
    /* Include padding in width */
}

/* ==================== Single Product Details ==================== */
.km-product-details {
    margin-bottom: 30px;
    background: #ffffff;
    padding: 0;
    border: 1px solid var(--km-border);
    border-top: 3px solid var(--km-primary);
    border-radius: var(--km-radius);
    box-shadow: var(--km-shadow);
}

.km-product-table th {
    background-color: var(--km-accent);
    color: #ffffff;
    /* White text on black header */
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid #333;
}

.km-product-table td {
    border-bottom: 1px solid #eee;
    color: #333;
    font-weight: 500;
}

.km-product-table tr:hover td {
    background-color: #fffbeb;
    /* Very light yellow hover */
}

/* ==================== Responsive ==================== */
@media screen and (max-width: 900px) {
    .km-products-wrapper {
        flex-direction: column;
        gap: 20px;
    }

    .km-category-sidebar {
        flex: none;
        width: 100%;
        position: static;
        max-height: none;
    }

    .km-category-title {
        border-radius: var(--km-radius) var(--km-radius) 0 0;
    }
}

/* ==================== Single Product Page overrides ==================== */
/* Hide standard theme featured images to prevent duplication */
.single-km_product .post-thumbnail,
.single-km_product .entry-header img,
.single-km_product .featured-image,
.single-km_product .wp-post-image:not(.km-single-image img),
.single-km_product .page-header-image {
    display: none !important;
}

/* ==================== Single Product Page ==================== */
.km-single-product-wrapper {
    display: flex;
    flex-wrap: wrap;
    gap: 40px;
    margin-top: 20px;
    background: #fff;
    padding: 30px;
    border-radius: var(--km-radius);
    border: 1px solid var(--km-border);
    box-shadow: var(--km-shadow);
}

.km-single-left {
    flex: 1 1 400px;
    /* Minimum width before wrapping */
}

.km-single-right {
    flex: 1 1 400px;
}

/* Single Image */
.km-single-image {
    border: 1px solid var(--km-border);
    border-radius: var(--km-radius);
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.05);
}

.km-single-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.km-single-image:hover img {
    transform: scale(1.05);
}

/* Single Content */
.km-single-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--km-accent);
    margin: 0 0 20px 0;
    line-height: 1.2;
    text-transform: uppercase;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--km-primary);
}

.km-single-meta-badge {
    display: inline-flex;
    align-items: center;
    background: var(--km-accent);
    color: #fff;
    padding: 8px 16px;
    border-radius: 4px;
    margin-bottom: 30px;
    font-family: monospace;
    font-size: 1.1rem;
}

.km-single-meta-badge .km-label {
    color: var(--km-primary);
    margin-right: 10px;
    font-weight: 700;
}

.km-single-meta-badge .km-value {
    color: #fff;
    font-weight: 500;
}

/* Specs Table */
.km-specs-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--km-text-main);
    display: flex;
    align-items: center;
}

.km-specs-title::before {
    content: '';
    display: inline-block;
    width: 6px;
    height: 20px;
    background: var(--km-primary);
    margin-right: 10px;
}

.km-specs-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 30px;
    font-size: 0.95rem;
}

.km-specs-table th,
.km-specs-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid #eee;
}

.km-specs-table th {
    width: 40%;
    background-color: var(--km-bg-light);
    color: var(--km-accent);
    font-weight: 600;
}

.km-specs-table td {
    color: var(--km-text-muted);
}

.km-specs-table tr:last-child th,
.km-specs-table tr:last-child td {
    border-bottom: none;
}

/* Description Box */
.km-single-description-box {
    color: var(--km-text-main);
    line-height: 1.6;
    background: var(--km-bg-light);
    padding: 24px;
    border-radius: 8px;
    border-left: 4px solid var(--km-border);
}

/* Responsive for Single Page */
@media screen and (max-width: 768px) {
    .km-single-product-wrapper {
        flex-direction: column;
        padding: 20px;
    }

    .km-single-title {
        font-size: 1.5rem;
    }
}

/* ==================== Category Grid Shortcode ==================== */
.km-category-grid-wrapper {
    margin: 40px 0;
    width: 100%;
}

.km-category-grid {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    /* Force 3 columns */
    gap: 30px !important;
    width: 100% !important;
    box-sizing: border-box !important;
}

.km-category-card {
    display: flex !important;
    flex-direction: column !important;
    background: #fff;
    border: 1px solid var(--km-border);
    border-radius: var(--km-radius);
    overflow: hidden;
    text-decoration: none !important;
    transition: all 0.3s ease;
    box-shadow: var(--km-shadow);
    height: 100%;
    /* Equal height */
    position: relative;
    border-top: 5px solid var(--km-primary);
    /* Industrial accent */
}

/* Ensure no theme overrides break the layout */
.km-category-grid>* {
    width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.km-category-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--km-shadow-hover);
    border-color: var(--km-accent);
    /* Dark border on hover */
}

.km-category-card-image {
    aspect-ratio: 16/9;
    background: #f9fafb;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--km-border);
    width: 100%;
}

.km-category-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover !important;
    /* Looks better for tiles */
    transition: transform 0.5s ease;
    display: block !important;
}

.km-category-card:hover .km-category-card-image img {
    transform: scale(1.1);
}

.km-category-card-content {
    padding: 20px;
    text-align: center;
    background: #fff;
    position: relative;
    flex: 1;
    /* Push footer down if we had one */
}

.km-category-card-title {
    font-size: 1.25rem;
    font-weight: 800;
    margin: 0 !important;
    color: var(--km-accent);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.3s ease;
    line-height: 1.2 !important;
}

.km-category-card:hover .km-category-card-title {
    color: var(--km-primary-dark);
}

/* Responsive */
@media (max-width: 900px) {
    .km-category-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 600px) {
    .km-category-grid {
        grid-template-columns: 1fr !important;
    }
}

/* ==================== Search Bar ==================== */
.km-search-wrapper {
    margin: 0 0 30px 0;
    width: 100%;
    box-sizing: border-box;
}

.km-product-search-form {
    width: 100%;
}

.km-search-input-group {
    display: flex;
    width: 100%;
    position: relative;
    box-shadow: var(--km-shadow);
    border-radius: var(--km-radius);
    overflow: hidden;
    border: 1px solid var(--km-border);
}

.km-search-field {
    flex: 1;
    padding: 15px 20px;
    border: none;
    background: #fff;
    font-size: 1rem;
    color: var(--km-text-main);
    outline: none;
}

.km-search-field:focus {
    background: #fff;
}

.km-search-submit {
    background-color: var(--km-accent);
    color: #fff;
    border: none;
    padding: 0 25px;
    font-weight: 700;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.km-search-submit:hover {
    background-color: var(--km-primary);
    color: var(--km-accent);
}

.km-search-submit .dashicons {
    font-size: 1.2rem;
    width: 20px;
    height: 20px;
}

/* Search Results UI */
.km-search-results-label {
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--km-border);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--km-text-main);
    display: flex;
    align-items: center;
    gap: 10px;
}

.km-search-count {
    background: var(--km-primary);
    color: var(--km-accent);
    font-size: 0.8rem;
    padding: 2px 8px;
    border-radius: 10px;
}

.km-clear-search {
    margin-left: auto;
    font-size: 0.9rem;
    color: red;
    text-decoration: underline;
}

/* ==================== Footer List Layout ==================== */
.km-category-footer-list {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

.km-category-footer-list li {
    margin-bottom: 8px !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 8px;
}

.km-category-footer-list li:last-child {
    border-bottom: none;
}

.km-category-footer-list a {
    color: #ccc !important;
    /* Default footer text color usually */
    text-decoration: none !important;
    font-size: 0.95rem;
    transition: all 0.2s ease;
    display: flex !important;
    align-items: center;
    gap: 5px;
}

.km-category-footer-list a:hover {
    color: var(--km-primary) !important;
    transform: translateX(5px);
}

.km-category-footer-list .dashicons {
    color: var(--km-primary);
}