/* Main Layout */
html, body {
    height: 100%;
    margin: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden; /* Prevent horizontal scrolling */
    overflow-y: auto; /* Ensure vertical scrolling is enabled */
}

.content-wrap {
    flex: 1 1 auto; /* Allow flex grow and shrink */
    padding-top: 56px;
    padding-bottom: 120px; /* Add padding for footer space */
    margin-left: 250px;
    transition: all 0.3s;
    width: calc(100% - 250px);
    min-height: calc(100vh - 176px); /* Account for header (56px) and footer (120px) */
    max-width: 100%;
    overflow-y: auto; /* Ensure content can scroll */
}

body.has-sidebar {
    position: relative;
}

/* Sidebar styles */
.sidebar {
    width: 250px;
    height: calc(100vh - 56px);
    position: fixed;
    top: 56px;
    left: 0;
    background: #343a40;
    color: #fff;
    transition: all 0.3s;
    z-index: 1000;
    overflow-y: auto;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
}

.sidebar-header {
    padding: 20px;
    background: #2c3034;
    border-bottom: 1px solid #495057;
}

.sidebar-header h5 {
    color: #fff;
    margin: 0;
}

.sidebar ul.components {
    padding: 20px 0;
}

.sidebar ul li a {
    padding: 10px 20px;
    display: block;
    color: #adb5bd;
    text-decoration: none;
    transition: all 0.3s;
    position: relative;
}

.sidebar ul li a:hover {
    color: #fff;
    background: #495057;
}

.sidebar ul li a i {
    margin-right: 10px;
    color: #6c757d;
}

.sidebar ul li a:hover i {
    color: #fff;
}

.sidebar ul li.active > a {
    color: #fff;
    background: #007bff;
}

.sidebar ul li.active > a i {
    color: #fff;
}

.sidebar ul ul a {
    padding-left: 40px;
    font-size: 0.9em;
    background: #2c3034;
}

/* Collapsed sidebar */
body.sidebar-collapsed .content-wrap {
    margin-left: 70px;
    width: calc(100% - 70px);
}

body.sidebar-collapsed .sidebar {
    width: 70px;
    overflow: visible;
}

body.sidebar-collapsed .sidebar-header {
    display: none;
}

body.sidebar-collapsed .sidebar ul li a {
    position: relative;
    padding: 15px 0;
    display: flex;
    justify-content: center;
    align-items: center;
    white-space: nowrap;
}

/* Collapsed sidebar - hide text spans */
body.sidebar-collapsed .sidebar ul li a span {
    display: none !important;
}

body.sidebar-collapsed .sidebar ul li a i {
    margin: 0;
    font-size: 1.3em;
    width: 100%;
    text-align: center;
}

/* CSS tooltip for collapsed sidebar */
body.sidebar-collapsed .sidebar ul li a:hover::after {
    content: attr(data-title);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    background: #495057;
    color: white;
    padding: 5px 10px;
    border-radius: 3px;
    margin-left: 10px;
    white-space: nowrap;
    z-index: 1000;
    box-shadow: 2px 2px 5px rgba(0,0,0,0.2);
}

body.sidebar-collapsed .sidebar ul li .dropdown-toggle::after {
    display: none;
}

/* Mobile styles */
@media (max-width: 992px) {
    body.sidebar-collapsed .sidebar {
        width: 250px;
    }
    
    body.sidebar-collapsed .sidebar ul li a {
        justify-content: flex-start;
        padding: 10px 20px;
    }
    
    body.sidebar-collapsed .sidebar ul li a span {
        display: inline !important;
    }
    
    body.sidebar-collapsed .sidebar ul li a i {
        margin-right: 10px;
        width: auto;
        text-align: left;
    }
    
    /* Hide tooltip on mobile */
    body.sidebar-collapsed .sidebar ul li a:hover::after {
        display: none;
    }
}

/* Navigation */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1050;
    height: 56px;
}

.navbar-brand {
    display: flex;
    align-items: center;
}

.navbar-brand .logo {
    height: 35px;
    transition: all 0.3s ease;
}

.navbar-brand .brand-text {
    margin-left: 90px;
    margin-top: 10px;
    font-size: 1.25rem;
    color: white;
}


/* Company selector in header */
.navbar .company-selector-header {
    margin-right: 15px;
}

.navbar .company-selector-header select {
    background: rgba(255,255,255,0.2);
    color: white;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 4px;
    padding: 5px 10px;
    /* Add arrow indicator */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="white" width="18px" height="18px"><path d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 30px;
}

/* Dropdown options styling */
.navbar .company-selector-header select option {
    background: #343a40; /* Dark background */
    color: white; /* White text */
}

