/* ============================================
   Project Management App — Styles (Compact)
   ============================================ */

/* Layout */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 0.875rem;
    padding-top: 48px; /* compact navbar */
}

.navbar { min-height: 48px; padding-top: 0.25rem; padding-bottom: 0.25rem; }
.navbar-brand { font-size: 1rem; }

.main-wrapper {
    min-height: calc(100vh - 48px);
}

/* Sidebar — compact */
.sidebar {
    transition: width 0.2s;
}

.sidebar .p-3 { padding: 0.5rem 0.75rem !important; }

.sidebar h6 { margin-bottom: 0.5rem !important; font-size: 0.7rem; }

.sidebar .nav-link {
    font-size: 0.8rem;
    border-radius: 4px;
    margin-bottom: 1px;
    padding: 4px 8px !important;
    line-height: 1.4;
}

.sidebar .nav-link:hover:not(.active) {
    background-color: #e9ecef;
}

/* Sidebar group folders */
.sidebar-group-toggle {
    cursor: pointer;
    user-select: none;
}

.sidebar-group-toggle .sidebar-chevron {
    transition: transform 0.2s ease;
    font-size: 0.6rem;
}

.sidebar-group-toggle:not(.collapsed) .sidebar-chevron {
    transform: rotate(90deg);
}

.sidebar-group .collapse .nav-link {
    padding-left: 10px !important;
    font-size: 0.78rem;
}

/* Task Table — compact */
.task-table { font-size: 0.82rem; }

.task-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #6c757d;
    padding: 6px 8px !important;
    border-bottom-width: 2px;
}

.task-table td {
    padding: 5px 8px !important;
    vertical-align: middle;
}

.task-table tbody tr {
    transition: background-color 0.1s;
}

.task-table tbody tr:hover {
    background-color: #f0f4ff !important;
}

.task-table .badge {
    font-size: 0.68rem;
    padding: 2px 6px;
}

/* Tree connector lines */
.tree-node {
    position: relative;
    white-space: nowrap;
}

.subtask-add-btn { opacity: 0; transition: opacity 0.15s; }
tr:hover .subtask-add-btn { opacity: 1; }

.tree-line {
    position: absolute;
    top: 0;
    width: 18px;
    height: 100%;
    color: #c0c4cc;
    font-family: monospace;
    font-size: 0.82rem;
    line-height: 1.4;
    pointer-events: none;
    user-select: none;
}

.tree-label {
    display: inline-block;
}

/* Project header — compact */
#taskPanel > .d-flex:first-child { margin-bottom: 0.75rem !important; }
#taskPanel h4 { font-size: 1.1rem; margin-bottom: 0 !important; }
#taskPanel p.text-muted { font-size: 0.8rem; margin-bottom: 0 !important; }

/* Due Date Status */
.due-badge { font-size: 0.68rem; }

/* Completed Tasks */
.task-completed {
    text-decoration: line-through;
    opacity: 0.6;
}

/* Offcanvas Task Detail */
#taskDetailPanel { z-index: 1050; }

#taskDetailBody {
    padding: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Tabs in task detail */
#taskTabs { flex-shrink: 0; }

#taskTabs .nav-link {
    font-size: 0.8rem;
    padding: 6px 12px;
}

.tab-content {
    flex: 1;
    overflow-y: auto;
}

.detail-section {
    padding: 10px 16px;
    border-bottom: 1px solid #e9ecef;
}

.detail-section:last-child { border-bottom: none; }

