/* === LAYOUT BEHAVIOR ===
 *
 * Desktop (>768px):
 *   - Horizontal layout: scrollable content area + fixed-width sidebar
 *   - Sidebar hidden by default, slides in from right when .open class added
 *   - Desktop X button in top-right corner to close
 *
 * Mobile (≤768px):
 *   - Vertical layout: content fills screen
 *   - Sidebar is a slide-up drawer from bottom (60vh height)
 *   - Drawer hidden by default, opens when .open class added
 *   - Drawer has close button and backdrop overlay
 *   - Horizontal scroll disabled, navigation via carousel buttons using transform
 *
 * === STICKY HEADER ===
 *   - Two rows: logo/info row + filter bar
 *   - Both rows stick together at top when scrolling
 *   - Logo on left, newsletter link + contact email on right
 *   - Same horizontal layout on mobile and desktop
 *
 * === FILTER BAR ===
 *   - Horizontal flex, scrolls horizontally on overflow
 *   - Inside sticky header
 *   - Dropdown menus scroll if content exceeds max height
 *   - Clicking overlay (visible when dropdown open) closes dropdowns
 *
 * === DATA GRID (#table-container, grid view) ===
 *   - width: max-content so the grid is wider than viewport
 *   - Carousel JS applies transform to #table-container to scroll columns
 *   - On mobile: .content is overflow-x hidden, carousel is the scroll mechanism
 *   - On desktop: .content overflows naturally (no carousel shown)
 *
 * === LIST VIEW (#list-container) ===
 *   - Separate element, no connection to carousel
 *   - Each tool-type section has its own independently-scrollable row
 *
 * === MOBILE CAROUSEL ===
 *   - Fixed < > buttons at bottom of screen
 *   - Jumps one column at a time via CSS transform on #table-container
 *   - Hidden when sidebar drawer is open or list view is active
 */

/* Base */
html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

/* Layout */
.main-container {
    display: flex;
    width: 100%;
    height: 100vh;
}

.main-container.resizing {
    user-select: none;
    cursor: ew-resize;
}

.main-container.resizing * {
    cursor: ew-resize;
    pointer-events: none;
}

.main-container.resizing .sidebar-resize-handle {
    background: rgba(0, 0, 0, 0.1);
}

.content {
    flex: 1;
    overflow: auto;
}

/* Grid view container — carousel transforms this */
#table-container {
    width: max-content;
    min-width: 100%;
    padding: 0 16px 16px 24px;
}

/* List view container — full width, no transform involvement */
#list-container {
    width: 100%;
    box-sizing: border-box;
}

/* Sticky Header */
.sticky-header {
    position: -webkit-sticky;
    position: sticky;
    top: 0;
    left: 0;
    z-index: 30;
    background: white;
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px 12px 24px;
    border-bottom: 1px solid #ccc;
}

.header-logo {
    font-weight: 600;
    font-size: 1.1em;
    text-align: center;
}

.header-logo-link {
    text-decoration: none;
}

.header-breadcrumb-sep {
    margin: 0 4px;
}

.header-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    font-size: 0.9em;
}

.header-icon {
    font-size: 1em;
}

/* Sidebar */
.sidebar {
    display: none;
    position: relative;
    width: 350px;
    flex-shrink: 0;
    border-left: 1px solid #ccc;
    background: white;
}

.sidebar.open {
    display: block;
}

.sidebar-content {
    height: 100%;
    overflow-y: auto;
    padding: 16px;
}

.sidebar-handle {
    display: none;
}

.sidebar-close-desktop {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    font-size: 18px;
    line-height: 1;
}

.sidebar-close-desktop:hover {
    background: #f5f5f5;
}

.sidebar-close-mobile {
    display: none;
}

.sidebar-resize-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
    background: transparent;
}

.sidebar-resize-handle:hover {
    background: rgba(0, 0, 0, 0.1);
}

.sidebar-overlay {
    display: none;
}

/* Filter Bar */
.filter-bar-container {
    position: relative;
    background: white;
}

