/* hi-impact Portal Branding Styles */

:root {
    --hi-primary: #252B58;      /* Navy Blue - Headers, sidebar, primary buttons */
    --hi-secondary: #51B8B6;    /* Light Blue - Links, hover states, accents */
    --hi-accent-1: #F7931E;     /* Orange - Call-to-action buttons, highlights */
    --hi-accent-2: #D55559;     /* Red - Alerts, warnings, urgent items */
    --hi-light-bg: #F8F9FA;     /* Light background */
    --hi-white: #FFFFFF;
    --hi-dark-text: #212529;
    --hi-sidebar-width: 260px;
}

/* Body and main layout */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--hi-dark-text);
    background-color: var(--hi-light-bg);
}

/* Sidebar styles */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: var(--hi-sidebar-width);
    background-color: var(--hi-primary);
    color: var(--hi-white);
    overflow-y: auto;
    overflow-x: visible;
    /* Must sit above school-context tabs / dropdowns (z-index ~9998–10000)
       so condensed-mode tooltips are not covered by "School Details" etc.
       Still well below modal layers (1_000_000+). */
    z-index: 11000;
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.1);
    transition: width 0.3s ease;
    isolation: isolate;
}

/* Condensed sidebar state */
.sidebar.condensed {
    width: 70px;
}

.sidebar-header {
    padding: 1.5rem 1rem;
    background-color: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Sidebar toggle button */
.sidebar-toggle-btn {
    background: rgba(81, 184, 182, 0.2);
    border: 1px solid rgba(81, 184, 182, 0.4);
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.sidebar-toggle-btn:hover {
    background: rgba(81, 184, 182, 0.4);
    border-color: var(--hi-secondary);
}

.sidebar-toggle-btn i {
    transition: transform 0.3s ease;
}

/* Toggle icon rotation when condensed */
.sidebar.condensed .sidebar-toggle-btn i {
    transform: rotate(180deg);
}

.sidebar-header-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

/* Hide text content when condensed */
.sidebar.condensed .sidebar-header-content,
.sidebar.condensed .nav-toggle,
.sidebar.condensed .selected-school-info,
.sidebar.condensed .selected-school-name,
.sidebar.condensed .text-white-50,
.sidebar.condensed .school-search-box,
.sidebar.condensed .school-selector-actions {
    display: none !important;
}

/* Hide button text in condensed mode */
.sidebar.condensed button {
    font-size: 0;
}

.sidebar.condensed button i {
    font-size: 1rem;
}

.sidebar-brand {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--hi-white);
    text-decoration: none;
    display: block;
}

.sidebar-brand:hover {
    color: var(--hi-secondary);
}

.sidebar-brand-logo {
    display: block;
    width: 178px;
    max-width: 100%;
    height: auto;
}

.sidebar-nav {
    padding: 1rem 0;
}

.nav-item {
    margin: 0.25rem 0;
}

.nav-link {
    display: block;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--hi-white);
    border-left-color: var(--hi-secondary);
}

.nav-link.active {
    background-color: rgba(255, 255, 255, 0.15);
    color: var(--hi-white);
    border-left-color: var(--hi-accent-1);
    font-weight: 600;
}

.nav-link i {
    margin-right: 0.5rem;
    width: 20px;
    text-align: center;
}

/* Condensed sidebar nav links */
.sidebar.condensed .nav-link {
    padding: 0.75rem;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    position: relative;
    font-size: 0;
}

.sidebar.condensed .nav-link i {
    margin-right: 0;
    font-size: 1.3rem;
    display: block;
    width: 100%;
}

