/* Override contributors.css margin */
.contributors-section {
    margin-bottom: 0 !important;
}

/* Global hidden class */
.hidden {
    display: none !important;
}

/* Layout with sidebar */
.apps-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 0;
    align-items: stretch;
    margin-left: calc(-50vw + 50%);
    margin-right: calc(-50vw + 50%);
    width: 100vw;
}

/* Sidebar: full-height column with sticky content inside */
.filter-sidebar {
    background: var(--color-canvas-subtle, #f6f8fa);
    border-right: 1px solid var(--color-border-default, #e1e4e8);
}

.filter-sidebar-inner {
    position: sticky;
    top: 0;
    padding: 1.5rem;
    max-height: 100vh;
    overflow-y: auto;
}

/* Hide landscape controls by default (desktop) */
.landscape-overlay,
.landscape-hamburger {
    display: none;
}

/* Mobile portrait ONLY - collapsible filters */
@media (max-width: 480px) { /* and (orientation: portrait) */
    .apps-layout {
        grid-template-columns: 1fr;
        margin-left: 0;
        margin-right: 0;
        width: 100%;
    }
    
    .filter-sidebar {
        border-right: none;
        border-bottom: 1px solid var(--color-border-default, #e1e4e8);
    }
    
    .filter-sidebar-inner {
        position: relative !important;
        top: 0 !important;
        max-height: none !important;
        padding: 1rem;
    }

    /* Toggle button */
    .mobile-filter-toggle {
        display: flex !important;
        width: 100%;
        padding: 0.6rem 0.75rem;
        margin-bottom: 0.75rem;
        background: var(--color-canvas-default, #ffffff);
        border: 1px solid var(--color-border-default, #e1e4e8);
        border-radius: 6px;
        font-size: 0.85rem;
        color: var(--color-text-secondary, #586069);
        cursor: pointer;
        align-items: center;
        justify-content: space-between;
        min-height: 44px;
        transition: all 0.15s ease;
    }

    .mobile-filter-toggle:hover {
        background: var(--color-canvas-subtle, #f6f8fa);
    }

    .mobile-filter-toggle i {
        transition: transform 0.3s ease;
    }

    .mobile-filter-toggle.expanded i {
        transform: rotate(180deg);
    }

    /* Collapsible wrapper - collapsed by default */
    .filter-tags-wrapper {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-in-out;
    }

    .filter-tags-wrapper.expanded {
        max-height: 3000px;
    }

    /* Smaller fonts for mobile */
    .sidebar-header h3 {
        font-size: 0.95rem;
    }

    .filter-counter-box {
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.75rem;
    }

    .filter-counter {
        font-size: 0.85rem;
    }

    .search-box input {
        font-size: 0.85rem;
        padding: 0.5rem 0.6rem 0.5rem 2rem;
    }

    .filter-tags-section h4 {
        font-size: 0.75rem;
    }

    .filter-btn {
        font-size: 0.8rem;
        padding: 0.5rem 0.6rem;
        min-height: 44px;
    }

    /* Portrait double accordion */
    .sidebar-header-actions {
        display: flex;
        flex-direction: row-reverse;
        gap: 0.5rem;
        align-items: center;
        flex: 1;
    }

    .portrait-collapse-btn {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: var(--color-canvas-default, #ffffff);
        border: 1px solid var(--color-border-default, #e1e4e8);
        border-radius: 6px;
        cursor: pointer;
        color: var(--color-text-secondary, #586069);
        transition: all 0.15s ease;
        margin-left: auto;
        order: -1;
    }

    .portrait-collapse-btn:hover {
        background: var(--color-canvas-subtle, #f6f8fa);
    }

    .portrait-collapse-btn i {
        transition: transform 0.3s ease;
    }

    .portrait-collapse-btn.expanded i {
        transform: rotate(180deg);
    }

    /* Level 1 wrapper - collapsed by default */
    .portrait-content-wrapper {
        max-height: 0;
        overflow: hidden;
        transition: max-height 0.3s ease-in-out;
    }

    .portrait-content-wrapper.expanded {
        max-height: 3000px;
    }

    /* Card optimizations for portrait mobile */
    .container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .contributors-page {
        padding: 0 !important;
    }

    .contributors-section {
        max-width: 100% !important;
        padding: 0 !important;
    }

    .apps-main {
        padding: 1rem;
        max-width: 100% !important;
    }

    .apps-main .contributors-header {
        margin-bottom: 1.5rem;
    }

    .apps-main .contributors-header h1 {
        font-size: 1.75rem;
    }

    .apps-cta {
        margin-bottom: 1rem;
    }

    .view-toggle-bar {
        margin-bottom: 1rem;
    }

    .app-grid {
        gap: 1rem;
        margin: 1rem 0;
    }

    .app-header {
        padding: 0.75rem 1rem;
    }

    .app-avatar-text {
        font-size: 1rem;
        padding: 0.3rem 0.5rem;
        width: 75px;
    }

    .app-title {
        font-size: 0.95rem;
    }

    .app-body {
        padding: 0.75rem 1rem;
    }

    .app-summary {
        font-size: 0.85rem;
    }

    .tag {
        font-size: 0.65rem;
        padding: 0.2rem 0.5rem;
    }

    /* Detailed view overrides for portrait mobile */
    .app-grid:not(.compact) .app-avatar-text {
        width: 75px !important;
        font-size: 1rem;
    }

    /* Compact view overrides for portrait mobile */
    .app-grid.compact .app-avatar-text {
        width: 75px !important;
        font-size: 0.9rem;
    }

    .app-grid.compact .app-title {
        font-size: 0.85rem;
    }
}

/* Landscape mode - drawer sidebar (≤768px in landscape OR small height) */
@media (max-width: 900px) and (min-width: 480px) { /* and (orientation: landscape) */
    /* Change layout to 1 column since sidebar is fixed */
    .apps-layout {
        grid-template-columns: 1fr;
        margin-left: 0;
        margin-right: 0;
        width: 100%;
    }

    /* Show and configure overlay - behind sidebar but above content */
    .landscape-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 900;
        opacity: 0;
        visibility: hidden;
        transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    }

    .landscape-overlay.visible {
        opacity: 1;
        visibility: visible;
    }

    /* Sidebar becomes fixed drawer - above overlay */
    .filter-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        width: 260px;
        z-index: 1000;
        transform: translateX(0);
        transition: transform 0.3s ease-in-out;
    }

    .filter-sidebar.closed {
        transform: translateX(-100%);
    }

    .filter-sidebar-inner {
        position: relative !important;
        top: 0 !important;
        padding: 1rem;
        height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    /* Show and configure hamburger button - above sidebar */
    .landscape-hamburger {
        display: flex !important;
        position: fixed;
        left: 5px;
        top: 70px;
        z-index: 1001;
        width: 48px;
        height: 48px;
        background: var(--color-canvas-default, #ffffff);
        border: 1px solid var(--color-border-default, #e1e4e8);
        border-radius: 8px;
        cursor: pointer;
        align-items: center;
        justify-content: center;
        font-size: 1.25rem;
        color: var(--color-text-secondary, #586069);
        transition: all 0.15s ease;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        opacity: 1;
        visibility: visible;
        transition: opacity 0.3s ease, visibility 0.3s ease;
    }

    .landscape-hamburger.hidden {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .landscape-hamburger:hover {
        background: var(--color-canvas-subtle, #f6f8fa);
        color: var(--color-text-primary, #24292e);
    }

    /* Smaller fonts */
    .sidebar-header h3 {
        font-size: 0.95rem;
    }

    .filter-tags-section h4 {
        font-size: 0.75rem;
    }

    .filter-btn {
        font-size: 0.8rem;
        padding: 0.4rem 0.6rem;
        min-height: 40px;
    }

    /* Main content adjustments */
    .apps-main {
        padding: 1rem;
    }

    .apps-main .contributors-header {
        margin-bottom: 1rem;
    }

    .apps-main .contributors-header h1 {
        font-size: 1.5rem;
    }

    .apps-cta {
        margin-bottom: 0.75rem;
    }

    .app-grid {
        gap: 0.75rem;
        margin: 1rem 0;
    }

    /* Card optimizations for landscape */
    .app-header {
        padding: 0.5rem 1rem;
    }

    .app-avatar-text {
        font-size: 1rem;
        padding: 0.3rem 0.5rem;
        width: 80px;
    }

    .app-title {
        font-size: 0.9rem;
    }

    .app-body {
        padding: 0.5rem 1rem;
    }

    .app-summary {
        font-size: 0.8rem;
        line-height: 1.4;
    }

    .tag {
        font-size: 0.6rem;
        padding: 0.15rem 0.4rem;
    }
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--color-border-default, #e1e4e8);
}

.sidebar-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--color-text-primary, #24292e);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.sidebar-header h3 i {
    color: var(--color-accent-fg, #0969da);
}

.filter-counter-box {
    margin-bottom: 1rem;
    padding: 0;
    background: transparent;
    border: 0;
    text-align: left;
}

.filter-counter {
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Search box */
.search-box {
    position: relative;
    margin-bottom: 1.5rem;
}

.search-box i {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--color-text-tertiary, #6a737d);
    font-size: 0.9rem;
}

.search-box input {
    width: 100%;
    padding: 0.6rem 0.75rem 0.6rem 2.25rem;
    border: 1px solid var(--color-border-default, #e1e4e8);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--color-canvas-default, #ffffff);
    transition: border-color 0.15s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--color-accent-fg, #0969da);
    box-shadow: 0 0 0 3px rgba(9, 105, 218, 0.1);
}

.filter-tags-section {
    margin-bottom: 1.5rem;
}

.filter-tags-section:last-child {
    margin-bottom: 0;
}

.filter-tags-section h4 {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-secondary, #586069);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 0.75rem 0;
}

/* Main content area */
.apps-main {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 2rem 2rem 2rem;
    flex-shrink: 0;
}

@media (max-width: 968px) {
    .apps-main {
        padding: 1rem 1rem 0 1rem;
    }
}

/* Header inside main content */
.apps-main .contributors-header {
    margin-bottom: 2rem;
}

.apps-main .contributors-header h1 {
    margin-top: 0;
}

/* CTA for adding applications */
.apps-cta {
    background: var(--color-canvas-subtle, #f6f8fa);
    border: 1px solid var(--color-border-muted, #d1d5da);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.apps-cta p {
    margin: 0;
    font-size: 0.85rem;
    color: var(--color-text-secondary, #586069);
}

.apps-cta a {
    color: var(--color-accent-fg, #0969da);
    text-decoration: none;
    font-weight: 500;
}

.apps-cta a:hover {
    text-decoration: underline;
}

/* View Toggle */
.view-toggle-bar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 1.5rem;
}

.view-btn {
    background: none;
    border: 1px solid var(--color-border-default, #e1e4e8);
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    color: var(--color-text-secondary, #586069);
    font-size: 1rem;
    transition: background 0.15s, color 0.15s;
}

.view-btn:first-child {
    border-radius: 6px 0 0 6px;
}

.view-btn:last-child {
    border-radius: 0 6px 6px 0;
    border-left: none;
}

.view-btn.active {
    background: var(--color-border-default, #e1e4e8);
    color: var(--color-text-primary, #24292e);
}

.view-btn:hover:not(.active) {
    background: var(--color-canvas-subtle, #f6f8fa);
}

/* Application Cards */
.app-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin: 2rem 0;
    width: 100%;
    min-width: 100%;
}

.app-card {
    display: flex;
    flex-direction: column;
    background: var(--color-canvas-default, #ffffff);
    border: 1px solid var(--color-border-default, #e1e4e8);
    border-left: 3px solid #007fa2;
    border-radius: 4px;
    overflow: hidden;
    transition: transform 0.15s ease, border-color 0.15s ease, background-color 0.15s ease;
    transform-origin: center;
    text-decoration: none;
    color: inherit;
    width: 100%;
    box-sizing: border-box;
}

.app-card:hover {
    transform: scale(1.01);
    border-color: #005f73;
    border-left-color: #005f73;
    background: #f8fafc;
}

.app-header {
    padding: 1rem 1.75rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--color-canvas-default, #ffffff);
    border-bottom: 1px solid var(--color-border-default, #e1e4e8);
}

.app-avatar-text {
    font-family: 'JuliaMono', monospace, 'Courier New', monospace;
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
    background: #f8fafc;
    border: 1px solid #b6dfe5;
    color: #005f73;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    padding: 0.3rem 0.75rem;
    border-radius: 4px;
    width: 125px;
    text-align: center;
    flex-shrink: 0;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
    text-align: left;
    color: #005f73;
    text-decoration: none;
    flex: 1;
}

.app-card:hover .app-avatar-text {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.app-card:hover .app-title {
    text-decoration: none;
}

.app-body {
    padding: 1rem 1.75rem 1rem;
    background: var(--color-canvas-default, #ffffff);
}

.app-summary {
    font-size: 0.95rem;
    text-align: left;
    color: var(--color-text-secondary, #585c60);
    line-height: 1.6;
    margin: 0 !important;
}

.dark .app-card:hover {
    background: #172033;
    border-color: #5ec9d6;
}

.dark .app-avatar-text {
    background: #172033;
    border-color: #347b86;
    color: #7dd3e0;
}

.dark .app-card:hover .app-avatar-text {
    background: #334155;
    border-color: #5ec9d6;
}

.dark .app-title {
    color: #5ec9d6;
}

/* Compact view */
.app-grid.compact {
    gap: 0.5rem;
}

.app-grid.compact .app-body {
    display: none;
}

.app-grid.compact .app-header {
    padding: 0.5rem 1rem;
    border-bottom: none;
}

.app-grid.compact .app-avatar-text {
    font-size: 1rem;
    padding: 0.3rem 0.5rem;
}

.app-grid.compact .app-title {
    font-size: 0.95rem;
}

.app-grid.compact .app-card {
    border-radius: 4px;
}

/* Tags on cards */
.app-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border-muted, #d1d5da);
}

.tags-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text-tertiary, #6a737d);
    margin-right: 0.25rem;
}

.tag {
    font-size: 0.7rem;
    font-weight: 500;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    background: var(--color-canvas-subtle, #f6f8fa);
    border: 1px solid var(--color-border-muted, #d1d5da);
    color: var(--color-text-secondary, #586069);
    text-transform: lowercase;
    line-height: 1;
    transition: all 0.15s ease;
}

.tag:hover {
    background: var(--color-canvas-default, #ffffff);
    border-color: var(--color-border-default, #e1e4e8);
}

.app-grid.compact .app-tags {
    display: none;
}

.filter-reset {
    font-size: 0.8rem;
    color: var(--color-danger-fg, #d1242f);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    font-weight: 500;
    visibility: visible;
    opacity: 1;
}

.filter-reset:hover {
    background: var(--color-danger-subtle, #ffebe9);
    color: var(--color-danger-fg, #d1242f);
}

.filter-reset.hidden {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.filter-bar {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.filter-btn {
    font-size: 0.85rem;
    padding: 0.5rem 0.75rem;
    border-radius: 6px;
    background: var(--color-canvas-default, #ffffff);
    border: 1px solid var(--color-border-default, #e1e4e8);
    color: var(--color-text-secondary, #586069);
    cursor: pointer;
    transition: all 0.15s ease;
    text-transform: lowercase;
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.filter-btn:hover {
    background: var(--color-canvas-default, #ffffff);
    border-color: var(--color-accent-fg, #0969da);
    color: var(--color-accent-fg, #0969da);
}

.filter-btn.active {
    background: var(--color-accent-emphasis, #0969da);
    border-color: var(--color-accent-emphasis, #0969da);
    color: white;
    font-weight: 600;
}

.filter-btn .tag-count {
    font-size: 0.75rem;
    opacity: 0.7;
}

/* Filtered state */
.app-card.filtered-out {
    display: none;
}

.no-results {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--color-text-secondary, #586069);
    background: var(--color-canvas-subtle, #f6f8fa);
    border-radius: 12px;
    border: 2px dashed var(--color-border-default, #e1e4e8);
}

.no-results i {
    font-size: 3rem;
    color: var(--color-text-tertiary, #6a737d);
    margin-bottom: 1rem;
    display: block;
}

.no-results p {
    font-size: 1rem;
    margin: 0;
}

.no-results.hidden {
    display: none;
}
