/* HEPTAS - Custom Styles */

/* ========================================
   LAYOUT - Fixed Sidebar, Scrollable Content
   ======================================== */

html, body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f8f9fa;
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Sidebar - a thin icon rail, full height */
.sidebar {
    width: 56px;
    min-width: 56px;
    height: 100vh;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Main Content - Scrollable */
.main-content {
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    overflow-x: hidden;
    background-color: #f8f9fa;
}

.page-content {
    padding: 1.5rem;
    min-height: 100%;
}

/* Sticky Toolbar */
.sticky-toolbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #f8f9fa;
    padding-bottom: 0.5rem;
    margin: -1.5rem -1.5rem 1rem -1.5rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #dee2e6;
}

/* ========================================
   SIDEBAR STYLES
   ======================================== */

/* Brand: the logo's "7" on a white tile */
.rail-brand {
    display: block;
    width: 40px;
    height: 40px;
    margin: 8px 0;
    border-radius: 6px;
    background: #fff;
    overflow: hidden;
    flex-shrink: 0;
}

.rail-brand img {
    width: 100%;
    height: 100%;
    display: block;
}

/* The icons scroll on their own when the window is too short */
.rail-nav {
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: none;
}

.rail-nav::-webkit-scrollbar {
    display: none;
}

/* One icon; the active page gets a bar on the left, as in VS Code */
.rail-link {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 44px;
    font-size: 1.25rem;
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    transition: color 0.15s, background-color 0.15s;
}

.rail-link:hover,
.rail-link:focus-visible {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.08);
}

.rail-link.active {
    color: #fff;
}

.rail-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 0 2px 2px 0;
    background: #0d6efd;
}

.rail-button {
    border: 0;
    border-radius: 0;
    background: transparent;
    padding: 0;
}

.rail .dropdown-toggle::after {
    display: none;   /* no caret on an icon */
}

.rail-divider {
    width: 28px;
    margin: 6px auto;
    border-color: rgba(255, 255, 255, 0.35);
    opacity: 1;
}

.rail-bottom {
    width: 100%;
    padding: 4px 0;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    background-color: rgba(0, 0, 0, 0.2);
}

.rail-user {
    cursor: default;
}

/* Admins: a red dot on the person icon (the footer's old Admin badge) */
.rail-admin-dot {
    position: absolute;
    top: 9px;
    right: 15px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dc3545;
    border: 1px solid #212529;
}

/* ========================================
   CARDS
   ======================================== */

