/**
 * Main Application Styles
 */

:root {
    --sidebar-width: 250px;
    --topbar-height: 60px;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
}

/* Sidebar */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: white;
    color: #2c3e50;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 2px 0 8px rgba(0,0,0,0.05);
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.sidebar-header .dashboard-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-header .dashboard-logo-icon {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
}

.sidebar-header .dashboard-logo-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: #2c3e50;
}

.sidebar-nav {
    padding: 0.5rem 0;
}

.sidebar-nav .nav-link {
    color: #4b5563;
    padding: 0.875rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav .nav-link:hover {
    background-color: #f9fafb;
    color: #667eea;
}

.sidebar-nav .nav-link.active {
    background-color: #eff6ff;
    color: #667eea;
    border-left-color: #667eea;
    font-weight: 600;
}

.sidebar-nav .nav-link .icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-divider {
    height: 1px;
    background-color: #e5e7eb;
    margin: 0.5rem 1.5rem;
}

/* Submenu Styles */
.nav-item-with-submenu {
    position: relative;
}

.nav-item-with-submenu .nav-link {
    position: relative;
}

.nav-item-with-submenu .submenu-arrow {
    margin-left: auto;
    font-size: 0.75rem;
    transition: transform 0.3s;
}

.nav-item-with-submenu:has(.submenu.show) .submenu-arrow {
    transform: rotate(180deg);
}

.submenu {
    display: none;
    background-color: #f9fafb;
    padding: 0.25rem 0;
    margin-left: 1.5rem;
    border-left: 2px solid #e5e7eb;
}

.submenu.show {
    display: block;
}

.submenu-link {
    color: #6b7280;
    padding: 0.625rem 1.5rem 0.625rem 2.5rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.9rem;
}

.submenu-link:hover {
    background-color: #f3f4f6;
    color: #667eea;
}

.submenu-link.active {
    background-color: #eff6ff;
    color: #667eea;
    font-weight: 500;
}

.submenu-link .icon {
    font-size: 0.95rem;
    width: 18px;
    text-align: center;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 1rem;
    min-height: 100vh;
}

.topbar {
    background-color: white;
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.topbar h1 {
    margin: 0;
    font-size: 1.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Cards */
.card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

.card-header {
    padding: 1rem;
    border-bottom: 1px solid #e9ecef;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: 1rem;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

/* DataTables Pagination Alignment */
.dataTables_wrapper {
    display: flex;
    flex-direction: column;
}

.dataTables_wrapper .row {
    margin: 0;
}

.dataTables_wrapper .row:first-child {
    margin-bottom: 1rem;
}

/* Pagination row - align info and pagination on same line */
.dataTables_wrapper .row:last-child {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    margin-top: 1rem;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
    border-top: 1px solid #e5e7eb;
    width: 100%;
}

/* Ensure the row uses flexbox for proper alignment */
.dataTables_wrapper .row:last-child > div {
    margin: 0 !important;
    padding: 0 !important;
}

/* Left column - info text */
.dataTables_wrapper .row:last-child > div:first-child {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-right: auto !important;
    padding-right: 1rem !important;
}

/* Right column - pagination */
.dataTables_wrapper .row:last-child > div:last-child {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-left: auto !important;
    padding-left: 1rem !important;
}

/* Info text styling - left side */
.dataTables_info {
    padding: 0 !important;
    margin: 0 !important;
    color: #6b7280;
    font-size: 0.875rem;
    line-height: 1.5;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
}

/* Pagination controls styling - right side */
.dataTables_paginate {
    padding: 0 !important;
    margin: 0 !important;
    float: none !important;
    text-align: right !important;
    display: inline-block;
    vertical-align: middle;
}

.dataTables_paginate.paging_simple_numbers {
    display: inline-block !important;
}

.dataTables_paginate .pagination {
    margin: 0 !important;
    padding: 0 !important;
    display: inline-flex !important;
    align-items: center;
    vertical-align: middle;
    list-style: none;
}

.dataTables_paginate .pagination li {
    margin: 0 !important;
    display: inline-flex;
    align-items: center;
}

.dataTables_paginate .pagination li:not(:first-child) {
    margin-left: 0.25rem !important;
}

.dataTables_paginate .pagination li a.page-link {
    padding: 0.5rem 0.75rem;
    color: #6b7280;
    border: 1px solid #e5e7eb;
    border-radius: 0.375rem;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.5;
    min-height: auto;
    text-decoration: none;
    background-color: white;
    cursor: pointer;
}

.dataTables_paginate .pagination li a.page-link:hover:not(.disabled) {
    background-color: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
    z-index: 2;
}

.dataTables_paginate .pagination li.active a.page-link {
    background-color: #0d6efd;
    border-color: #0d6efd;
    color: white;
    z-index: 1;
}

.dataTables_paginate .pagination li.disabled a.page-link,
.dataTables_paginate .pagination li.disabled a.page-link:hover {
    color: #6c757d;
    pointer-events: none;
    background-color: white;
    border-color: #e5e7eb;
    cursor: not-allowed;
    opacity: 0.6;
}

/* Ensure both info and paginate are on same baseline */
.dataTables_wrapper .row:last-child .dataTables_info,
.dataTables_wrapper .row:last-child .dataTables_paginate {
    vertical-align: middle;
    line-height: 1.5;
}

/* Ensure pagination row is on same line on all screen sizes */
@media (max-width: 768px) {
    .dataTables_wrapper .row:last-child {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 0.75rem;
    }
    
    .dataTables_wrapper .row:last-child > div:first-child,
    .dataTables_wrapper .row:last-child > div:last-child {
        width: 100%;
        margin: 0 !important;
        padding: 0 !important;
        justify-content: flex-start !important;
    }
    
    .dataTables_paginate {
        width: 100%;
        text-align: left !important;
    }
    
    .dataTables_paginate .pagination {
        justify-content: flex-start;
    }
}

/* Forms */
.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
}

/* Loading */
#loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#loading .spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Breadcrumbs */
.breadcrumb {
    background-color: white;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
}

/* Charts */
.chart-container {
    position: relative;
    height: 300px;
    margin: 1rem 0;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
}