.detail-section h6 {
    font-size: 0.72rem;
    text-transform: uppercase;
    color: #6c757d;
    margin-bottom: 8px;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.detail-section .table-sm td { padding: 2px 4px; font-size: 0.82rem; }

/* Comment Styles */
.comment-item {
    padding: 6px 10px;
    background: #f8f9fa;
    border-radius: 6px;
    margin-bottom: 5px;
}

.comment-item .comment-author {
    font-weight: 600;
    font-size: 0.78rem;
    color: #333;
}

.comment-item .comment-date {
    font-size: 0.7rem;
    color: #999;
}

.comment-item .comment-text {
    font-size: 0.82rem;
    margin-top: 2px;
    line-height: 1.4;
}

/* @mention highlight */
.mention-tag {
    background-color: #e7f1ff;
    color: #0d6efd;
    padding: 0 3px;
    border-radius: 2px;
    font-weight: 500;
}

/* @mention dropdown */
.mention-dropdown {
    position: absolute;
    background: #fff;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.1);
    max-height: 180px;
    overflow-y: auto;
    z-index: 2000;
    min-width: 160px;
}

.mention-dropdown-item {
    padding: 5px 10px;
    cursor: pointer;
    font-size: 0.82rem;
}

.mention-dropdown-item:hover,
.mention-dropdown-item.active {
    background-color: #0d6efd;
    color: #fff;
}

/* Document & Link items */
.doc-item, .link-item {
    display: flex;
    align-items: center;
    padding: 5px 8px;
    background: #f8f9fa;
    border-radius: 4px;
    margin-bottom: 4px;
    font-size: 0.8rem;
}

.doc-item:hover, .link-item:hover {
    background: #e9ecef;
}

.doc-item .doc-info, .link-item .link-info {
    flex-grow: 1;
    min-width: 0;
}

.doc-item .doc-name, .link-item .link-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-item .doc-meta, .link-item .link-meta {
    font-size: 0.7rem;
    color: #888;
}

/* Activity Log */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.8rem;
}

.activity-item:last-child { border-bottom: none; }

.activity-icon {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    font-size: 0.85rem;
}

.activity-detail {
    flex: 1;
    min-width: 0;
}

.activity-text { display: block; line-height: 1.3; }
.activity-extra {
    display: block;
    font-size: 0.72rem;
    color: #888;
    font-style: italic;
}

.activity-time {
    display: block;
    font-size: 0.7rem;
    color: #aaa;
}

/* Comment input area */
.comment-input-area {
    padding: 8px 16px;
    border-top: 1px solid #e9ecef;
    background: #fff;
    position: sticky;
    bottom: 0;
}

.comment-input-area textarea {
    resize: none;
    font-size: 0.82rem;
}

/* Upload area */
.upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 6px;
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background-color 0.2s;
}

.upload-area:hover {
    border-color: #0d6efd;
    background-color: #f8f9fa;
}

/* Cards hover */
.card { transition: box-shadow 0.2s; }
a.card:hover { box-shadow: 0 3px 8px rgba(0,0,0,0.1); }

/* Admin table tweaks */
.table .btn-group-sm .btn {
    padding: 0.1rem 0.25rem;
    font-size: 0.7rem;
}

/* Drag and Drop */
.drag-handle {
    cursor: grab;
    color: #adb5bd;
    font-size: 0.85rem;
    padding: 2px 4px;
    user-select: none;
}
.drag-handle:hover { color: #495057; }
.drag-handle:active { cursor: grabbing; }
tr.task-row.dragging { opacity: 0.4; background: #e9ecef; }
tr.task-row.drag-over { border-top: 2px solid #0d6efd !important; }
tr.task-row.drag-over-below { border-bottom: 2px solid #0d6efd !important; }

/* ============================================
   Mobile Sidebar Toggle Button
   ============================================ */
.sidebar-toggle-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1045;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #0d6efd;
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.4);
    font-size: 1.2rem;
    transition: transform 0.2s, box-shadow 0.2s;
}

.sidebar-toggle-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 18px rgba(13, 110, 253, 0.5);
}

.sidebar-toggle-btn:active {
    transform: scale(0.95);
}

/* Mobile sidebar backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    top: 48px;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1039;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-backdrop.show {
    display: block;
    opacity: 1;
}

/* ============================================
   Maintenance Tracker — Heatmap Grid
   ============================================ */

.hm-table { font-size: 0.82rem; border-collapse: separate; border-spacing: 0; }

.hm-table thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    color: #6c757d;
    padding: 8px 6px !important;
    background: #f8f9fa;
    border-bottom: 2px solid #dee2e6;
    position: sticky;
    top: 0;
    z-index: 2;
}