/* Focus state */
.navbar .company-selector-header select:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255,255,255,0.3);
}

/* For Firefox - ensure options are visible */
@-moz-document url-prefix() {
    .navbar .company-selector-header select {
        color: white !important;
        text-shadow: 0 0 0 white;
    }
}

/* For IE11 - ensure options are visible */
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
    .navbar .company-selector-header select {
        color: white;
    }
    .navbar .company-selector-header select option {
        background: #343a40;
        color: white;
    }
}


/* Footer */
.footer {
    background-color: #f8f9fa;
    border-top: 1px solid #dee2e6;
    padding: 1px 0;
    transition: all 0.3s;
    position: fixed;
    bottom: 0;
    margin-left: 250px;
    width: calc(100% - 250px);
    z-index: 100;
    margin-top: 0px;
    clear: both;
    
}

body.sidebar-collapsed .footer {
    margin-left: 70px;
    width: calc(100% - 70px);
}

/* Mobile styles */
@media (max-width: 992px) {
    .content-wrap {
        margin-left: 0 !important;
        width: 100% !important;
        padding-top: 56px;
        min-height: calc(100vh - 116px); /* Adjusted for mobile */
    }
    
    .footer {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* Hide sidebar by default on mobile */
    .sidebar {
        transform: translateX(-100%);
        width: 250px !important;
        z-index: 1040;
    }
    
    /* Show sidebar when active */
    body.sidebar-active .sidebar {
        transform: translateX(0);
    }
    
    /* Add overlay when sidebar is active */
    .sidebar-overlay {
        content: '';
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.5);
        z-index: 1030;
        display: none;
    }
    
    body.sidebar-active .sidebar-overlay {
        display: block;
    }
    
    /* Make sure sidebar toggler is visible */
    .sidebar-toggler {
        display: block !important;
    }
    
    /* Ensure submenu functionality works on mobile */
    .sidebar ul li a[data-toggle="collapse"] {
        cursor: pointer;
    }
    
    .sidebar .collapse {
        transition: height 0.35s ease;
    }
}

/* Sidebar Toggler Button */
.sidebar-toggler {
    display: inline-block !important;
    cursor: pointer;
    border: none;
    background: transparent;
    padding: 0.5rem;
    color: rgba(255,255,255,.5);
    transition: all 0.3s ease;
    order: -1; /* Ensure it appears first */
    margin-right: 10px;
}

.sidebar-toggler:hover {
    color: rgba(255,255,255,.75);
}

.sidebar-toggler:focus {
    outline: none;
    color: rgba(255,255,255,.75);
}

/* Make sure it's visible on all screens */
@media (max-width: 992px) {
    .sidebar-toggler {
        display: inline-block !important;
    }
}

/* Navbar brand positioning adjustment */
.navbar-brand {
    margin-left: 10px;
}

.navbar-brand .brand-text {
    margin-left: 15px;
    margin-top: 0;
}

/* Fix for login page footer */
body:not(.has-sidebar) .footer {
    margin-left: 0;
    width: 100%;
}

/* Login page specific styles */
body:not(.has-sidebar) .container {
    transform: translateX(-250px);
    max-width: calc(100% - 250px);
    width: auto;
}

/* Mobile responsiveness for login */
@media (max-width: 991.98px) {
    body:not(.has-sidebar) .container {
        transform: translateX(0);
        max-width: 100%;
        width: 100%;
        margin-left: 0;
    }
}
.footer img {
    height: 30px;
}

.footer .text-muted {
    color: #6c757d !important;
}

/* Dark mode styles */
@media (prefers-color-scheme: dark) {
    body:not(.light-mode) {
        background-color: #343a40;
        color: #f8f9fa;
    }
    
    body:not(.light-mode) .navbar-dark .navbar-brand .logo {
        content: url("../images/logo-w.png");
    }
    
    body:not(.light-mode) .footer {
        background-color: #2c3034;
        border-top-color: #495057;
    }
    
    body:not(.light-mode) .sidebar {
        background: #2c3034;
    }
    
    body:not(.light-mode) .sidebar-header {
        background: #212529;
    }
    
    body:not(.light-mode) .content-wrap {
        background-color: #343a40;
    }
    
    /* Adjust tooltip color in dark mode */
    body:not(.light-mode).sidebar-collapsed .sidebar ul li a:hover::after {
        background: #343a40;
    }
}

/* Force white logo in dark navbar */
.navbar-dark .navbar-brand .logo {
    content: url("../images/logo-w.png");
}

/* Default light logo */
.logo {
    content: url("../images/logo.png");
}

/* Smooth transitions */
.sidebar,
.content-wrap,
.footer {
    transition: all 0.3s ease;
}