/* =====================================================
   Clinical Trac - Sidebar Navigation Styles
   ===================================================== */

:root {
    --sidebar-width: 210px;
    --sidebar-collapsed-width: 60px;
    --navbar-height: 65px;
    --navbar-bg: #ffffff;
    --navbar-border: #e0e0e0;
    --transition-speed: 0.3s;

    /* Light Mode (Default) - White sidebar */
    --sidebar-bg: #ffffff;
    --sidebar-text: #4a5568;
    --sidebar-icon: #64748b;
    --sidebar-hover: rgba(45, 138, 238, 0.08);
    --sidebar-hover-text: #2D8AEE;
    --sidebar-active-bg: #e8f4fd;
    --sidebar-active-text: #2D8AEE;
    --sidebar-border: #e2e8f0;
    --sidebar-header-border: #e2e8f0;
}

/* Dark Mode - Dark sidebar */
body.sidebar-dark-mode {
    --sidebar-bg: #1e2530;
    --sidebar-text: #e2e8f0;
    --sidebar-icon: #94a3b8;
    --sidebar-hover: rgba(255, 255, 255, 0.08);
    --sidebar-hover-text: #ffffff;
    --sidebar-active-bg: #2D8AEE;
    --sidebar-active-text: #ffffff;
    --sidebar-border: rgba(255, 255, 255, 0.1);
    --sidebar-header-border: rgba(255, 255, 255, 0.1);
}

/* Dark Mode - Icon filters and specific overrides */
body.sidebar-dark-mode .nav-item img {
    filter: brightness(0) invert(1);
}

body.sidebar-dark-mode .sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* =====================================================
   Layout Wrapper
   ===================================================== */
.app-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Main content wrapper styles are defined in "Main Content Adjustments" section */

/* =====================================================
   Top Navbar
   ===================================================== */
.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: var(--navbar-bg);
    border-bottom: 1px solid var(--navbar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 1200;
    transition: height 0.3s ease, box-shadow 0.3s ease;
}

/* Navbar Logo */
.navbar-brand-logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    flex-shrink: 0;
}

.navbar-logo {
    height: 50px;
    width: auto;
    max-width: 200px;
    object-fit: contain;
}

/* Scrolled state - subtle shadow only, no height change to avoid sidebar gap */
.top-navbar.scrolled {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Navbar is always full width - no sidebar offset needed */

.navbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.navbar-left a {
    color: #1E88E5;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
}

.navbar-left a:hover {
    text-decoration: underline;
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.navbar-datetime {
    color: #666;
    font-size: 13px;
}

.navbar-icon {
    color: #666;
    font-size: 20px;
    cursor: pointer;
    position: relative;
    padding: 5px;
    transition: color 0.2s ease;
}

.navbar-icon:hover {
    color: #1E88E5;
}

.navbar-icon .badge {
    position: absolute;
    top: -2px;
    right: -2px;
    background: #f44336;
    color: white;
    font-size: 10px;
    padding: 2px 5px;
    border-radius: 10px;
    min-width: 16px;
    text-align: center;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 5px 10px;
    border-radius: 20px;
    transition: background 0.2s ease;
}

.navbar-user:hover {
    background: #f5f5f5;
}

.navbar-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #1E88E5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.navbar-user-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.navbar-user-name {
    font-size: 14px;
    font-weight: 500;
    color: #333;
}

.navbar-user-dropdown {
    font-size: 12px;
    color: #666;
}

/* =====================================================
   Sidebar - Gmail-like Hover Behavior
   ===================================================== */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: var(--sidebar-collapsed-width);
    height: calc(100vh - var(--navbar-height));
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    z-index: 1100;
    transition: width var(--transition-speed) ease, background var(--transition-speed) ease;
    overflow: visible;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--sidebar-border);
}

/* Expanded state - on hover or when pinned */
body.sidebar-hovered .sidebar,
body.sidebar-pinned .sidebar {
    width: var(--sidebar-width);
}

/* Legacy collapsed class for compatibility */
body.sidebar-collapsed .sidebar {
    width: var(--sidebar-collapsed-width);
    overflow: visible;
}