.hm-task-header { white-space: nowrap; }

.hm-month-header {
    min-width: 72px;
    line-height: 1.2;
}

.hm-task-name {
    padding: 6px 10px !important;
    max-width: 220px;
    font-size: 0.82rem;
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
}

.hm-table tbody tr:hover .hm-task-name,
.hm-table tbody tr:hover .hm-freq-col {
    background: #f8fafc;
}

.hm-freq-col {
    position: sticky;
    left: 200px;
    z-index: 1;
    background: #fff;
}

.hm-table thead th:nth-child(1) {
    position: sticky;
    left: 0;
    z-index: 3;
}

.hm-table thead th:nth-child(2) {
    position: sticky;
    left: 200px;
    z-index: 3;
}

.hm-cell {
    padding: 6px 4px !important;
    vertical-align: middle;
    position: relative;
    transition: background-color 0.15s;
}

.hm-cell:hover {
    background-color: #f0f4ff !important;
}

.hm-current-month {
    background-color: #fffbeb !important;
    border-left: 2px solid #f59e0b !important;
    border-right: 2px solid #f59e0b !important;
}

thead .hm-current-month {
    background-color: #fef3c7 !important;
    color: #92400e;
    font-weight: 700;
}

/* Status dots */
.hm-dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 0.78rem;
    font-weight: 700;
    line-height: 1;
    transition: transform 0.15s, box-shadow 0.15s;
}

.hm-dot:hover {
    transform: scale(1.1);
}

.hm-completed {
    background-color: #dcfce7;
    color: #16a34a;
    border: 1.5px solid #86efac;
}

.hm-missed {
    background-color: #fee2e2;
    color: #dc2626;
    border: 1.5px solid #fca5a5;
}

.hm-pending {
    background-color: #fef3c7;
    color: #d97706;
    border: 1.5px solid #fcd34d;
    animation: pulse-pending 2s ease-in-out infinite;
}

.hm-upcoming {
    background-color: #f1f5f9;
    color: #94a3b8;
    border: 1.5px solid #e2e8f0;
}

.hm-no-occurrence {
    background: transparent;
    color: #d1d5db;
    border: 1.5px dashed #e5e7eb;
    font-size: 0.7rem;
}

@keyframes pulse-pending {
    0%, 100% { box-shadow: 0 0 0 0 rgba(217, 119, 6, 0.2); }
    50% { box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.1); }
}