/* Submenu styles */
.nav-submenu {
    list-style: none;
    padding-left: 0;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.nav-submenu.show {
    max-height: 500px;
}

.nav-submenu .nav-link {
    padding-left: 2.5rem;
    font-size: 0.9rem;
}

/* Hide submenus when condensed */
.sidebar.condensed .nav-submenu {
    display: none;
}

/* Floating Tooltip System for Condensed Sidebar */
.sidebar.condensed .nav-item {
    position: relative;
}

/* Tooltip box */
.sidebar-tooltip {
    position: fixed;
    left: 80px;
    transform: translateY(-50%) translateX(-10px);
    background-color: var(--hi-primary);
    color: white;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease, transform 0.2s ease;
    z-index: 999999;
    pointer-events: auto;
    border: 1px solid rgba(81, 184, 182, 0.3);
    font-size: 1rem;
    display: block;
}

/* Show tooltip when marked as visible (controlled by JavaScript) */
.sidebar.condensed .sidebar-tooltip.tooltip-visible {
    opacity: 1 !important;
    visibility: visible !important;
    transform: translateY(-50%) translateX(0);
    pointer-events: auto;
    display: block !important;
}

/* Create invisible bridge between icon and tooltip to prevent flicker */
.sidebar.condensed .nav-item::after,
.sidebar.condensed .school-selector-container::after {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 350px;
    height: 100%;
    z-index: 9999;
    pointer-events: none;
}

/* Allow pointer events on the nav-item and tooltip */
.sidebar.condensed .nav-item:hover::after,
.sidebar.condensed .school-selector-container:hover::after {
    pointer-events: auto;
}

/* Hide tooltips when sidebar is not condensed */
.sidebar:not(.condensed) .sidebar-tooltip {
    display: none !important;
}

/* Ensure tooltips are visible in condensed mode (even when not hovering yet) */
.sidebar.condensed .sidebar-tooltip {
    display: block;
}

/* Tooltip title styling */
.tooltip-title {
    font-weight: 600;
    font-size: 1rem;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid rgba(81, 184, 182, 0.3);
}

/* Tooltip arrow pointing to icon */
.sidebar-tooltip::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    width: 0;
    height: 0;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 6px solid var(--hi-primary);
}

/* Submenu tooltip (nested) */
.sidebar-submenu-tooltip {
    position: relative;
    margin-top: 0.5rem;
    background-color: rgba(37, 43, 88, 0.98);
    padding: 0.5rem 0;
    border-radius: 6px;
    border: 1px solid rgba(81, 184, 182, 0.3);
    min-width: 200px;
}

/* Submenu tooltip is always visible when parent tooltip is visible */
.sidebar-submenu-tooltip {
    display: block;
}

/* Submenu tooltip items */
.sidebar-submenu-tooltip a {
    display: block;
    padding: 0.5rem 1rem;
    color: white;
    text-decoration: none;
    transition: background-color 0.2s ease;
    font-size: 0.95rem;
}

.sidebar-submenu-tooltip a:hover {
    background-color: rgba(81, 184, 182, 0.2);
}

.sidebar-submenu-tooltip a i {
    margin-right: 0.5rem;
    width: 20px;
    font-size: 1rem;
}

/* Remove submenu indicator since title and submenu are now integrated */
.tooltip-has-submenu::after {
    display: none;
}

/* School selector tooltip */
.school-selector-tooltip {
    display: flex !important;
    flex-direction: column;
    gap: 0.25rem;
    cursor: pointer;
}

.sidebar.condensed .school-selector-container:hover > .school-selector-tooltip {
    display: flex !important;
}

.school-selector-tooltip .school-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.school-selector-tooltip .hint-text {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.7);
    font-style: italic;
}

/* Make school selector clickable in condensed mode */
.sidebar.condensed .school-selector-container {
    cursor: pointer;
}

.sidebar.condensed .school-selector-container:hover {
    background-color: rgba(81, 184, 182, 0.1);
}

.nav-toggle {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.85);
    cursor: pointer;
    float: right;
    padding: 0.75rem 1rem;
    transition: transform 0.3s ease;
}

.nav-toggle.rotated {
    transform: rotate(180deg);
}