/* Sidebar Header (logo moved to top navbar — hidden) */
.sidebar-header {
    display: none;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--sidebar-text);
    overflow: hidden;
}

body.sidebar-collapsed .sidebar-brand {
    justify-content: center;
}

.sidebar-logo {
    width: 40px;
    height: auto;
    min-width: 40px;
    max-height: 40px;
    object-fit: contain;
    transition: all var(--transition-speed) ease;
}

/* Expanded logo */
body.sidebar-hovered .sidebar-logo,
body.sidebar-pinned .sidebar-logo {
    width: 120px;
    min-width: 120px;
    max-height: 60px;
}

body.sidebar-collapsed .sidebar-logo {
    width: 40px;
    height: auto;
    min-width: 40px;
    max-height: 40px;
}

.sidebar-title {
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    width: 0;
    display: none;
    transition: opacity var(--transition-speed) ease;
}

/* Show title when expanded */
body.sidebar-hovered .sidebar-title,
body.sidebar-pinned .sidebar-title {
    opacity: 1;
    width: auto;
    display: block;
}

body.sidebar-collapsed .sidebar-title {
    opacity: 0;
    width: 0;
    display: none;
}

/* Sidebar Toggle Button - HIDDEN for Gmail-like hover behavior */
.sidebar-toggle {
    display: none !important;
}

/* Pin Button - Appears when sidebar is expanded */
.pin-button {
    position: absolute;
    top: 10px;
    right: 15px;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--sidebar-icon);
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    opacity: 0;
    z-index: 10;
}

.pin-button:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-hover-text);
}

.pin-button i {
    font-size: 16px;
    transition: transform 0.2s ease;
}

/* Show pin button when sidebar is expanded (hovered or pinned) */
body.sidebar-hovered .pin-button,
body.sidebar-pinned .pin-button {
    opacity: 1;
}

/* Pinned state - rotate the pin icon */
body.sidebar-pinned .pin-button i {
    transform: rotate(45deg);
    color: var(--sidebar-active-text);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 10px 0;
}

body.sidebar-collapsed .sidebar-nav {
    overflow-y: auto;
    /* Keep scrolling enabled when collapsed */
    overflow-x: visible;
    /* Allow tooltips to show horizontally */
}

.sidebar-nav::-webkit-scrollbar {
    display: none;
}

.sidebar-nav {
    scrollbar-width: none;
    /* Firefox */
    -ms-overflow-style: none;
    /* IE/Edge */
}

/* Menu Category */
.nav-category {
    padding: 15px 5px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--sidebar-icon);
    white-space: nowrap;
    overflow: hidden;
    text-align: center;
}

.nav-category span {
    display: none;
}

.nav-category::after {
    content: "•••";
    font-size: 8px;
    letter-spacing: 2px;
}

/* Show category text when expanded */
body.sidebar-hovered .nav-category,
body.sidebar-pinned .nav-category {
    padding: 15px 20px 8px;
    text-align: left;
}

body.sidebar-hovered .nav-category span,
body.sidebar-pinned .nav-category span {
    display: inline;
}

body.sidebar-hovered .nav-category::after,
body.sidebar-pinned .nav-category::after {
    content: "";
}

body.sidebar-collapsed .nav-category {
    text-align: center;
    padding: 15px 5px 8px;
}

body.sidebar-collapsed .nav-category span {
    display: none;
}

body.sidebar-collapsed .nav-category::after {
    content: "•••";
    font-size: 8px;
    letter-spacing: 2px;
}

/* Nav Items */
.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s ease;
    position: relative;
    white-space: nowrap;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    border-left-color: transparent;
    text-decoration: none;
    color: var(--sidebar-hover-text);
}

.nav-item:hover i {
    color: var(--sidebar-hover-text);
}

.nav-item.active {
    background: var(--sidebar-active-bg);
    border-left-color: transparent;
    border-radius: 8px;
    margin: 4px 4px;
    padding: 12px 15px;
    color: var(--sidebar-active-text);
}

.nav-item.active i {
    color: var(--sidebar-active-text);
}

.nav-item.active:hover {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    filter: brightness(0.95);
}

.nav-item i {
    font-size: 20px;
    min-width: 24px;
    text-align: center;
    margin-right: 15px;
}

