/*
 * shared-ui.css
 * Shared index-page UI components – toolbar, table, badges, action buttons.
 * Extracted from employees.css so every module can use the same design language.
 * Registered globally via AppAsset.
 */

/* ═══════════════════════════════════════════════════════════
   Toolbar
   ═══════════════════════════════════════════════════════════ */
.staff-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 14px;
}
.staff-toolbar-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 0 0 auto;
    align-self: flex-end;
}
.staff-toolbar-title {
    font-size: 12px;
    font-weight: 700;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.staff-toolbar-count {
    font-size: 12px;
    color: #9ca3af;
    white-space: nowrap;
}
.staff-filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 10px;
    align-items: flex-end;
    justify-content: flex-end;
    flex: 0 0 auto;
    margin-left: auto;
}
.staff-filter-field {
    min-width: 130px;
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.staff-filter-field > label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #6b7280;
    margin-bottom: 0;
}
.staff-filter-bar .form-control,
.staff-filter-bar .form-select {
    font-size: 12px;
    height: 30px;
    padding: 4px 8px;
    border-color: #e2e8f0;
    border-radius: 6px;
}
.staff-filter-bar .form-control:focus,
.staff-filter-bar .form-select:focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.08);
}

/* ═══════════════════════════════════════════════════════════
   Table wrapper & table
   ═══════════════════════════════════════════════════════════ */
.staff-table-wrapper {
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
}
.staff-table-wrapper .table-responsive { margin: 0; }

