/* ============================================
   GAMING KB RIGHT SIDEBAR STYLES - COMPREHENSIVE FIX
============================================ */

/* First, let's fix the main layout container to ensure sidebar has enough space */
.gamekb-article-layout {
    display: grid;
    grid-template-columns: 1fr 350px; /* Fixed width for sidebar instead of percentage */
    gap: 30px; /* Reduced from 40px */
}

/* Main Sidebar Container - Now with fixed width */
.gamekb-article-sidebar {
    background: #f5f5f7;
    border-radius: 8px;
    padding: 0;
    margin-top: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    width: 350px; /* Fixed width to match grid */
    box-sizing: border-box;
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f5f5f7;
}

/* Reset inner elements to fit within fixed width */
.gamekb-article-sidebar * {
    max-width: 100%;
    box-sizing: border-box;
}

.gamekb-article-sidebar::-webkit-scrollbar {
    width: 6px;
}

.gamekb-article-sidebar::-webkit-scrollbar-track {
    background: #f5f5f7;
    border-radius: 3px;
}

.gamekb-article-sidebar::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

/* Current Game KB Header */
.gamekb-current-kb {
    padding: 18px 18px 12px;
    width: 100%;
}

.gamekb-kb-title {
    font-size: 1.3rem; /* Slightly smaller */
    font-weight: 700;
    color: #333;
    margin: 0 0 5px;
    line-height: 1.3;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    word-break: break-word; /* Better handling of long words */
    overflow-wrap: break-word;
}

.gamekb-kb-meta {
    font-size: 0.85rem;
    color: #666;
    margin: 0;
}

/* Thin Dividing Lines */
.gamekb-divider {
    height: 1px;
    background: #e0e0e0;
    border: none;
    margin: 0;
    width: 100%;
}

/* Search Form Container */
.gamekb-search-form-container {
    padding: 18px;
    background: transparent;
    width: 100%;
}

/* Relevanssi Search Form Styling */
.gamekb-relevanssi-search-form {
    margin: 0;
    padding: 0;
    width: 100%;
}

