/* ==========================================================================
   Shared Grid Styles
   Common patterns for list-style grids (Invoices, Employees, etc.)
   ========================================================================== */

/* Search Bar */
.grid-search-bar {
    position: relative;
}

.grid-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #6c757d;
    font-size: 1rem;
    pointer-events: none;
}

.grid-search-input {
    padding-left: 2.75rem;
    border-radius: 12px;
    border: 1px solid #e3ebf6;
    height: 48px;
    font-size: 0.9375rem;
    background: white;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    box-sizing: border-box;
}

.grid-filter-btn {
    box-sizing: border-box;
}

.grid-search-input:focus {
    border-color: #2c7be5;
    box-shadow: 0 0 0 0.2rem rgba(44, 123, 229, 0.15);
}

.grid-search-clear {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: #95a5b3;
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
}

.grid-search-clear:hover {
    color: #12263f;
}

/* Filter / Sort Buttons */
.grid-filter-btn {
    border: 1px solid #e3ebf6;
    background: white;
    color: #12263f;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: 12px;
    padding: 0 1.5rem;
    height: 48px;
    min-height: 48px;
    min-width: 140px;
    text-align: left;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: inline-flex;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
    box-sizing: border-box;
}

.grid-filter-btn::after {
    margin-left: auto;
}

.grid-filter-btn:hover {
    border-color: #2c7be5;
    color: #2c7be5;
}

/* Dropdown Menus (filters & sort) */
.grid-dropdown-menu {
    min-width: 260px;
    border: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    padding: 0.75rem !important;
}

.grid-dropdown-menu.wide {
    min-width: 340px;
}

.grid-dropdown-options {
    max-height: 460px;
    overflow-y: auto;
}

.grid-dropdown-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.875rem;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.1s ease;
    margin: 0;
}

.grid-dropdown-option:hover {
    background: #f8f9fa;
}

.grid-dropdown-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #2c7be5;
    cursor: pointer;
    flex-shrink: 0;
}

.grid-dropdown-option-label {
    flex: 1;
    font-size: 0.9375rem;
    color: #12263f;
}

.grid-dropdown-option-count {
    font-size: 0.8125rem;
    color: #95a5b3;
}

/* List Container */
.grid-list {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    margin-bottom: 1rem;
}

/* Row Base */
.grid-row {
    display: grid;
    align-items: center;
    padding: 1.25rem 1.5rem;
    background: white;
    transition: all 0.15s ease;
    text-decoration: none;
    color: inherit;
    border-bottom: 1px solid #f0f3f5;
}

.grid-row:last-child {
    border-bottom: none;
}

.grid-row:hover {
    background: #f8f9fa;
    text-decoration: none;
    color: inherit;
}

