/* Toolbar Layout & Offsets */
body.toolbar-active {
    padding-top: 140px; /* Extra offset so page header isn't hidden under toolbar */
}

body.toolbar-active:not(.admin-bar) {
    padding-top: 120px; /* Just toolbar */
}

body.toolbar-minimized {
    padding-top: 64px; /* 32px admin bar + condensed toolbar header */
}

body.toolbar-minimized:not(.admin-bar) {
    padding-top: 40px; /* Just minimized toolbar header */
}

/* Fixed Toolbar Shell */
.fixed-toolbar {
    position: fixed;
    top: 32px;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #000435 0%, #33A7B5 100%);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999; /* Below WP admin bar (99999) but above page content */
    transition: box-shadow 0.3s ease;
    display: flex;
    flex-direction: column;
}

body:not(.admin-bar) .fixed-toolbar {
    top: 0;
}

.fixed-toolbar .toolbar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 12px;
    background: rgba(0, 4, 53, 0.9);
    border-bottom: 1px solid rgba(255, 255, 255, 0.25);
    gap: 10px;
    min-height: 44px; /* Ensure consistent height */
    position: relative;
}

.fixed-toolbar .toolbar-title {
    color: #FFFFFF;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none; /* Don't block clicks */
}

.fixed-toolbar .toolbar-toggle {
    background: #FFFFFF;
    border: 2px solid #000435;
    color: #000435;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer !important;
    font-size: 18px;
    font-weight: bold;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto !important;
    position: relative;
    z-index: 200005; /* ABOVE EVERYTHING including WP admin bar and tutorial overlay */
    flex-shrink: 0;
    user-select: none;
}

.fixed-toolbar .toolbar-toggle:hover {
    background: #FFF5CB;
    border-color: #33A7B5;
    transform: scale(1.05);
}

.fixed-toolbar .toolbar-toggle:active {
    transform: scale(0.95);
}

/* Facility Selector */
.fixed-toolbar .facility-selector {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-shrink: 1;
    flex-grow: 1;
    justify-content: center;
}

.fixed-toolbar .facility-dropdown {
    min-width: 200px;
    width: auto;
    max-width: none;
    padding: 6px 10px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.95);
    color: #000435;
    font-size: 13px;
    cursor: pointer;
    height: 32px;
    text-overflow: ellipsis;
}

.fixed-toolbar .facility-selector .btn-toolbar {
    width: 32px;
    height: 32px;
    padding: 4px;
    min-width: 32px;
    min-height: 32px;
}

/* Toolbar Content */
.fixed-toolbar .toolbar-content {
    padding: 8px 16px;
    transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
    max-height: 1000px;
    overflow-x: hidden; /* No scrolling needed with wrap */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap; /* Allow wrapping for 2 rows */
}

/* MINIMIZED STATE */
.fixed-toolbar.minimized .toolbar-content {
    max-height: 0;
    padding: 0 16px;
    opacity: 0;
    pointer-events: none;
    border-top: none;
}

.fixed-toolbar .toolbar-section {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    position: relative;
    width: 100%; /* Take full width to manage rows */
    max-width: none;
}

.fixed-toolbar .toolbar-group {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    flex-shrink: 0;
    white-space: nowrap;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 0;
}

/* Force Facility Nav to 2nd Row Globally */
.fixed-toolbar .toolbar-group.facility-nav-group {
    flex-grow: 1;
    flex-shrink: 0;
    position: relative;
    left: auto;
    transform: none;
    order: 99; /* Force to bottom */
    width: 100%; /* Force new line */
    min-width: 200px;
    justify-content: center;
    margin: 8px 0 0 0; /* Spacing from top row */
}

.fixed-toolbar .toolbar-label {
    display: none;
}