.nav-item img {
    width: 20px;
    height: 20px;
    min-width: 20px;
    margin-right: 15px;
    filter: brightness(0);
}

.nav-item span {
    font-size: 14px;
    opacity: 0;
    width: 0;
    overflow: hidden;
    transition: opacity var(--transition-speed) ease;
}

/* Show nav item text when expanded */
body.sidebar-hovered .nav-item span,
body.sidebar-pinned .nav-item span {
    opacity: 1;
    width: auto;
    overflow: visible;
}

/* Collapsed state icons centered */
.nav-item {
    justify-content: center;
    padding: 12px;
}

.nav-item i {
    margin-right: 0;
}

.nav-item img {
    margin-right: 0;
}

/* Expanded state icons with margin */
body.sidebar-hovered .nav-item,
body.sidebar-pinned .nav-item {
    justify-content: flex-start;
    padding: 12px 20px;
}

body.sidebar-hovered .nav-item i,
body.sidebar-pinned .nav-item i {
    margin-right: 15px;
}

body.sidebar-hovered .nav-item img,
body.sidebar-pinned .nav-item img {
    margin-right: 15px;
}

body.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 12px;
}

body.sidebar-collapsed .nav-item i {
    margin-right: 0;
}

body.sidebar-collapsed .nav-item img {
    margin-right: 0;
}

body.sidebar-collapsed .nav-item span {
    opacity: 0;
    width: 0;
    overflow: hidden;
}

/* CSS tooltips removed - using JavaScript tooltips instead for better scroll support */

/* =====================================================
   Main Content Adjustments
   ===================================================== */
.main-content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-collapsed-width);
    transition: margin-left var(--transition-speed) ease;
    min-height: 100vh;
    padding-top: var(--navbar-height);
    overflow-x: hidden;
    width: calc(100% - var(--sidebar-collapsed-width));
    box-sizing: border-box;
}

/* Expanded state */
body.sidebar-pinned .main-content-wrapper {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
}

body.sidebar-collapsed .main-content-wrapper {
    margin-left: var(--sidebar-collapsed-width);
    width: calc(100% - var(--sidebar-collapsed-width));
}

/* Ensure containers within main content fit properly */
.main-content-wrapper .container {
    width: 100%;
    max-width: 100%;
    padding-left: 15px;
    padding-right: 15px;
    box-sizing: border-box;
}

.main-content-wrapper .container-fluid {
    width: 100%;
    padding-left: 15px;
    padding-right: 15px;
    box-sizing: border-box;
}

/* Breadcrumb adjustments */
.main-content-wrapper .breadcrumb-bg {
    margin-left: 0;
    margin-right: 0;
    width: 100%;
}

/* Fix table and card overflow */
.main-content-wrapper .table-responsive {
    overflow-x: auto;
}

.main-content-wrapper .panel,
.main-content-wrapper .card {
    max-width: 100%;
    overflow: hidden;
}

/* Dashboard specific adjustments */
.main-content-wrapper .main-body {
    width: 100%;
    padding: 0 15px;
    box-sizing: border-box;
}

.main-content-wrapper .parent-col {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.main-content-wrapper .dashboard-graph-section {
    width: 100%;
    max-width: 100%;
}

/* Form and page content adjustments */
.main-content-wrapper .row {
    margin-left: 0;
    margin-right: 0;
}

.main-content-wrapper .row.margin_zero {
    margin-left: 0;
    margin-right: 0;
}

/* Prevent horizontal scroll on body */
html,
body {
    overflow-x: hidden;
}

/* Graph adjustments */
.main-content-wrapper .graph-card {
    max-width: 100%;
    overflow: hidden;
}

.main-content-wrapper canvas {
    max-width: 100% !important;
}

.page-content {
    padding-top: 20px;
    min-height: calc(100vh - var(--navbar-height));
}

/* Hide old header styles when sidebar is active */
body.has-sidebar #top-bar-header-bg {
    display: none;
}