.staff-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    margin: 0;
}
.staff-table > thead > tr > th {
    background: #f8fafc;
    font-weight: 600;
    color: #374151;
    border-bottom: 2px solid #cbd5e1;
    border-top: none;
    border-left: none;
    border-right: none;
    padding: 9px 12px;
    white-space: nowrap;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.staff-table > thead > tr > th a,
.staff-table > thead > tr > th a:visited {
    color: #374151;
    text-decoration: none;
}
.staff-table > thead > tr > th a:hover { color: #1e40af; }
.staff-table > tbody > tr > td {
    padding: 9px 12px;
    border-bottom: 1px solid #e2e8f0;
    border-top: none;
    border-left: none;
    border-right: none;
    vertical-align: middle;
    color: #374151;
}
.staff-table > tbody > tr:last-child > td { border-bottom: none; }
.staff-table > tbody > tr:hover { background: #eff6ff; }

/* ═══════════════════════════════════════════════════════════
   Row action icon buttons
   ═══════════════════════════════════════════════════════════ */
.staff-act-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    margin-left: 3px;
    border: none;
    background: transparent;
    color: #94a3b8;
    border-radius: 5px;
    text-decoration: none;
    padding: 0;
    cursor: pointer;
    transition: background .15s, color .15s;
    line-height: 1;
}
.staff-act-btn:first-child { margin-left: 0; }
.staff-act-btn:hover { text-decoration: none; }
.staff-act-btn .fa,
.staff-act-btn .fas { font-size: 12px; }
.staff-act-edit  .fa  { color: #1e40af; }
.staff-act-edit:hover { background: #dbeafe; color: #1e40af; }
.staff-act-view  .fa  { color: #065f46; }
.staff-act-view:hover { background: #d1fae5; color: #065f46; }
.staff-act-archive .fa  { color: #dc2626; }
.staff-act-archive:hover { background: #f6bebe; color: #92400e; }
.staff-act-restore .fa  { color: #16a34a; }
.staff-act-restore:hover { background: #d1fae5; color: #065f46; }
.staff-act-delete  .fa  { color: #dc2626; }
.staff-act-delete:hover  { background: #fee2e2; color: #dc2626; }
.staff-act-approve .fa  { color: #059669; }
.staff-act-approve:hover { background: #d1fae5; color: #059669; }
.staff-act-deactivate .fa  { color: #6b7280; }
.staff-act-deactivate:hover { background: #f1f5f9; color: #374151; }
.staff-act-key .fa, .staff-act-key .fas  { color: #0369a1; }
.staff-act-key:hover { background: #e0f2fe; color: #0369a1; }
.staff-act-mobile .fa, .staff-act-mobile .fas { color: #d97706; }
.staff-act-mobile:hover { background: #fef9c3; color: #b45309; }
.staff-actions-cell { white-space: nowrap; text-align: right; }

/* Batch-review checkbox column */
.staff-chk-checkbox { width: 16px; height: 16px; cursor: pointer; }
.staff-chk-col { min-width: 80px; text-align: center; }

/* ═══════════════════════════════════════════════════════════
   Pagination strip
   ═══════════════════════════════════════════════════════════ */
.staff-pager-wrapper {
    padding: 12px 16px 10px;
    border-top: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 8px;
}
.staff-pager-info { font-size: 12px; color: #9ca3af; }

/* ═══════════════════════════════════════════════════════════
   Status / type pill badges  (.s-badge)
   ═══════════════════════════════════════════════════════════ */
.s-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.03em;
    white-space: nowrap;
    line-height: 1.6;
}
.s-badge-active    { background: #d1fae5; color: #065f46; }
.s-badge-archived  { background: #f1f5f9; color: #475569; }
.s-badge-approved  { background: #d1fae5; color: #065f46; }
.s-badge-rejected  { background: #fee2e2; color: #b91c1c; }
.s-badge-pending   { background: #fef9c3; color: #854d0e; }
.s-badge-inactive  { background: #f1f5f9; color: #475569; }
.s-badge-paid      { background: #d1fae5; color: #065f46; }
.s-badge-info      { background: #dbeafe; color: #1e40af; }
.s-badge-warning   { background: #fef9c3; color: #854d0e; }
.s-badge-fulltime  { background: #dbeafe; color: #1e40af; }
.s-badge-parttime  { background: #ede9fe; color: #5b21b6; }
.s-badge-contract  { background: #fce7f3; color: #9d174d; }
.s-badge-intern    { background: #f1f5f9; color: #475569; }

/* ═══════════════════════════════════════════════════════════
   Cell helpers
   ═══════════════════════════════════════════════════════════ */
.staff-idx-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1e40af;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.staff-idx-name-link { font-weight: 600; color: #1e40af; text-decoration: none; }
.staff-idx-name-link:hover { text-decoration: underline; }
.staff-idx-sub   { font-size: 11px; color: #9ca3af; }
.staff-idx-muted { color: #9ca3af; }
.staff-idx-rownum { font-size: 12px; color: #9ca3af; }
.staff-idx-code {
    font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
    font-size: 11px;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    color: #374151;
    padding: 1px 6px;
    border-radius: 4px;
}

/* ═══════════════════════════════════════════════════════════
   Sidebar overflow fix
   Makes accordion panels scrollable so long labels are reachable.
   The outer sidebar stays clipped to prevent active-item backgrounds
   from bleeding past the dark sidebar boundary.
   ═══════════════════════════════════════════════════════════ */
@media (min-width: 768px) {
    /* Hard outer boundary – nothing bleeds past the 14rem sidebar */
    .sidebar:not(.toggled) {
        overflow-x: hidden;
    }
    /* White accordion panels scroll horizontally; no text is ever hidden */
    .sidebar:not(.toggled) .nav-item .collapse .collapse-inner,
    .sidebar:not(.toggled) .nav-item .collapsing .collapse-inner {
        overflow-x: auto;
    }
    /* Stretch item background to cover its full text.
       min-width:100% fills the panel when text is short;
       width:max-content expands to cover the text when it's longer. */
    .sidebar:not(.toggled) .nav-item .collapse .collapse-inner .collapse-item,
    .sidebar:not(.toggled) .nav-item .collapsing .collapse-inner .collapse-item {
        min-width: 100%;
        width: max-content;
        box-sizing: border-box;
    }
}


/* ═══════════════════════════════════════════════════════════
   Mobile / Responsive overrides
   ═══════════════════════════════════════════════════════════ */

/* Scrollable tab nav on small screens */
.nav-tabs {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs .nav-link {
    white-space: nowrap;
}

/* ── 768px and below: tablet / mobile toolbar ─────────────── */
@media (max-width: 767.98px) {
    /* Toolbar stacks label above filters */
    .staff-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    /*
     * Switch filter bar from a flex row to a CSS Grid.
     * Flexbox-based flex-basis fights against inline style="min-width:180px"
     * because flex-basis can be overridden by min-width constraints.
     * CSS Grid avoids this: track sizes are assigned first; min-width: 0
     * on the items then prevents them from overflowing their tracks even
     * when an inline min-width is present (our !important beats the inline).
     */
    .staff-filter-bar {
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 8px 10px !important;
        width: 100% !important;
        margin-left: 0 !important;
        flex: none !important;
        justify-content: unset !important;
    }
    .staff-filter-field {
        min-width: 0 !important;   /* allow the grid track to set width */
        max-width: 100% !important;
        flex: none !important;
        box-sizing: border-box !important;
        /* align-self:flex-end (inline) remains valid in a grid container */
    }
}

/* ── 575px and below: phone ───────────────────────────────── */
@media (max-width: 575.98px) {
    /* Single-column filter grid on phones */
    .staff-filter-bar {
        grid-template-columns: 1fr !important;
    }
    /* Card headers with d-flex on mobile */
    .card-header.d-flex.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
        gap: .5rem;
    }
    /* Profile header buttons stack */
    .d-sm-flex.align-items-center.justify-content-between {
        flex-direction: column;
        align-items: flex-start !important;
    }
    /* Prevent container overflow */
    .container-fluid {
        padding-left: 10px;
        padding-right: 10px;
    }
    /* Staff table: reduce font size to fit more columns */
    .staff-table {
        font-size: 11.5px;
    }
    .staff-table > thead > tr > th,
    .staff-table > tbody > tr > td {
        padding: 7px 8px;
    }
}