.fixed-toolbar .btn-toolbar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 0;
    width: 50px;
    height: 50px;
    min-width: 50px;
    min-height: 50px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 8px;
    border: 2px solid #33A7B5;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #FFFFFF;
    color: #000435;
    box-shadow: 0 2px 4px rgba(51, 167, 181, 0.2);
    flex-shrink: 0;
    white-space: nowrap;
    text-align: center;
    overflow: hidden;
}
/* ... (hover states remain same) ... */

/* Desktop & Tablet Optimizations (769px and above) */
/* Show full buttons with labels when space permits */
@media (min-width: 769px) {
    .fixed-toolbar .toolbar-label {
        display: inline-block;
        font-size: 12px;
        font-weight: 600;
        color: #FFFFFF;
    }

    .fixed-toolbar .btn-toolbar .toolbar-label {
        color: inherit;
    }

    .fixed-toolbar .btn-toolbar {
        width: auto;
        min-width: 100px;
        max-width: 180px;
        height: 44px;
        min-height: 44px;
        padding: 0 12px;
        gap: 6px;
        justify-content: center;
    }

    .fixed-toolbar .facility-selector .btn-toolbar {
        width: 32px;
        min-width: 32px;
        max-width: 32px;
        height: 32px;
        padding: 4px;
    }

    .fixed-toolbar .toolbar-content {
        justify-content: center;
    }

    .fixed-toolbar .toolbar-section {
        justify-content: center;
    }

    .fixed-toolbar .facility-dropdown {
        min-width: 250px;
        width: auto;
        max-width: 400px;
    }
}

/* Specific Desktop Tweaks (1025px+) */
@media (min-width: 1025px) {
    /* Keep the general 769px+ styles, just minor tweaks if needed */
}

/* Mobile screens <= 768px */
@media (max-width: 768px) {
    .fixed-toolbar .toolbar-header {
        padding: 4px 8px;
        min-height: 32px;
    }

    .fixed-toolbar .toolbar-title {
        font-size: 11px;
    }

    .fixed-toolbar .toolbar-title #toolbar-project-name {
        display: none;
    }

    .fixed-toolbar .toolbar-toggle {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }

    .fixed-toolbar .toolbar-content {
        padding: 6px 10px;
    }

    .fixed-toolbar .toolbar-section {
        gap: 6px;
    }

    .fixed-toolbar .toolbar-group {
        gap: 4px;
    }
    
    /* Nav group is already forced to bottom by base styles, just tweak spacing */
    .fixed-toolbar .toolbar-group.facility-nav-group {
        margin-top: 6px;
    }

    .fixed-toolbar .toolbar-label {
        display: none; /* Hide labels on mobile to save space */
    }

    .fixed-toolbar .btn-toolbar {
        width: 40px;
        height: 40px;
        min-width: 40px;
        min-height: 40px;
        font-size: 14px;
    }

    .fixed-toolbar .facility-dropdown {
        min-width: 150px;
        width: auto;
        max-width: 220px;
        font-size: 12px;
        padding: 4px 8px;
        height: 32px;
    }
}

/* Small-screen tweaks (<= 640px) */
@media (max-width: 640px) {
    /* Ensure no header wrapping */
    .fixed-toolbar .toolbar-header {
        padding: 6px 10px;
        flex-wrap: nowrap;
    }
    
    .fixed-toolbar .toolbar-title {
        font-size: 14px;
        flex: 1;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .fixed-toolbar .btn-toolbar {
        min-width: 36px;
        width: 36px;
        height: 36px;
        min-height: 36px;
    }
}

/* Wiki Editor Checklists */
.diagnoses-checklist,
.allegations-checklist {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin: 15px 0;
    padding: 15px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.checklist-column h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 14px;
    font-weight: 600;
    border-bottom: 2px solid #0073aa;
    padding-bottom: 5px;
}

.checklist-column label {
    display: block;
    padding: 5px 0;
    cursor: pointer;
    transition: background 0.2s ease;
}

.checklist-column label:hover {
    background: #fff;
    padding-left: 3px;
}

.checklist-column input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}