/* Main content area */
.main-content {
    margin-left: var(--hi-sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

/* Adjust main content when sidebar is condensed */
.sidebar.condensed ~ .main-content {
    margin-left: 70px;
}

/* Top header */
.top-header {
    background-color: var(--hi-white);
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.breadcrumb {
    background-color: transparent;
    margin-bottom: 0;
    padding: 0;
}

.breadcrumb-item a {
    color: var(--hi-secondary);
    text-decoration: none;
}

.breadcrumb-item a:hover {
    color: var(--hi-accent-1);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* School Context Tabs Navigation */
.school-context-tabs {
    background-color: white;
    border-bottom: 2px solid var(--hi-primary);
    padding: 0 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.nav-tabs-hi {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 0.5rem;
}

.nav-item-hi {
    position: relative;
}

.nav-link-hi {
    display: block;
    padding: 1rem 1.5rem;
    color: var(--hi-primary);
    text-decoration: none;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.nav-link-hi:hover {
    color: var(--hi-secondary);
    background-color: rgba(81, 184, 182, 0.1);
    border-bottom-color: var(--hi-secondary);
}

.nav-link-hi.active {
    color: var(--hi-accent-1);
    border-bottom-color: var(--hi-accent-1);
    font-weight: 600;
}

.nav-link-hi i {
    margin-right: 0.25rem;
}

/* Dropdown Styles for Assets Tab */
.dropdown-hi {
    position: relative;
    z-index: 9998;
}

.dropdown-menu-hi {
    position: absolute;
    top: 100%;
    left: 0;
    background-color: white;
    border: 1px solid rgba(37, 43, 88, 0.15);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    list-style: none;
    padding: 0.5rem 0;
    margin: 0;
    min-width: 220px;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.dropdown-hi:hover .dropdown-menu-hi {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item-hi {
    display: block;
    padding: 0.75rem 1.25rem;
    color: var(--hi-primary);
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.dropdown-item-hi:hover {
    background-color: rgba(81, 184, 182, 0.1);
    color: var(--hi-secondary);
}

.dropdown-item-hi i {
    margin-right: 0.5rem;
    width: 20px;
    text-align: center;
}

.dropdown-divider-hi {
    margin: 0.5rem 0;
    border: 0;
    border-top: 1px solid rgba(37, 43, 88, 0.1);
}

/* Nested dropdown submenu */
.dropdown-submenu-hi {
    position: relative;
}

.dropdown-menu-nested-hi {
    position: absolute;
    left: 100%;
    top: 0;
    background-color: white;
    border: 1px solid rgba(37, 43, 88, 0.15);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    list-style: none;
    padding: 0;
    margin: 0;
    min-width: 250px;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: all 0.3s ease;
}

.dropdown-submenu-hi:hover > .dropdown-menu-nested-hi {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
}

/* Chevron indicator for items with submenus */
.dropdown-submenu-hi > .dropdown-item-hi .bi-chevron-right {
    font-size: 0.8rem;
    opacity: 0.6;
    transition: opacity 0.2s ease;
}

.dropdown-submenu-hi:hover > .dropdown-item-hi .bi-chevron-right {
    opacity: 1;
}

/* Responsive adjustments for tabs */
@media (max-width: 992px) {
    .school-context-tabs {
        padding: 0 1rem;
    }
    
    .nav-tabs-hi {
        flex-wrap: wrap;
    }
    
    .nav-link-hi {
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }
}

/* Content container */
.content-container {
    flex: 1;
    padding: 2rem;
}

/* Footer */
.main-footer {
    background-color: var(--hi-white);
    padding: 1.5rem 2rem;
    text-align: center;
    color: #6c757d;
    border-top: 1px solid #dee2e6;
}

/* Buttons */
.btn-hi-primary {
    background-color: var(--hi-primary);
    color: var(--hi-white);
    border: none;
}

.btn-hi-primary:hover {
    background-color: #1a1f3d;
    color: var(--hi-white);
}

.btn-hi-secondary {
    background-color: var(--hi-secondary);
    color: var(--hi-white);
    border: none;
}

.btn-hi-secondary:hover {
    background-color: #3d9c9a;
    color: var(--hi-white);
}

.btn-hi-action {
    background-color: var(--hi-accent-1);
    color: var(--hi-white);
    border: none;
}

.btn-hi-action:hover {
    background-color: #d67c15;
    color: var(--hi-white);
}

.btn-hi-alert {
    background-color: var(--hi-accent-2);
    color: var(--hi-white);
    border: none;
}

.btn-hi-alert:hover {
    background-color: #b84448;
    color: var(--hi-white);
}

/* Cards */
.card-hi {
    border: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

.card-hi-header {
    background-color: var(--hi-primary);
    color: var(--hi-white);
    border-radius: 8px 8px 0 0;
    padding: 1rem 1.5rem;
    font-weight: 600;
}

/* Links */
a {
    color: var(--hi-secondary);
}

a:hover {
    color: var(--hi-accent-1);
}

/* Maintenance message */
.maintenance-message {
    text-align: center;
    padding: 4rem 2rem;
    background-color: var(--hi-white);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 2rem auto;
    max-width: 600px;
}

.maintenance-message h2 {
    color: var(--hi-accent-1);
    margin-bottom: 1rem;
}

.maintenance-message p {
    color: #6c757d;
    font-size: 1.1rem;
}

/* Stats cards */
.stat-card {
    background-color: var(--hi-white);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    text-align: center;
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.stat-card-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--hi-primary);
}

.stat-card-label {
    font-size: 1rem;
    color: #6c757d;
    margin-top: 0.5rem;
}

.stat-card.primary {
    border-top: 4px solid var(--hi-primary);
}

.stat-card.secondary {
    border-top: 4px solid var(--hi-secondary);
}

.stat-card.accent {
    border-top: 4px solid var(--hi-accent-1);
}

.stat-card.alert {
    border-top: 4px solid var(--hi-accent-2);
}

/* Quick action buttons */
.quick-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: 2rem;
}

.quick-action-btn {
    flex: 1;
    min-width: 200px;
    padding: 1.5rem;
    text-align: center;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.quick-action-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.quick-action-btn i {
    display: block;
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* Responsive design */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.show {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-toggle {
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 1001;
        background-color: var(--hi-primary);
        color: var(--hi-white);
        border: none;
        padding: 0.5rem 1rem;
        border-radius: 4px;
    }
}

/* Page titles */
.page-title {
    color: var(--hi-primary);
    font-weight: 700;
    margin-bottom: 1.5rem;
}

/* Tables */
.table-hi {
    background-color: var(--hi-white);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.table-hi thead {
    background-color: var(--hi-primary);
    color: var(--hi-white);
}

.table-hi thead th {
    border: none;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
}

.table-hi tbody tr:hover {
    background-color: rgba(81, 184, 182, 0.1);
}

/* School Context Badge */
.selected-school-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: rgba(81, 184, 182, 0.15);
    border-left: 3px solid var(--hi-secondary);
    border-radius: 4px;
    color: var(--hi-primary);
    font-size: 0.9rem;
}

.selected-school-badge i {
    margin-right: 0.5rem;
    color: var(--hi-secondary);
    font-size: 1.1rem;
}

.selected-school-badge strong {
    color: var(--hi-primary);
    font-weight: 600;
}

/* School Dropdown Selector in Top Header */
.selected-school-dropdown-container {
    display: inline-flex;
    align-items: center;
    padding: 0.5rem 1rem;
    background-color: rgba(81, 184, 182, 0.15);
    border-left: 3px solid var(--hi-secondary);
    border-radius: 4px;
    color: var(--hi-primary);
    font-size: 0.9rem;
}

.selected-school-dropdown-container i {
    margin-right: 0.5rem;
    color: var(--hi-secondary);
    font-size: 1.1rem;
}

.selected-school-dropdown-container select {
    border: 1px solid rgba(81, 184, 182, 0.3);
    background-color: white;
    color: var(--hi-primary);
    font-weight: 600;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.selected-school-dropdown-container select:hover {
    border-color: var(--hi-secondary);
    box-shadow: 0 0 0 0.15rem rgba(81, 184, 182, 0.2);
}

.selected-school-dropdown-container select:focus {
    border-color: var(--hi-secondary);
    box-shadow: 0 0 0 0.25rem rgba(81, 184, 182, 0.25);
    outline: none;
}

/* ── Modal z-index overrides ──────────────────────────────────────────────────
   The top-nav dropdowns and sidebar tooltip use very high z-indexes (up to
   999999). Override Bootstrap's modal/backdrop z-indexes so modals always
   appear on top of every navigation element.
   Also hide sidebar tooltips while a modal is open to prevent bleed-through.
   ─────────────────────────────────────────────────────────────────────────── */
.modal-backdrop { z-index: 1000000 !important; }
.modal          { z-index: 1000001 !important; }

body.modal-open .sidebar-tooltip,
body.modal-open .dropdown-menu-hi,
body.modal-open .dropdown-menu-nested-hi { visibility: hidden !important; opacity: 0 !important; }