.filter-bar {
    display: flex;
    gap: 12px;
    padding: 12px 0 12px 24px;
    align-items: center;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.filter-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.filter-dropdown {
    display: flex;
    align-items: center;
    gap: 4px;
}

.filter-button {
    padding: 8px 12px;
    border: 1px solid #ccc;
    background: white;
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
}

.filter-button:hover {
    background: #f5f5f5;
}

.filter-clear {
    padding: 4px 8px;
    border: none;
    background: #eee;
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
}

.filter-clear:hover {
    background: #ddd;
}

.filter-dropdown-menu {
    position: absolute;
    top: 100%;
    left: 0;
    background: white;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 100;
    min-width: 220px;
    max-height: 300px;
    overflow-y: auto;
}

.filter-dropdown-menu input[type="text"] {
    width: calc(100% - 24px);
    margin: 8px;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 16px;
}

.filter-dropdown-menu label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    cursor: pointer;
}

.filter-dropdown-menu label:hover {
    background: #f5f5f5;
}

.filter-dropdown-menu input[type="checkbox"] {
    margin: 0;
}

.filter-clear-all {
    padding: 8px 12px;
    border: 1px solid #ccc;
    background: #f5f5f5;
    cursor: pointer;
    border-radius: 4px;
    white-space: nowrap;
}

.filter-clear-all:hover {
    background: #eee;
}

/* Info Bar (legacy, kept for newsletter pages) */
.info-bar {
    padding: 8px 0;
    font-size: 0.9em;
}

.info-line {
    margin: 2px 0;
}

.info-link {
    color: blue;
    text-decoration: underline;
}

/* No Results */
.no-results {
    padding: 40px;
    text-align: center;
    color: #666;
}

/* Data Grid */
.data-grid {
    display: grid;
    grid-template-columns: repeat(var(--col-count), auto);
    width: max-content;
}

.grid-header {
    position: -webkit-sticky;
    position: sticky;
    top: var(--header-height, 85px);
    z-index: 10;
    background: #f5f5f5;
    padding: 8px;
    border-top: 1px solid black;
    border-right: 1px solid black;
    border-bottom: 1px solid black;
    text-align: center;
    white-space: nowrap;
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.grid-header:first-child {
    border-left: 1px solid black;
}

.grid-cell {
    background: white;
    padding: 8px;
    border-right: 1px solid black;
    border-bottom: 1px solid black;
    text-align: center;
    white-space: nowrap;
}

.capability-label + .grid-cell {
    border-left: 1px solid black;
}

.capability-label {
    grid-column: 1 / -1;
    position: sticky;
    left: 0;
    width: fit-content;
    padding: 4px 12px;
    margin-top: 16px;
    font-weight: 400;
    font-size: 0.9em;
    color: #666;
    border-left: 3px solid #666;
}

.grid-cell code {
    background: #f0f0f0;
    padding: 0.0em 0.3em;
    border-radius: 3px;
    font-size: 0.85em;
}

/* Links */
.clickable {
    cursor: pointer;
    text-decoration: underline;
    color: blue;
}

.variation {
    font-size: 0.9em;
    opacity: 0.8;
}

.variant-toggle {
    font-size: 0.85em;
    color: #666;
}

/* Tool Cards */
.tool-card {
    cursor: pointer;
    border-radius: 8px;;
    box-shadow: -2px 2px #f5f5f5;
}

.tool-card-thumb, .tool-card-thumb-small {
    border: 2px solid #ddd;
    margin-top: 0;
}

.tool-card:hover {
    background: #f5f5f5;
}

.tool-card-compact .tool-card-thumb-small {
    margin-left: -2px;
    margin-bottom: -2px;
}

.tool-card-full {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    max-width: 120px;
    white-space: normal;
    text-align: center;
}

.tool-card-full .tool-card-name {
    padding: 2px;
}
.tool-card-full .tool-card-systems {
    padding-bottom: 4px;
}

.tool-card-full .tool-card-thumb {
    width: 120px;
    height: 120px;
    background: #ccc;
}

.tool-card-compact {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    max-width: 120px;
}

.tool-card-compact .tool-card-thumb-small {
    width: 36px;
    height: 36px;
    background: #ccc;
    flex-shrink: 0;
}

.tool-card-compact .tool-card-info {
    display: flex;
    flex-direction: column;
    text-align: left;
    overflow: hidden;
    padding-right: 2px;
    padding-bottom: 2px;
}

.tool-card-compact .tool-card-name,
.tool-card-compact .tool-card-systems {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tool-card-description {
    font-size: 0.8em;
    color: #666;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    padding: 0 2px 2px 2px;
}

#list-container .tool-card-full .tool-card-description {
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    max-width: 240px;
}

#list-container .tool-card-compact .tool-card-description {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    max-width: 240px;
}
#list-container .tool-card-full {
    max-width: 240px;
}