/* =====================================================
   Responsive Design
   ===================================================== */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        top: 0;
        height: 100vh;
        z-index: 1300;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
        width: var(--sidebar-width);
    }

    /* Show nav text when sidebar is open on mobile */
    body.sidebar-open .nav-item {
        justify-content: flex-start;
        padding: 12px 20px;
    }

    body.sidebar-open .nav-item span {
        opacity: 1;
        width: auto;
        overflow: visible;
    }

    body.sidebar-open .nav-item i {
        margin-right: 15px;
    }

    body.sidebar-open .nav-item img {
        margin-right: 15px;
    }

    body.sidebar-open .pin-button {
        display: none;
    }

    .main-content-wrapper {
        margin-left: 0 !important;
        width: 100% !important;
    }

    .top-navbar {
        left: 0 !important;
        padding: 0 10px;
    }

    .mobile-toggle {
        display: flex !important;
    }

    /* Hide the sidebar toggle button on mobile - use hamburger menu instead */
    .sidebar-toggle {
        display: none !important;
    }

    /* Hide datetime on small screens to save space */
    .navbar-datetime {
        display: none;
    }

    .navbar-right {
        gap: 10px;
    }

    .navbar-user-name {
        display: none;
    }

    .navbar-logo {
        height: 40px;
        max-width: 140px;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1250;
    }

    body.sidebar-open .sidebar-overlay {
        display: block;
    }
}

@media (min-width: 993px) {
    .mobile-toggle {
        display: none !important;
    }

    .sidebar-overlay {
        display: none !important;
    }
}

/* Mobile Toggle Button */
.mobile-toggle {
    background: none;
    border: none;
    color: #666;
    font-size: 24px;
    cursor: pointer;
    padding: 5px;
    display: none;
}

/* =====================================================
   User Dropdown Menu
   ===================================================== */
.user-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 200px;
    padding: 8px 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1100;
}

.navbar-user.active .user-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: #333;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s ease;
}

.user-dropdown-menu a:hover {
    background: #f5f5f5;
}

.user-dropdown-menu .divider {
    height: 1px;
    background: #e0e0e0;
    margin: 8px 0;
}

.user-dropdown-menu .user-email {
    padding: 10px 16px;
    font-size: 12px;
    color: #666;
}

/* =====================================================
   Sidebar Footer & Theme Toggle
   ===================================================== */
.sidebar-footer {
    /* padding: 15px;
    border-top: 1px solid var(--sidebar-header-border); */
    margin-top: auto;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 2px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease;
}

.theme-toggle:hover {
    background: var(--sidebar-hover);
}

.theme-toggle i {
    font-size: 18px;
    color: var(--sidebar-icon);
    min-width: 20px;
}

.theme-label {
    font-size: 14px;
    color: var(--sidebar-text);
    flex: 1;
    white-space: nowrap;
}

/* Toggle Switch Styles */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    min-width: 44px;
    background-color: #cbd5e1;
    border-radius: 24px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.toggle-slider {
    position: absolute;
    height: 18px;
    width: 18px;
    left: 3px;
    top: 3px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Dark mode active state - toggle is ON */
body.sidebar-dark-mode .toggle-switch {
    background-color: #2D8AEE;
}

body.sidebar-dark-mode .toggle-slider {
    transform: translateX(20px);
}

/* Collapsed sidebar footer */
/* Collapsed state - hide theme label and switch */
.theme-label,
.toggle-switch {
    display: none;
}

.theme-toggle {
    justify-content: center;
    padding: 3px;
}

/* Expanded state - show theme label and switch */
body.sidebar-hovered .theme-label,
body.sidebar-hovered .toggle-switch,
body.sidebar-pinned .theme-label,
body.sidebar-pinned .toggle-switch {
    display: block;
}

body.sidebar-hovered .theme-toggle,
body.sidebar-pinned .theme-toggle {
    justify-content: flex-start;
    padding: 2px 12px;
}



body.sidebar-collapsed .theme-toggle {
    justify-content: center;
    padding: 3px;
}

body.sidebar-collapsed .theme-label,
body.sidebar-collapsed .toggle-switch {
    display: none;
}

/* Dark mode icon update */
body.sidebar-dark-mode .theme-toggle i {
    color: #fbbf24;
}

#notification-count {
    position: absolute;
    left: -7px;
    top: -3px;
    font-size: 11px;
    color: #de5050;
    font-weight: bold;
}