.card {
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.card-header {
    background-color: #fff;
    border-bottom: 1px solid rgba(0, 0, 0, 0.125);
}

/* ========================================
   TABLES
   ======================================== */

.table {
    margin-bottom: 0;
}

.table th {
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    border-bottom: 2px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    white-space: nowrap;
    position: relative;
    user-select: none;
    padding: 0.75rem 0.5rem;
    vertical-align: middle;
    height: 44px;
}

.table th:last-child {
    border-right: none;
}

.table td {
    vertical-align: middle;
    border-right: 1px solid #f0f0f0;
    padding: 0.5rem;
}

.table td:last-child {
    border-right: none;
}

.table-hover tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

/* ========================================
   FROZEN COLUMNS & TABLE SCROLL
   ======================================== */

.table-wrapper {
    overflow-x: auto;
    overflow-y: visible;
    max-width: 100%;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.table-frozen {
    border-collapse: separate;
    border-spacing: 0;
    width: max-content;
    min-width: 100%;
}

.table-frozen th,
.table-frozen td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Frozen columns. Their left offsets are set by script (updateFrozenPositions), so any
   number of frozen columns of any width stack up correctly. */
.table-frozen .frozen-col {
    position: sticky !important;
    left: 0;
    background: #fff;
    z-index: 2;
}

.table-frozen thead .frozen-col {
    background: #f8f9fa !important;
    z-index: 4 !important;
}

/* Checkbox column */
.table-frozen .frozen-col.col-select {
    min-width: 40px;
    width: 40px;
}

/* The last frozen column separates them from the scrolling ones */
.table-frozen .frozen-col.frozen-last {
    border-right: 3px solid #adb5bd !important;
    box-shadow: 3px 0 6px rgba(0,0,0,0.15);
}

/* Description: one line with an ellipsis; the full text is its tooltip */
.table-frozen td.col-desc {
    max-width: 0;
}

.table-frozen td.col-desc .desc-text {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Column headings: a sort button and, apart from it, a filter (funnel) button */
.th-inner {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-right: 6px;
}

.th-sort {
    border: 0;
    background: none;
    padding: 0;
    font: inherit;
    font-weight: 600;
    color: inherit;
    text-align: left;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.th-sort:hover {
    text-decoration: underline;
}

.th-sort .sort-arrow {
    color: var(--bs-primary);
    font-size: 0.75em;
}

.btn-funnel {
    border: 0;
    background: none;
    padding: 0 0.15rem;
    line-height: 1;
    color: #6c757d;
    border-radius: 0.25rem;
}

.btn-funnel:hover,
.btn-funnel:focus-visible {
    background: rgba(13, 110, 253, 0.12);
    color: var(--bs-primary);
}

.btn-funnel.active {
    color: var(--bs-primary);
}

.filter-pop {
    min-width: 15rem;
    white-space: normal;
}

.filter-pop .filter-choices {
    max-height: 14rem;
    overflow-y: auto;
}

/* Active filter chips above the table */
.filter-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    align-items: center;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: 1px solid #ced4da;
    border-radius: 1rem;
    background: #f8f9fa;
    padding: 0.15rem 0.35rem 0.15rem 0.65rem;
    font-size: 0.85rem;
}

.filter-chip a {
    color: #6c757d;
    text-decoration: none;
}

.filter-chip a:hover {
    color: var(--bs-danger);
}

/* Selection bar for the ticked work items (it sits in the sticky toolbar) */
.selection-bar {
    background: #e7f1ff;
    border: 1px solid #b6d4fe;
    border-radius: 0.375rem;
    padding: 0.4rem 0.75rem;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

/* Columns dialog: drag-to-order list */
.column-order li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid #dee2e6;
    border-radius: 0.25rem;
    margin-bottom: 0.25rem;
    background: #fff;
}

.column-order li.dragging {
    opacity: 0.5;
}

.column-order .drag-handle {
    cursor: grab;
    color: #6c757d;
}

.table-frozen tbody tr:hover .frozen-col {
    background: #e8f4fd !important;
}

/* ========================================
   COLUMN RESIZING
   ======================================== */

.resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    background: transparent;
    z-index: 10;
}

.resize-handle:hover {
    background: rgba(13, 110, 253, 0.3);
}

.resize-handle.resizing {
    background: #0d6efd;
}

th.resizing {
    background-color: #e3f2fd !important;
}

/* Header row styling */
.table-light th {
    background-color: #f8f9fa !important;
}

/* ========================================
   TOOLBAR & FILTER PANEL
   ======================================== */

.toolbar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    align-items: center;
}

.filter-panel-container {
    max-width: 40%;
}

.filter-panel {
    background: #fff;
    border: 2px solid #ffc107;
    border-radius: 0.375rem;
    padding: 1rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.filter-label {
    font-weight: 500;
    font-size: 0.8rem;
    min-width: 80px;
    color: #6c757d;
}

.filter-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 0.75rem;
}

.filter-checkboxes .form-check-inline {
    margin-right: 0;
}

/* Bulk Actions Panel */
.bulk-panel-container {
    max-width: 40%;
}

.bulk-panel {
    background: #fff;
    border: 2px solid #ffc107;
    border-radius: 0.375rem;
    padding: 1rem;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.bulk-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.bulk-label {
    font-weight: 500;
    font-size: 0.8rem;
    min-width: 100px;
    color: #6c757d;
}

/* ========================================
   PAGINATION
   ======================================== */

.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    flex-wrap: wrap;
    gap: 1rem;
}

.pagination-info {
    color: #6c757d;
    font-size: 0.875rem;
}

.pagination {
    margin-bottom: 0;
}

/* ========================================
   FORMS
   ======================================== */

.form-label {
    font-weight: 500;
    font-size: 0.875rem;
}

.form-control:focus,
.form-select:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* ========================================
   BADGES
   ======================================== */

.badge {
    font-weight: 500;
}

.badge.bg-secondary {
    background-color: #6c757d !important;
}

/* ========================================
   MODALS
   ======================================== */

.modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.modal-footer {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
}

/* ========================================
   BUTTONS
   ======================================== */

.btn-group-sm > .btn {
    padding: 0.25rem 0.5rem;
}

/* ========================================
   LOGIN PAGE
   ======================================== */

.card.shadow {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

/* ========================================
   RESPONSIVE
   ======================================== */

@media (max-width: 768px) {
    /* The icon rail is narrow enough to stay on small screens. */
    .main-content {
        width: 100%;
    }
    
    .filter-panel-container,
    .bulk-panel-container {
        max-width: 100%;
    }
}

/* ========================================
   UTILITY CLASSES
   ======================================== */

.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* ========================================
   COLUMN WIDTH CLASSES
   ======================================== */

.col-select { 
    width: 40px; 
    min-width: 40px; 
    max-width: 40px; 
    text-align: center;
}

.col-workid { 
    min-width: 140px; 
}

.col-actions { 
    width: 80px; 
    min-width: 80px; 
    max-width: 80px; 
    text-align: center;
}

/* Weekly Time Inputs */
.col input[type="number"] {
    text-align: center;
}

/* ========================================
   UPLOAD PREVIEW
   ======================================== */

#previewSection .table-warning {
    background-color: rgba(255, 193, 7, 0.1);
}

#previewSection .desc-input {
    min-width: 200px;
}

/* ========================================
   PRINT STYLES
   ======================================== */

@media print {
    .sidebar,
    .toolbar,
    .filter-bar,
    .btn-group,
    .sticky-toolbar {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        max-width: 100%;
    }
}


/* ========================================
   ADMIN "VIEW AS" BANNER
   Fixed above the sidebar and content while an admin views as someone; not dismissible.
   text-bg-warning sets a contrasting text colour for the background in Bootstrap's themes.
   ======================================== */

body.view-as-active {
    --view-as-banner-height: 44px;
    padding-top: var(--view-as-banner-height);
}

.view-as-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--view-as-banner-height);
    z-index: 1030;
    border-bottom: 3px solid var(--bs-dark);
    font-size: 0.9rem;
}

body.view-as-active .sidebar,
body.view-as-active .main-content {
    height: calc(100vh - var(--view-as-banner-height));
    min-height: 0 !important;
}

.view-as-menu {
    width: 340px;
    max-height: 60vh;
    overflow-y: auto;
}

.view-as-menu .dropdown-item {
    white-space: normal;
}