#list-container .tool-card-full .tool-card-thumb {
    width: 240px;
    height: 240px;
}

#list-container .tool-card-description {
    max-width: 240px;
}

#list-container .tool-card-compact {
    max-width: 240px;
}

#list-container .tool-card-compact .tool-card-thumb-small {
    width: 72px;
    height: 72px;
}

.tool-card-systems {
    font-size: 0.85em;
}

/* Images */
img {
    width: 100%;
    margin-top: 8px;
}

/* Screenshot Gallery */
.gallery {
    margin-top: 16px;
}

.gallery-preview {
    width: 100%;
    aspect-ratio: 16 / 9;
    overflow: auto;
    position: relative;
}

.gallery-preview img {
    width: auto;
    margin: 0;
    flex-shrink: 0;
}

.gallery-preview img.fit-width { width: 100%; }
.gallery-preview img.fit-height { height: 100%; }

.gallery-thumbs {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.gallery-thumb {
    width: 80px;
    height: 45px;
    object-fit: cover;
    cursor: pointer;
    flex-shrink: 0;
    margin: 0;
}

/* Tabs */
.tab-bar {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 16px;
    margin-top: 4px;
}

.tab-bar.expanded {
    flex-wrap: wrap;
    overflow-x: visible;
    padding-bottom: 0;
}

.tab-bar-toggle {
    background: none;
    border: none;
    color: #666;
    font-size: 0.8em;
    cursor: pointer;
    padding: 4px 0;
    white-space: nowrap;
}

.tab-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
}

.tab {
    padding: 6px 10px;
    border: 1px solid #ccc;
    background: #f5f5f5;
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.8em;
    flex-shrink: 0;
}

.sub-tab-bar {
    display: flex;
    gap: 4px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 16px;
    margin-top: 4px;
}

.sub-tab-bar.expanded {
    flex-wrap: wrap;
    overflow-x: visible;
    padding-bottom: 0;
}

.sub-tab {
    padding: 6px 10px;
    border: 1px solid #ccc;
    background: #f5f5f5;
    cursor: pointer;
    white-space: nowrap;
    font-size: 0.8em;
    flex-shrink: 0;
}

.tab-section-label {
    font-size: 0.75em;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 16px;
    margin-bottom: 4px;
}

/* Carousel - hidden on desktop */
.carousel-nav {
    display: none;
}

/* Newsletter Pages */
.newsletter-page {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px;
}

.newsletter-header {
    margin-bottom: 24px;
}

.back-link {
    color: blue;
    text-decoration: underline;
}

/* Signup Banner */
.signup-banner {
    background: #f5f5f5;
    border: 1px solid #ccc;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 32px;
}

.signup-banner-content {
    text-align: center;
}

.signup-banner-text {
    margin: 0 0 16px 0;
    font-size: 1.1em;
}

