/* Custom Modern Styling for Movix Income Share Management System */

html, body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden !important;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

*, ::before, ::after {
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #2b3674;
    background-color: #f4f7fe !important;
}

/* Wrapper & Layout Structure */
.wrapper, .main-wrapper {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    position: relative;
}

/* Sidebar Navigation Base */
.sidebar, .sidebar-nav, #sidebar {
    width: 260px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    background: #1e293b;
    overflow-y: auto;
    transition: left 0.3s ease-in-out;
}

/* Sidebar Backdrop Overlay for Mobile */
.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    display: none;
}

.sidebar-backdrop.show {
    opacity: 1;
    visibility: visible;
    display: block !important;
}

/* Main Content Wrapper for Desktop */
.main-content {
    margin-left: 260px;
    width: calc(100% - 260px);
    max-width: calc(100% - 260px);
    min-height: 100vh;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Responsive Mobile Layout (max-width: 991.98px) */
@media (max-width: 991.98px) {
    .sidebar, .sidebar-nav, #sidebar {
        left: -260px;
        z-index: 1050;
    }

    .sidebar.show, .sidebar-nav.show, #sidebar.show {
        left: 0 !important;
    }

    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Adjust main content padding & margins on mobile */
    main.container-fluid {
        padding: 0.85rem !important;
    }

    .card {
        margin-bottom: 0.85rem;
    }

    .card-body {
        padding: 0.85rem;
    }

    .stat-card {
        padding: 0.85rem !important;
    }

    /* Responsive Typography */
    h4, .fs-4 {
        font-size: 1.25rem !important;
    }
    h3, .fs-3 {
        font-size: 1.4rem !important;
    }
    h2, .fs-2 {
        font-size: 1.6rem !important;
    }
    h1, .fs-1 {
        font-size: 1.8rem !important;
    }
}

/* Navbar */
.navbar {
    z-index: 1030;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: visible !important;
}

.navbar,
.topbar,
.dropdown,
#topbarUserDropdown,
.navbar .container-fluid,
.navbar-nav,
.user-dropdown,
.navbar-collapse {
    max-height: none !important;
    overflow: visible !important;
    overflow-y: visible !important;
    overflow-x: visible !important;
}

.dropdown-menu,
.navbar .dropdown-menu,
.dropdown-menu-end {
    max-height: none !important;
    height: auto !important;
    overflow: visible !important;
    overflow-y: visible !important;
    z-index: 1070 !important;
    position: absolute !important;
    margin-top: 0.5rem;
}

.dropdown-item, .nav-link, .btn {
    touch-action: manipulation;
}

/* Container & Row Overflow Constraints */
main.container-fluid, .container-fluid {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

.row {
    max-width: 100%;
}

/* Sidebar Links */
.sidebar-nav .nav-link, .sidebar .nav-link {
    font-size: 0.88rem;
    font-weight: 500;
    padding: 0.65rem 0.9rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
}

.sidebar-nav .nav-link:hover, .sidebar .nav-link:hover {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.1);
}

.sidebar-nav .nav-link.active, .sidebar .nav-link.active {
    box-shadow: 0 4px 12px rgba(13, 110, 253, 0.3);
}

/* Stat Cards */
.stat-card {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.06);
}

.stat-icon {
    width: 52px;
    height: 52px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

/* Dynamic Percentage Balance Meter */
.share-meter-card {
    border-radius: 1rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
}

.progress-share-bar {
    height: 12px;
    border-radius: 6px;
}

/* Chart Container Heights */
.chart-container {
    position: relative;
    width: 100%;
    max-width: 100%;
    height: 280px;
    max-height: 280px;
    overflow: hidden;
}

@media (min-width: 992px) {
    .chart-container {
        height: 380px;
        max-height: 380px;
    }
}

/* Tables & Responsive Touch Scroll */
.table-responsive {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
    max-width: 100%;
    margin-bottom: 0.5rem;
}

.table-responsive .table {
    white-space: nowrap;
}

.table-custom {
    border-collapse: separate;
    border-spacing: 0;
}

.table-custom thead th {
    background-color: #f8fafc;
    color: #475569;
    font-size: 0.75rem;
    font-weight: 700;
    text-uppercase: uppercase;
    letter-spacing: 0.05em;
    padding: 0.85rem 1rem;
    border-bottom: 2px solid #e2e8f0;
}

.table-custom tbody tr {
    transition: background-color 0.15s ease;
}

.table-custom tbody tr:hover {
    background-color: #f1f5f9;
}

.table-custom td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    font-size: 0.88rem;
    border-bottom: 1px solid #f1f5f9;
}

.table-custom tfoot tr {
    background-color: #f8fafc !important;
}

.table-custom tfoot td {
    background-color: #f8fafc !important;
    padding: 0.85rem 1rem;
    vertical-align: middle;
    border-top: 2px solid #e2e8f0;
    border-bottom: none;
    font-size: 0.85rem;
}

/* Table Sort Headers Styling */
.sortable-header {
    cursor: pointer !important;
    user-select: none;
    -webkit-user-select: none;
    transition: background-color 0.15s ease-in-out, color 0.15s ease-in-out;
}

.sortable-header:hover {
    background-color: #e2e8f0 !important;
    color: #0d6efd !important;
}

.sortable-header[data-sort-dir] {
    background-color: #eff6ff !important;
    color: #0d6efd !important;
}

.sort-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    line-height: 1;
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.sortable-header:hover .sort-indicator {
    opacity: 1 !important;
}

/* Compact Fit-to-Width Dashboard Table Styling */
.table-fit {
    table-layout: fixed;
    width: 100% !important;
    margin-bottom: 0;
}

.table-fit th,
.table-fit td {
    white-space: normal !important;
    word-wrap: break-word;
    overflow-wrap: break-word;
    padding: 0.75rem 0.85rem;
}

.table-dashboard-compact th {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    white-space: nowrap !important;
}

.table-dashboard-compact td {
    font-size: 0.85rem;
}

.avatar-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    user-select: none;
}

/* Print Media Query */
@media print {
    body {
        background-color: #ffffff !important;
    }
    .sidebar-nav, .sidebar, #sidebar, .navbar, .btn-print-hide, .footer, .alert {
        display: none !important;
    }
    .main-content {
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    .card {
        border: 1px solid #ddd !important;
        box-shadow: none !important;
    }
}