.gamekb-relevanssi-search-form form {
    position: relative;
    display: block;
    width: 100%;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.gamekb-search-wrapper {
    position: relative;
    display: block;
    width: 100%;
}

/* Input field - tighter for sidebar */
.gamekb-search-input {
    width: 100%;
    padding: 12px 40px 12px 12px !important; /* Reduced padding */
    border: 2px solid #d0d7de;
    border-radius: 8px !important;
    background: #ffffff;
    font-size: 13px; /* Smaller font */
    font-weight: 400;
    color: #334155;
    outline: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

/* Magnifying glass icon */
.gamekb-relevanssi-search-form .search-submit-wrapper {
    position: absolute;
    right: 8px; /* Moved closer to edge */
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    z-index: 10;
    width: 26px; /* Smaller */
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gamekb-relevanssi-search-form .custom-search-icon {
    width: 16px; /* Smaller */
    height: 16px;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

/* Hide the submit button */
.gamekb-search-submit {
    display: none !important;
}

/* Input focus state */
.gamekb-search-input:focus {
    border-color: #0366d6 !important;
    box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.1) !important;
}

/* Search note */
.gamekb-search-note {
    font-size: 0.8rem; /* Smaller */
    color: #666;
    margin: 8px 0 0;
    font-style: italic;
    text-align: center;
    line-height: 1.3;
}

/* Categories/Articles Navigation */
.gamekb-categories-nav {
    padding: 18px 12px; /* Reduced padding */
    width: 100%;
}

/* Category Items */
.gamekb-category {
    margin-bottom: 5px;
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #eaeaea;
    transition: border-color 0.2s ease;
    width: 100%;
}

/* Category Toggle Button */
.gamekb-category-toggle {
    width: 100%;
    text-align: left;
    padding: 10px 12px; /* Reduced padding */
    background: #ffffff;
    border: none;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    color: #24292f;
    font-size: 0.9rem; /* Smaller */
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    transition: background-color 0.2s ease;
    position: relative;
}

/* Expand/Collapse Arrow */
.gamekb-toggle-icon {
    width: 14px; /* Smaller */
    height: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease;
    color: #57606a;
    flex-shrink: 0;
}

.gamekb-toggle-icon svg {
    width: 8px; /* Smaller */
    height: 8px;
}

/* Category Name and Count */
.gamekb-category-name {
    flex-grow: 1;
    margin-right: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem; /* Smaller */
}

.gamekb-category-count {
    font-size: 0.8rem; /* Smaller */
    color: #57606a;
    font-weight: 400;
    margin-right: 6px;
    flex-shrink: 0;
}

/* Articles List */
.gamekb-articles-list {
    background: #fcfcfc;
    border-top: 1px solid #f0f0f0;
    display: none;
    padding: 8px 0; /* Reduced padding */
    width: 100%;
}

.gamekb-category-active .gamekb-articles-list {
    display: block;
}

/* Article Links - compact for sidebar */
.gamekb-articles-list a {
    display: block;
    padding: 6px 12px 6px 20px; /* Reduced padding */
    color: #24292f;
    text-decoration: none;
    font-size: 0.95rem; /* Smaller */
    line-height: 1.3;
    transition: background-color 0.2s ease, color 0.2s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Hover effect for article links */
.gamekb-articles-list a:hover {
    background-color: #f0fff4;
}

/* Current Article Highlight */
.gamekb-current-article a {
    background-color: #f0fff4 !important;
    color: #2ea44f !important;
    font-weight: 500;
}

/* RESPONSIVE ADJUSTMENTS */

/* Tablet (768px to 1024px) */
@media (max-width: 1024px) {
    .gamekb-article-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .gamekb-article-sidebar {
        position: static;
        width: 100%;
        max-height: none;
        margin-top: 30px;
        order: 2;
    }
    
    /* Reset to original padding for tablet/mobile */
    .gamekb-current-kb {
        padding: 20px 20px 15px;
    }
    
    .gamekb-kb-title {
        font-size: 1.4rem;
    }
    
    .gamekb-search-form-container {
        padding: 20px;
    }
    
    .gamekb-search-input {
        padding: 14px 45px 14px 15px !important;
        font-size: 14px;
    }
    
    .gamekb-categories-nav {
        padding: 20px 15px;
    }
    
    .gamekb-category-toggle {
        padding: 12px 15px;
        font-size: 0.95rem;
    }
    
    .gamekb-category-name {
        font-size: 0.95rem;
        white-space: normal; /* Allow wrapping on tablet/mobile */
    }
    
    .gamekb-articles-list a {
        padding: 8px 15px 8px 25px;
        font-size: 0.9rem;
        white-space: normal; /* Allow wrapping */
        line-height: 1.4;
    }
}

/* Mobile (below 768px) */
@media (max-width: 768px) {
    .gamekb-article-sidebar {
        margin: 20px 0;
    }
    
    .gamekb-current-kb,
    .gamekb-search-form-container {
        padding: 15px;
    }
    
    .gamekb-categories-nav {
        padding: 15px 10px;
    }
    
    .gamekb-kb-title {
        font-size: 1.2rem;
    }
    
    .gamekb-category-name {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
    }
}

/* Small mobile */
@media (max-width: 480px) {
    .gamekb-article-sidebar {
        border-radius: 6px;
    }
    
    .gamekb-kb-title {
        font-size: 1.1rem;
    }
    
    .gamekb-search-input {
        font-size: 13px;
        padding: 12px 40px 12px 12px !important;
    }
    
    .gamekb-category-toggle {
        padding: 10px 12px;
        font-size: 0.85rem;
    }
    
    .gamekb-articles-list a {
        padding: 5px 10px 5px 18px;
        font-size: 0.85rem;
    }
}