.signup-form {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.signup-input {
    padding: 10px 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1em;
    width: 250px;
    max-width: 100%;
}

.signup-button {
    padding: 10px 20px;
    background: #333;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 1em;
    cursor: pointer;
}

.signup-button:hover {
    background: #555;
}

.signup-message {
    margin: 0 0 16px 0;
    padding: 8px 12px;
    border-radius: 4px;
}

.signup-success {
    background: #d4edda;
    color: #155724;
}

.signup-error {
    background: #f8d7da;
    color: #721c24;
}

/* Newsletter Content */
.newsletter-content h1 {
    margin: 0 0 8px 0;
}

.newsletter-date {
    display: block;
    color: #666;
    margin-bottom: 24px;
}

.newsletter-body {
    line-height: 1.7;
}

.newsletter-body p {
    margin: 0 0 16px 0;
}

.newsletter-body ul, .newsletter-body ol {
    margin: 0 0 16px 0;
    padding-left: 24px;
}

.newsletter-body li {
    margin: 8px 0;
}

.newsletter-footer {
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid #ccc;
}

.newsletter-footer-link {
    color: blue;
    text-decoration: underline;
}

/* Newsletter List */
.newsletter-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.newsletter-list-item {
    border-bottom: 1px solid #eee;
}

.newsletter-list-link {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 0;
    text-decoration: none;
    color: inherit;
}

.newsletter-list-link:hover {
    background: #f9f9f9;
}

.newsletter-list-title {
    color: blue;
    text-decoration: underline;
}

.newsletter-list-date {
    color: #666;
    font-size: 0.9em;
}

.no-newsletters {
    color: #666;
    text-align: center;
    padding: 40px;
}

/* Mobile styles */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
    }

    .content {
        flex: 1;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    #table-container {
        padding: 0 8px 120px 12px;
    }

    #list-container {
        padding-bottom: 80px;
    }



    /* Header mobile */
    .header-row {
        padding: 8px 12px;
        gap: 8px;
    }

    .header-info {
        font-size: 0.75em;
    }

    .grid-header, .grid-cell {
        padding: 12px 8px;
    }

    /* Mobile carousel navigation */
    .carousel-nav {
        display: flex;
        position: fixed;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        gap: 24px;
        z-index: 50;
    }

    .carousel-btn {
        width: 56px;
        height: 56px;
        border-radius: 50%;
        background: white;
        border: 1px solid #ccc;
        font-size: 24px;
        cursor: pointer;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        touch-action: manipulation;
    }

    .carousel-btn:active {
        transform: scale(0.95);
    }

    .carousel-btn:disabled {
        opacity: 0.3;
        cursor: default;
    }

    /* Slide-up drawer */
    .sidebar {
        display: block;
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100% !important;
        height: 80vh;
        margin-right: 0;
        border-left: none;
        border-top: 1px solid #ccc;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
        transform: translateY(100%);
        transition: transform 0.3s ease-out;
        z-index: 100;
    }

    .sidebar.open {
        transform: translateY(0);
    }

    .sidebar-handle {
        display: block;
        width: 40px;
        height: 4px;
        background: #ccc;
        border-radius: 2px;
        margin: 12px auto;
    }

    .sidebar-content {
        height: calc(100% - 80px);
        padding: 0 16px 16px;
    }

    .sidebar-close-desktop {
        display: none;
    }

    .sidebar-close-mobile {
        display: block;
        position: absolute;
        bottom: 16px;
        left: 16px;
        right: 16px;
        padding: 12px;
        background: #333;
        color: white;
        border: none;
        border-radius: 8px;
        font-size: 16px;
        cursor: pointer;
    }

    .sidebar-resize-handle {
        display: none;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.3);
        z-index: 99;
    }

    .sidebar.open + .sidebar-overlay {
        display: block;
    }

    /* Filter adjustments for mobile */
    .filter-bar {
        padding: 8px 0 8px 12px;
        gap: 8px;
    }

    .tab-bar, .sub-tab-bar { scrollbar-width: none; }
    .tab-bar::-webkit-scrollbar, .sub-tab-bar::-webkit-scrollbar { display: none; }

    .filter-button {
        padding: 10px 12px;
        font-size: 14px;
    }

    .filter-dropdown-menu {
        min-width: 200px;
        max-height: 250px;
    }

    /* Newsletter mobile */
    .newsletter-page {
        padding: 16px 12px;
    }

    .signup-input {
        width: 100%;
    }

    .signup-form {
        flex-direction: column;
        align-items: stretch;
    }

    .newsletter-list-link {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
}

.tool-overflow-toggle {
    display: block;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.8em;
    color: #666;
    padding: 4px 0;
    text-align: center;
}

.tool-overflow-toggle:hover {
    text-decoration: underline;
}

/* List View */
.list-view-layout {
    padding: 0 16px 16px 24px;
}

@media (max-width: 768px) {
    .list-view-layout {
        padding: 0 16px 16px 12px;
    }
}

.list-section {
    margin-bottom: 8px;
}

.list-section .capability-label {
    grid-column: unset;
    position: static;
}

.list-section-row {
    display: flex;
    flex-direction: row;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
}

.list-section-cell {
    flex-shrink: 0;
    border: 1px solid black;
    padding: 8px;
    min-width: 240px;
}

.cell-product-name {
    background: #f5f5f5;
    font-weight: 600;
    font-size: 0.7em;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    text-align: center;
    padding: 8px;
    margin: -8px -8px 8px -8px;
    cursor: pointer;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.filter-group-label {
    padding: 8px 12px 4px 12px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #999;
    pointer-events: none;
}

.filter-group-child {
    padding-left: 24px !important;
}