/* Row Identity (avatar + name + meta) */
.grid-row-identity {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.grid-row-avatar {
    width: 44px;
    height: 44px;
    min-width: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.grid-row-avatar i {
    font-size: 18px;
}

.grid-row:hover .grid-row-avatar {
    transform: scale(1.05);
    opacity: 0.85;
}

.grid-row-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.grid-row-title {
    font-size: 1rem;
    font-weight: 600;
    color: #12263f;
    transition: color 0.2s ease;
}

.grid-row:hover .grid-row-title {
    color: #2c7be5;
}

.grid-row-meta {
    font-size: 0.875rem;
    color: #6c757d;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.grid-row-meta .meta-separator {
    opacity: 0.5;
}

.selectable-text {
    user-select: all;
    cursor: text;
}

/* Row Sections */
.grid-row-section {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.grid-row-section-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #95a5b3;
}

.grid-row-section-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #12263f;
}

.grid-row-section-sub {
    font-size: 0.75rem;
    color: #6c757d;
}

/* Status column */
.grid-row-status {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
    justify-content: flex-start;
}

/* ==========================================================================
   Department Tree Grid
   ========================================================================== */

.dept-row {
    grid-template-columns: minmax(0, 2fr) minmax(280px, 2.5fr) auto auto auto;
    gap: 1.5rem;
    transition: padding-left 0.15s ease, background 0.15s ease;
}

.dept-row.expanded {
    background: #fafbfc;
}

/* Chevron expand/collapse */
.dept-chevron {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border: none;
    background: transparent;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #95a5b3;
    transition: all 0.15s ease;
    padding: 0;
}

.dept-chevron:hover {
    background: #e8f0fe;
    color: #2c7be5;
}

.dept-chevron-spacer {
    width: 40px;
    min-width: 40px;
}

/* Department name link */
.dept-link {
    color: #12263f;
    text-decoration: none;
    transition: color 0.2s ease;
}

.dept-row-link,
.dept-row-body-link {
    color: inherit;
    text-decoration: none;
}

.dept-row-body-link {
    display: contents;
}

.dept-row-link:hover,
.dept-row-body-link:hover {
    color: inherit;
    text-decoration: none;
}

.dept-row-link:hover .dept-link,
.grid-row:hover .dept-link {
    color: #2c7be5;
    text-decoration: none;
}

/* Stats column */
.dept-stats {
    min-width: 260px;
}

.dept-usage-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dept-usage-bar {
    flex: 1;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
    max-width: 50%;
}

.dept-usage-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.dept-usage-fill.low {
    background: #00d97e;
}

.dept-usage-fill.medium {
    background: #f6c343;
}

.dept-usage-fill.high {
    background: #e63757;
}

/* Cards count badge */
.dept-cards-count {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dept-card-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.625rem;
    border-radius: 8px;
    background: #eef0f3;
    color: #6c757d;
    font-size: 0.8125rem;
    font-weight: 500;
}

/* Actions dropdown */
.dept-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    position: relative;
}

.dept-actions .dropdown-menu {
    z-index: 1050;
}

/* Ensure cards don't clip the dropdown */
.dept-entry {
    overflow: visible;
}

.dept-entry .grid-row {
    overflow: visible;
}

.dept-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #95a5b3;
    transition: all 0.15s ease;
    padding: 0;
}

.dept-action-btn:hover {
    background: #e8f0fe;
    color: #2c7be5;
}


/* Bottom padding for the virtualized list */
.dept-list-wrapper {
    padding-bottom: 1.5rem;
}

/* Each row is its own card — override grid-list overflow:hidden for dropdowns */
.dept-entry.grid-list {
    overflow: visible;
}

/* Per-entry top spacing replaces the old gap divs */
.dept-gap-root {
    margin-top: 1.25rem;
}

.dept-gap-sibling {
    margin-top: 0.5rem;
}

.dept-gap-child {
    margin-top: 0.125rem;
}

/* Root row styling — stands out via bolder text */
.dept-root-entry {
    margin-bottom: 0.5rem;
}

.dept-root-entry .grid-row-title,
.dept-root-entry .dept-link {
    font-size: 1.0625rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.grid-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 1rem 0;
}

.grid-page-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #e3ebf6;
    background: white;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    color: #6c757d;
    cursor: pointer;
    transition: all 0.15s ease;
}

.grid-page-btn:hover:not(:disabled) {
    border-color: #2c7be5;
    color: #2c7be5;
}

.grid-page-btn.active {
    background: #2c7be5;
    border-color: #2c7be5;
    color: white;
}

.grid-page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.grid-page-ellipsis {
    width: 36px;
    text-align: center;
    color: #95a5b3;
}

.grid-page-info {
    margin-left: 1rem;
    font-size: 0.8125rem;
    color: #95a5b3;
}

/* ==========================================================================
   Category Grid
   ========================================================================== */

.category-row {
    grid-template-columns: 1fr auto;
    gap: 2rem;
}

.category-tree-row {
    grid-template-columns: 1fr auto;
    gap: 2rem;
}

.category-actions {
    display: flex;
    align-items: center;
}

/* Depth-based left accent on child cards */
.dept-entry:not(.dept-root-entry) {
    border-left: 3px solid #d6e4ff;
}

.dept-entry:not(.dept-root-entry) .depth-2 {
    border-left-color: #b9d4f8;
}

.dept-entry:not(.dept-root-entry) .depth-3 {
    border-left-color: #95bef0;
}
