/* Tailwind CSS Overrides and Layout Adjustments */

/* Main content area adjustment for fixed sidebar */
#main {
    margin-left: 280px;
    margin-top: 60px;
    padding: 24px;
    min-height: calc(100vh - 60px);
    background-color: #f9fafb;
    transition: margin-left 0.3s ease;
}

/* Sidebar visibility fix */
#sidebar {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

/* Fix for Bootstrap collapse in sidebar - ensure expanded items are visible */
#sidebar .collapse {
    display: none;
    visibility: hidden;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.35s ease, opacity 0.35s ease, visibility 0.35s ease;
}

#sidebar .collapse.show {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: 2000px !important;
    overflow: visible !important;
    height: auto !important;
}

#sidebar .collapse.collapsing {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    overflow: hidden;
    height: auto !important;
}

/* Ensure nested lists in sidebar are visible when parent is expanded */
#sidebar ul.collapse.show {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    max-height: 2000px !important;
    overflow: visible !important;
    height: auto !important;
}

#sidebar ul.collapse.show li {
    display: list-item !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 10 !important;
    height: auto !important;
    min-height: auto !important;
}

#sidebar ul.collapse.show li a {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: relative !important;
    z-index: 10 !important;
    height: auto !important;
    min-height: auto !important;
}

/* Override any Bootstrap or other CSS that might hide collapse elements */
#sidebar .collapse.show {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    max-height: 2000px !important;
}

#sidebar .collapse.show li {
    display: list-item !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
}

#sidebar .collapse.show a {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
}

/* Ensure sidebar has proper overflow to show all content */
#sidebar {
    overflow-y: auto !important;
    overflow-x: visible !important;
}

/* Prevent any element from hiding collapsed/expanded items */
#sidebar * {
    box-sizing: border-box;
}

/* Ensure all links in expanded collapse are clickable */
#sidebar .collapse.show a {
    pointer-events: auto !important;
    cursor: pointer !important;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    #main {
        margin-left: 0;
        padding: 16px;
    }
    
    #sidebar {
        transform: translateX(-100%);
    }
    
    #sidebar.show {
        transform: translateX(0);
    }
}

@media (min-width: 1025px) {
    #sidebar {
        transform: translateX(0) !important;
    }
}

/* Card modern styling */
.card-modern {
    background: white;
    border-radius: 12px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    border: 1px solid #e5e7eb;
    padding: 24px;
}

/* Form inputs modern styling */
.form-control-modern,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 16px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    transition: all 0.2s;
    background-color: white;
}

.form-control-modern:focus,
input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Button modern styling */
.btn-modern {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s;
    border: none;
    cursor: pointer;
}

.btn-modern-primary {
    background: linear-gradient(to right, #2563eb, #1d4ed8);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-modern-primary:hover {
    background: linear-gradient(to right, #1d4ed8, #1e40af);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    transform: translateY(-1px);
}

/* Table modern styling */
.table-modern {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

.table-modern thead {
    background-color: #f9fafb;
}

.table-modern thead th {
    padding: 12px 24px;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #374151;
    border-bottom: 2px solid #e5e7eb;
}

.table-modern tbody tr {
    transition: background-color 0.15s;
}

.table-modern tbody tr:hover {
    background-color: #f9fafb;
}

.table-modern tbody td {
    padding: 16px 24px;
    border-bottom: 1px solid #e5e7eb;
    color: #111827;
}

/* Badge modern styling */
.badge-modern {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 12px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Dropdown menu adjustments */
.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    margin-top: 8px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #e5e7eb;
    z-index: 50;
    min-width: 224px;
}

.dropdown-menu.show {
    display: block;
}

/* Relative positioning for dropdown parent */
nav ul li.relative {
    position: relative;
}

/* Sidebar scrollbar styling */
#sidebar {
    scrollbar-width: thin;
    scrollbar-color: #4b5563 transparent;
}

#sidebar::-webkit-scrollbar {
    width: 6px;
}

#sidebar::-webkit-scrollbar-track {
    background: transparent;
}

#sidebar::-webkit-scrollbar-thumb {
    background-color: #4b5563;
    border-radius: 3px;
}

#sidebar::-webkit-scrollbar-thumb:hover {
    background-color: #6b7280;
}

/* Active link indicator */
#sidebar a[class*="bg-blue-600"] {
    background: rgba(37, 99, 235, 0.2) !important;
    border-left-color: #3b82f6 !important;
}

/* Smooth transitions for chevron rotation */
#sidebar .bi-chevron-down {
    transition: transform 0.3s ease;
}

#sidebar [data-bs-toggle="collapse"][aria-expanded="true"] .bi-chevron-down,
#sidebar .collapse.show ~ a .bi-chevron-down {
    transform: rotate(180deg);
}

/* Hover effects enhancement */
#sidebar a:hover {
    transform: translateX(2px);
}

/* Card info styling */
#sidebar .bg-gray-800 {
    backdrop-filter: blur(10px);
}

/* Animation for sidebar toggle */
#sidebar {
    transition: transform 0.3s ease;
}

/* Page title styling */
.pagetitle {
    margin-bottom: 24px;
}

.pagetitle h1 {
    font-size: 28px;
    font-weight: 700;
    color: #111827;
    margin-bottom: 8px;
}

/* Section spacing */
.section {
    margin-bottom: 24px;
}

/* Chart container */
.chart-container {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
    border: 1px solid #e5e7eb;
    margin-bottom: 24px;
    min-height: 400px;
}

.chart-container-lg {
    min-height: 500px;
}

/* Highcharts container adjustments */
.highcharts-container {
    width: 100% !important;
    height: 100% !important;
}

/* Grid system compatibility */
.grid {
    display: grid;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

.grid-cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-cols-3 {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

@media (min-width: 768px) {
    .md\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    .md\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
    
    .lg\:grid-cols-3 {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
    
    .lg\:col-span-1 {
        grid-column: span 1 / span 1;
    }
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

.gap-6 {
    gap: 1.5rem;
}

.space-y-1 > * + * {
    margin-top: 0.25rem;
}

.space-y-2 > * + * {
    margin-top: 0.5rem;
}

.space-y-4 > * + * {
    margin-top: 1rem;
}

.mb-6 {
    margin-bottom: 1.5rem;
}

.mb-4 {
    margin-bottom: 1rem;
}

.mt-4 {
    margin-top: 1rem;
}

/* Responsive adjustments for main content */
@media (max-width: 1024px) {
    #main {
        margin-left: 0 !important;
        padding: 16px !important;
    }
    
    #sidebar {
        transform: translateX(-100%);
    }
    
    #sidebar.show {
        transform: translateX(0);
    }
}

/* Ensure grid works on all browsers */
@supports (display: grid) {
    .grid {
        display: grid;
    }
}

/* Highcharts responsive */
.highcharts-container {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: 100%;
    text-align: left;
    line-height: normal;
    z-index: 0;
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    font-family: "Lucida Grande", "Lucida Sans Unicode", Arial, Helvetica, sans-serif;
    font-size: 12px;
}

/* Ensure cards have proper spacing */
.bg-white.rounded-xl {
    margin-bottom: 1.5rem;
}

/* Fix for radio buttons in Tailwind */
input[type="radio"]:checked + label {
    background-color: rgba(255, 255, 255, 0.4) !important;
    border-color: white !important;
}