/* Multi-occurrence badge */
.hm-multi-badge {
    position: absolute;
    top: 2px;
    right: 4px;
    font-size: 0.55rem;
    background: #6366f1;
    color: #fff;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

/* Legend swatches */
.hm-cell-legend {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 4px;
}

.hm-cell-legend.hm-completed { background-color: #dcfce7; border: 1.5px solid #86efac; }
.hm-cell-legend.hm-missed { background-color: #fee2e2; border: 1.5px solid #fca5a5; }
.hm-cell-legend.hm-pending { background-color: #fef3c7; border: 1.5px solid #fcd34d; }
.hm-cell-legend.hm-upcoming { background-color: #f1f5f9; border: 1.5px solid #e2e8f0; }
.hm-cell-legend.hm-no-occurrence { background: transparent; border: 1.5px dashed #e5e7eb; }

/* Table row hover */
.hm-table tbody tr {
    transition: background-color 0.1s;
}

.hm-table tbody tr:hover {
    background-color: #f8fafc;
}



/* Nav collapse area — desktop default */
.nav-collapse-area {
    display: flex;
}

/* ============================================
   RESPONSIVE — Tablet (≤ 992px)
   ============================================ */
@media (max-width: 992px) {
    /* Navbar: collapse items into hamburger */
    .navbar .nav-collapse-area {
        display: none;
        position: absolute;
        top: 48px;
        left: 0;
        right: 0;
        background: #1a1d21;
        padding: 8px 0;
        flex-direction: column;
        gap: 0;
        box-shadow: 0 8px 24px rgba(0,0,0,0.4);
        z-index: 1060;
        border-top: 1px solid rgba(255,255,255,0.08);
    }

    .navbar .nav-collapse-area.show {
        display: flex;
    }

    /* Strip btn-outline styling on mobile and make clean nav links */
    .navbar .nav-collapse-area .nav-mobile-link {
        border: none !important;
        background: transparent !important;
        color: rgba(255,255,255,0.85) !important;
        text-align: left;
        width: 100%;
        padding: 10px 20px !important;
        font-size: 0.88rem !important;
        border-radius: 0 !important;
        display: flex;
        align-items: center;
        gap: 10px;
        transition: background 0.15s, color 0.15s;
        box-shadow: none !important;
    }

    .navbar .nav-collapse-area .nav-mobile-link:hover,
    .navbar .nav-collapse-area .nav-mobile-link:focus {
        background: rgba(255,255,255,0.08) !important;
        color: #fff !important;
    }

    .navbar .nav-collapse-area .nav-mobile-link:active {
        background: rgba(255,255,255,0.12) !important;
    }

    .navbar .nav-collapse-area .nav-mobile-link i {
        font-size: 1rem;
        width: 20px;
        text-align: center;
        opacity: 0.7;
    }

    /* Admin links: subtle amber accent */
    .navbar .nav-collapse-area .nav-mobile-link--admin {
        color: rgba(255, 193, 7, 0.9) !important;
        border-left: 3px solid rgba(255, 193, 7, 0.4) !important;
        border-radius: 0 !important;
    }

    .navbar .nav-collapse-area .nav-mobile-link--admin:hover {
        color: #ffc107 !important;
        border-left-color: #ffc107 !important;
        background: rgba(255, 193, 7, 0.08) !important;
    }

    .navbar .nav-collapse-area .nav-mobile-link--admin i {
        opacity: 0.85;
    }

    /* User info section at bottom */
    .navbar .nav-collapse-area .nav-user-info {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 20px;
        border-top: 1px solid rgba(255,255,255,0.1);
        margin-top: 4px;
    }

    .navbar .nav-collapse-area .nav-user-info .btn {
        border-color: rgba(255,255,255,0.2) !important;
        color: rgba(255,255,255,0.6) !important;
        font-size: 0.76rem !important;
        padding: 4px 12px !important;
    }

    .navbar .nav-collapse-area .nav-user-info .btn:hover {
        background: rgba(255,255,255,0.1) !important;
        color: #fff !important;
    }

    .navbar-toggler-mobile {
        display: flex !important;
    }

    /* Sidebar: overlay on mobile */
    .sidebar {
        width: 260px !important;
        min-width: 260px !important;
        position: fixed;
        z-index: 1040;
        height: calc(100vh - 48px);
        top: 48px;
        left: 0;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: none;
    }

    .sidebar.show {
        transform: translateX(0);
        box-shadow: 4px 0 16px rgba(0,0,0,0.15);
    }

    .sidebar-toggle-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    /* Task detail panel full width */
    #taskDetailPanel {
        width: 100% !important;
    }

    /* Task table: hide less important columns */
    .task-table .col-hide-tablet {
        display: none;
    }

    /* Heatmap: remove sticky columns on tablet */
    .hm-task-name {
        max-width: 160px;
    }
}


/* ============================================
   RESPONSIVE — Mobile (≤ 768px)
   ============================================ */
@media (max-width: 768px) {
    body {
        font-size: 0.82rem;
    }

    /* Navbar */
    .navbar {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Task panel */
    #taskPanel {
        padding: 12px !important;
    }

    /* Project header stacks vertically */
    .mobile-stack {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
    }

    /* Filter toolbar stacking */
    #taskToolbar,
    .filter-toolbar-mobile {
        flex-direction: column !important;
    }

    #taskToolbar > input,
    #taskToolbar > select,
    .filter-toolbar-mobile > input,
    .filter-toolbar-mobile > select {
        max-width: 100% !important;
        width: 100% !important;
    }

    #taskToolbar > .ms-auto,
    .filter-toolbar-mobile > .ms-auto {
        margin-left: 0 !important;
    }

    /* Task table mobile optimizations */
    .task-table {
        font-size: 0.78rem;
    }

    .task-table th,
    .task-table td {
        padding: 4px 6px !important;
    }

    /* Hide assigned & due columns on small mobile */
    .task-table .col-hide-mobile {
        display: none;
    }

    /* Make action buttons bigger for touch */
    .task-table .btn {
        min-width: 32px;
        min-height: 32px;
        padding: 4px 6px !important;
    }

    /* Subtask button always visible on mobile (no hover) */
    .subtask-add-btn {
        opacity: 0.6 !important;
    }

    /* On mobile, tree indentation is smaller */
    .tree-line {
        width: 14px;
    }

    /* Overview summary cards smaller */
    .overview-cards .card {
        min-width: 100px !important;
    }

    .overview-cards .card-body {
        padding: 8px 10px !important;
    }

    .overview-cards .fs-4 {
        font-size: 1.1rem !important;
    }

    /* Offcanvas: full width + proper sizing */
    .offcanvas-end {
        width: 100% !important;
    }

    /* Modal fullscreen on mobile */
    .modal-dialog {
        margin: 8px;
    }

    .modal-dialog-scrollable .modal-content {
        max-height: calc(100vh - 16px);
    }

    /* Heatmap mobile adjustments */
    .hm-task-name {
        max-width: 120px;
        font-size: 0.75rem;
        position: static; /* Remove sticky on mobile — it causes layout issues */
    }

    .hm-freq-col {
        position: static;
    }

    .hm-table thead th:nth-child(1),
    .hm-table thead th:nth-child(2) {
        position: static;
    }

    .hm-month-header {
        min-width: 60px;
    }

    .hm-dot {
        width: 24px;
        height: 24px;
        font-size: 0.7rem;
    }

    /* Login page */
    .card {
        margin: 0 12px;
    }

    /* Maintenance legend wraps */
    .legend-mobile {
        gap: 6px !important;
    }

    .legend-mobile > span {
        font-size: 0.72rem !important;
    }

    /* Admin pages */
    .container-fluid {
        padding: 12px !important;
    }

    .container-fluid h4 {
        font-size: 1rem;
    }

    /* Table action buttons wrap */
    .table td .btn {
        margin-bottom: 2px;
    }

    /* Admin stat cards */
    .admin-stat-cards .card-body {
        padding: 10px !important;
    }

    .admin-stat-cards h2 {
        font-size: 1.4rem;
    }
}


/* ============================================
   RESPONSIVE — Small Mobile (≤ 480px)
   ============================================ */
@media (max-width: 480px) {
    body {
        font-size: 0.78rem;
    }

    .navbar-brand {
        font-size: 0.85rem;
        max-width: 160px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Even tighter task table */
    .task-table {
        font-size: 0.74rem;
    }

    /* Hide status column too on very small screens */
    .task-table .col-hide-xs {
        display: none;
    }

    /* Overview table: hide project column */
    #overviewTable .col-hide-xs {
        display: none;
    }

    /* Very small modals */
    .modal-dialog {
        margin: 4px;
    }

    /* Sidebar narrower */
    .sidebar {
        width: 240px !important;
        min-width: 240px !important;
    }

    /* Floating action button repositioned */
    .sidebar-toggle-btn {
        bottom: 16px;
        left: 16px;
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
}

/* ============================================
   Navbar toggler (hamburger) — always hidden on desktop
   ============================================ */
.navbar-toggler-mobile {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 1.2rem;
    cursor: pointer;
    transition: background 0.2s;
}

.navbar-toggler-mobile:hover {
    background: rgba(255,255,255,0.1);
}

/* Safe area padding for notched devices */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .sidebar-toggle-btn {
        bottom: calc(20px + env(safe-area-inset-bottom));
    }

    .comment-input-area {
        padding-bottom: calc(8px + env(safe-area-inset-bottom));
    }
}
