/**
 * Layout CSS
 * Contains styles for the main page layout structure, sidebar, content area and footer
 */

/* Global layout variables */
:root {
    --header-height: 60px;
    --footer-height: 60px;
    --sidebar-width: 240px;
    --content-padding: 10px;
}

/* Main Layout Structure */
html {
    height: 100%;
    overflow-x: hidden;
}

body {
    min-height: 100%;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    position: relative;
}

/* Main Content Area */
.main-content {
    flex: 1;
    min-height: calc(100vh - var(--header-height) - var(--footer-height));
    margin-top: var(--header-height);
    padding-top: 20px; /* Increased from 10px to 20px for more spacing */
    transition: margin-left 0.3s ease, width 0.3s ease;
    position: relative;
    width: 100%; /* Ensure no extra width */
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

/* Create visual header separation */
.main-content::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background-color: var(--border-color);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

/* Sidebar toggle states for content area */
html[data-toggled="close"] .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    transition: margin-left 0.3s ease, width 0.3s ease;
}

html[data-toggled="open"] .main-content {
    margin-left: var(--sidebar-width) !important;
    width: calc(100% - var(--sidebar-width)) !important;
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Footer positioning based on sidebar state */
html[data-toggled="close"] .footer {
    margin-left: 0;
    width: 100%;
    transition: margin-left 0.3s ease, width 0.3s ease;
}

html[data-toggled="open"] .footer {
    margin-left: var(--sidebar-width);
    width: calc(100% - var(--sidebar-width));
    transition: margin-left 0.3s ease, width 0.3s ease;
}

/* Footer positioning */
.footer {
    min-height: var(--footer-height);
    transition: margin-left 0.3s ease, width 0.3s ease;
    margin-left: var(--sidebar-width); /* Using variable */
    width: calc(100% - var(--sidebar-width)); /* Using variable */
}

/* Responsive layout adjustments */
@media (max-width: 991.98px) {
    .main-content,
    .footer {
        margin-left: 0;
        width: 100%;
    }
    
    /* Force sidebar closed on mobile */
    html[data-toggled="open"] .app-sidebar {
        transform: translateX(0);
        visibility: visible;
    }
    
    html[data-toggled="close"] .app-sidebar {
        transform: translateX(-100%);
        visibility: hidden;
    }
}

/* Container adjustments */
.container-fluid {
    width: 100%;
    max-width: 100vw;
    padding: 10px; /* Consistent 10px padding */
    margin-top: 10px; /* Additional top margin */
    margin-right: auto;
    margin-left: auto;
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

@media (max-width: 767.98px) {
    .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Page transition effects */
.page-transition-fade {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

/* Fix for overlapping elements */
.z-index-high {
    z-index: 1030;
}

.z-index-higher {
    z-index: 1040;
}

.z-index-highest {
    z-index: 1050;
}

/* Overlay for mobile sidebar */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1020;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

@media (max-width: 991.98px) {
    html[data-toggled="open"] .sidebar-overlay {
        opacity: 1;
        visibility: visible;
    }
}

/* Sidebar styles */
.app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    height: 100%;
    z-index: 1000;
    background-color: var(--sidebar-background, #212529);
    transition: transform 0.3s ease, visibility 0.3s ease;
    overflow-y: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.main-sidebar-header {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: var(--header-height);
    background-color: var(--sidebar-background, #212529);
    z-index: 1001;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: none !important;;
    transition: transform 0.3s ease;
}

.main-sidebar {
    padding-top: var(--header-height);
    height: 100%;
    transition: transform 0.3s ease;
}

/* Sidebar toggle states */
[data-toggled="close"] .app-sidebar,
[data-toggled="close"] .main-sidebar,
[data-toggled="close"] .main-sidebar-header {
    transform: translateX(calc(-1 * var(--sidebar-width)));
}

[data-toggled="open"] .app-sidebar,
[data-toggled="open"] .main-sidebar,
[data-toggled="open"] .main-sidebar-header {
    transform: translateX(0);
}

/* Media queries for responsive layout */
@media (max-width: 992px) {
    /* Mobile layout adjustments */
    .main-content.app-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .footer {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    [data-toggled="open"] .main-content.app-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    [data-toggled="close"] .main-content.app-content {
        margin-left: 0;
        width: 100%;
        padding: 1rem !important;
    }
    
    [data-toggled="open"] .footer,
    [data-toggled="close"] .footer {
        margin-left: 0;
        width: 100%;
    }
    
    /* Fix mobile navigation */
    .app-sidebar {
        z-index: 1050;
    }
}

/* Ensure page header is fully visible */
.page-header, .page-title, .dashboard-content > h1, .dashboard-content > h2 {
    margin-top: 0;
    padding-top: 0;
    position: relative;
    z-index: 2; /* Ensure it's above any overlapping elements */
}

/* Calendar page specific adjustments */
.dashboard-content {
    width: 100%;
    padding: 1.5rem 0; /* Updated to match the py-4 class (1.5rem) */
    margin: 0;
}

/* Calendar page title and buttons */
.calendar-header, 
.agenda-header,
.dashboard-content > .row:first-child,
.dashboard-content > h2:first-child,
.dashboard-content > .d-flex:first-child {
    margin-top: 0;
    padding-top: 0.5rem;
    margin-bottom: 1.25rem; /* Add bottom margin to push content down */
    position: relative;
    z-index: 10; /* Ensure above other elements */
    width: 100%;
}

/* Specific adjustments for card elements */
.dashboard-content .card {
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.05);
    border-radius: 0.375rem;
    overflow: hidden;
}

.dashboard-content .card-header {
    padding: 1rem 1.25rem;
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.page-header-breadcrumb {
    padding: 0.5rem 0;
    margin-top: 1rem; /* Add additional space at the top */
    margin-bottom: 1.25rem;
}

/* Calendar page header tweaks */
.page-header + .row,
.page-header-breadcrumb + .row {
    margin-top: 0;
}

/* Calendar page specific styling */
.calendar-header {
    padding: 1.25rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* Calendar styles to ensure proper rendering with sidebar toggle */
.fc-scrollgrid {
    width: 100% !important;
    height: auto !important;
    transition: all 0.3s ease;
}

.fc-view-harness {
    transition: all 0.3s ease;
}

.fc .fc-daygrid-body {
    width: 100% !important;
}

.fc .fc-daygrid-body-balanced {
    width: 100% !important;
}

.fc .fc-daygrid-body-unbalanced {
    width: 100% !important;
}

/* Fix table and cell borders */
.fc-theme-standard .fc-scrollgrid,
.fc-theme-standard td,
.fc-theme-standard th {
    border-collapse: collapse !important;
}

/* Main content padding to account for fixed header */
.app-content {
    padding-top: var(--content-padding, 20px);
    padding-bottom: var(--content-padding, 10px);
    padding-left: var(--content-padding, 20px);
    padding-right: var(--content-padding, 20px);
    margin-top: var(--header-height);
    transition: margin-left 0.3s ease, padding 0.3s ease;
} 