/**
 * Rise CRM – Modern SaaS Dashboard (scoped under .custom-modern-theme)
 * Do NOT override core structural classes (display, visibility, overflow, width).
 * Only add colors, shadows, spacing, and typography.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Poppins:wght@400;500;600;700&display=swap');
/* Cairo for Arabic – multiple weights (400, 600, 700) */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;600;700&display=swap');

:root {
    --rise-primary: #522B84;
    --rise-primary-light: rgba(82, 43, 132, 0.12);
    --rise-primary-soft: rgba(82, 43, 132, 0.08);
    --rise-accent: #E63B5D;
    --rise-accent-light: rgba(230, 59, 93, 0.12);
    --rise-accent-soft: rgba(230, 59, 93, 0.08);
    --rise-white: #FFFFFF;
    --rise-bg: #F8FAFC;
    --rise-bg-card: #FFFFFF;
    --rise-text: #1E293B;
    --rise-text-muted: #64748B;
    --rise-border: #E2E8F0;
    --rise-radius: 20px;
    --rise-radius-sm: 12px;
    --rise-shadow: 0 10px 30px rgba(82, 43, 132, 0.08);
    --rise-shadow-sm: 0 4px 12px rgba(82, 43, 132, 0.06);
    --rise-font: 'Inter', 'Poppins', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* ========== SIDEBAR: expanded state only (when NOT collapsed) ========== */
/* When sidebar is OPEN: show full logo above, all menu items. */
/* When sidebar is CLOSED (.sidebar-toggled): mini logo only (no cropped full logo). */

body.custom-modern-theme .sidebar {
    overflow: visible !important;
}

body.custom-modern-theme .sidebar .sidebar-scroll {
    overflow: auto !important;
    min-height: 0;
}

/* Expanded (no .sidebar-toggled): full logo visible above the menu – white area, Site Logo (175x40) */
body.custom-modern-theme:not(.sidebar-toggled) .sidebar .sidebar-brand.brand-logo,
body.custom-modern-theme:not(.sidebar-toggled) .sidebar a.brand-logo {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 250px !important;
    height: 65px !important;
    padding: 0.9rem 2.9rem !important;
    box-sizing: border-box !important;
    z-index: 1000 !important;
    text-align: center !important;
    background: #fff !important;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.08) !important;
}

/* RTL: sidebar is on the right, so logo must be fixed to the right */
html[dir="rtl"] body.custom-modern-theme:not(.sidebar-toggled) .sidebar .sidebar-brand.brand-logo,
html[dir="rtl"] body.custom-modern-theme:not(.sidebar-toggled) .sidebar a.brand-logo {
    left: auto !important;
    right: 0 !important;
}

body.custom-modern-theme:not(.sidebar-toggled) .sidebar .brand-logo img.dashboard-image {
    display: inline-block !important;
    visibility: visible !important;
    max-width: 250px !important;
    max-height: 40px !important;
    width: auto !important;
    height: auto !important;
}

body.custom-modern-theme:not(.sidebar-toggled) .sidebar .brand-logo-mini {
    display: none !important;
}

/* When collapsed (.sidebar-toggled): mini logo only */
body.custom-modern-theme.sidebar-toggled .sidebar .brand-logo {
    display: none !important;
}

body.custom-modern-theme.sidebar-toggled .sidebar .brand-logo-mini {
    display: block !important;
}

body.custom-modern-theme.sidebar-toggled .sidebar-brand {
    padding: 16px !important;
    width: 70px !important;
    box-sizing: border-box !important;
    background: #fff !important;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.08) !important;
}

body.custom-modern-theme.sidebar-toggled .sidebar .brand-logo-mini img.dashboard-image {
    max-width: 100%;
    height: auto;
    object-fit: contain;
}

/* RTL: collapsed sidebar brand (mini logo) also on the right */
html[dir="rtl"] body.custom-modern-theme.sidebar-toggled .sidebar .sidebar-brand,
html[dir="rtl"] body.custom-modern-theme.sidebar-toggled .sidebar .brand-logo-mini {
    left: auto !important;
    right: 0 !important;
}

/* All menu items visible when expanded (no display:none on li) */
body.custom-modern-theme .sidebar-menu li,
body.custom-modern-theme .sidebar-menu li.main {
    display: list-item !important;
    visibility: visible !important;
}

body.custom-modern-theme .sidebar-menu li a .menu-text,
body.custom-modern-theme .sidebar-menu li a span {
    display: inline !important;
    visibility: visible !important;
}

/* ---- Arabic: Cairo everywhere, no exception (dir/lang on <html>) ---- */
:root {
    --rise-font-ar: 'Cairo', sans-serif;
}

/* Body and every element use Cairo when RTL/Arabic (no exception) */
html[dir="rtl"] body.custom-modern-theme,
html[lang="ar"] body.custom-modern-theme {
    font-family: var(--rise-font-ar) !important;
}

/* Force Cairo on all descendants (overrides Open Sans / app.all.css fonts) */
html[dir="rtl"] body.custom-modern-theme *,
html[lang="ar"] body.custom-modern-theme * {
    font-family: var(--rise-font-ar) !important;
}

/* Explicit overrides for titles/headings (highest specificity) */
html[dir="rtl"] body.custom-modern-theme .page-title,
html[dir="rtl"] body.custom-modern-theme .card-title,
html[dir="rtl"] body.custom-modern-theme .modal-title,
html[dir="rtl"] body.custom-modern-theme h1,
html[dir="rtl"] body.custom-modern-theme h2,
html[dir="rtl"] body.custom-modern-theme h3,
html[dir="rtl"] body.custom-modern-theme h4,
html[dir="rtl"] body.custom-modern-theme h5,
html[dir="rtl"] body.custom-modern-theme h6,
html[dir="rtl"] body.custom-modern-theme .title,
html[dir="rtl"] body.custom-modern-theme th,
html[dir="rtl"] body.custom-modern-theme label,
html[dir="rtl"] body.custom-modern-theme .form-label,
html[dir="rtl"] body.custom-modern-theme .dropdown-menu,
html[dir="rtl"] body.custom-modern-theme .nav-link,
html[dir="rtl"] body.custom-modern-theme .btn,
html[dir="rtl"] body.custom-modern-theme input,
html[dir="rtl"] body.custom-modern-theme select,
html[dir="rtl"] body.custom-modern-theme textarea,
html[dir="rtl"] body.custom-modern-theme .table,
html[dir="rtl"] body.custom-modern-theme [class*="widget"],
html[dir="rtl"] body.custom-modern-theme [class*="poll"],
html[dir="rtl"] body.custom-modern-theme [class*="project"],
html[lang="ar"] body.custom-modern-theme .page-title,
html[lang="ar"] body.custom-modern-theme .card-title,
html[lang="ar"] body.custom-modern-theme .modal-title,
html[lang="ar"] body.custom-modern-theme h1,
html[lang="ar"] body.custom-modern-theme h2,
html[lang="ar"] body.custom-modern-theme h3,
html[lang="ar"] body.custom-modern-theme h4,
html[lang="ar"] body.custom-modern-theme h5,
html[lang="ar"] body.custom-modern-theme h6,
html[lang="ar"] body.custom-modern-theme .title,
html[lang="ar"] body.custom-modern-theme th,
html[lang="ar"] body.custom-modern-theme label,
html[lang="ar"] body.custom-modern-theme .form-label,
html[lang="ar"] body.custom-modern-theme .dropdown-menu,
html[lang="ar"] body.custom-modern-theme .nav-link,
html[lang="ar"] body.custom-modern-theme .btn,
html[lang="ar"] body.custom-modern-theme input,
html[lang="ar"] body.custom-modern-theme select,
html[lang="ar"] body.custom-modern-theme textarea,
html[lang="ar"] body.custom-modern-theme .table,
html[lang="ar"] body.custom-modern-theme [class*="widget"],
html[lang="ar"] body.custom-modern-theme [class*="poll"],
html[lang="ar"] body.custom-modern-theme [class*="project"] {
    font-family: var(--rise-font-ar) !important;
}

/* Placeholders and Select2 when RTL/Arabic */
html[dir="rtl"] body.custom-modern-theme input::placeholder,
html[dir="rtl"] body.custom-modern-theme textarea::placeholder,
html[lang="ar"] body.custom-modern-theme input::placeholder,
html[lang="ar"] body.custom-modern-theme textarea::placeholder {
    font-family: var(--rise-font-ar) !important;
}

html[dir="rtl"] body.custom-modern-theme .select2-container .select2-selection__rendered,
html[dir="rtl"] body.custom-modern-theme .select2-results__option,
html[lang="ar"] body.custom-modern-theme .select2-container .select2-selection__rendered,
html[lang="ar"] body.custom-modern-theme .select2-results__option {
    font-family: var(--rise-font-ar) !important;
}

html[dir="rtl"] body.custom-modern-theme b,
html[dir="rtl"] body.custom-modern-theme strong,
html[lang="ar"] body.custom-modern-theme b,
html[lang="ar"] body.custom-modern-theme strong {
    font-weight: 700 !important;
}

/* ---- Body & layout (cosmetic only) ---- */
body.custom-modern-theme {
    font-family: var(--rise-font) !important;
    background: var(--rise-bg) !important;
    color: var(--rise-text);
}

body.custom-modern-theme .scrollable-page,
body.custom-modern-theme .main-scrollable-page {
    background: var(--rise-bg) !important;
    padding: 24px 32px 32px !important;
    max-width: 1440px;
    margin: 0 auto;
}

body.custom-modern-theme .page-wrapper {
    padding: 0;
}

/* ---- Sidebar: colors and padding only (no width/display/overflow) ---- */
body.custom-modern-theme .sidebar {
    background: linear-gradient(180deg, var(--rise-primary) 0%, #3d2066 100%) !important;
    box-shadow: var(--rise-shadow) !important;
}

/* Site Logo (175x40) from Settings > General: show on white, no filter – same as login */
body.custom-modern-theme .sidebar .sidebar-brand.brand-logo,
body.custom-modern-theme:not(.sidebar-toggled) .sidebar a.brand-logo {
    background: #fff !important;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.08) !important;
}

body.custom-modern-theme .sidebar .brand-logo img.dashboard-image {
    filter: none !important;
    max-width: 175px !important;
    max-height: 40px !important;
    width: auto !important;
    height: auto !important;
    object-fit: contain !important;
}

/* Mini logo (collapsed): also original, no invert */
body.custom-modern-theme .sidebar .brand-logo-mini img.dashboard-image {
    filter: none !important;
}

/* Non-active items: primary #522B84 */
body.custom-modern-theme .sidebar-menu li:not(.active) > a {
    color: #522B84 !important;
    text-shadow: 0 0 1px rgba(255, 255, 255, 0.25);
}

body.custom-modern-theme .sidebar-menu li a {
    padding: 12px 20px !important;
    margin: 4px 12px;
    border-radius: var(--rise-radius-sm);
    transition: background 0.2s ease, color 0.2s ease;
}

body.custom-modern-theme .sidebar-menu li:not(.active) > a:hover {
    background: rgba(82, 43, 132, 0.5) !important;
    color: #fff !important;
}

body.custom-modern-theme .sidebar-menu li a:hover {
    background: rgba(255, 255, 255, 0.1) !important;
    color: #fff !important;
}

body.custom-modern-theme .sidebar-menu li.active > a,
body.custom-modern-theme .sidebar-menu li.active.expand > a {
    background: var(--rise-accent) !important;
    color: #fff !important;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(230, 59, 93, 0.35);
}

/* Non-active icon stroke (#522B84) */
body.custom-modern-theme .sidebar-menu li:not(.active) > a .icon {
    stroke: #522B84;
}

body.custom-modern-theme .sidebar-menu li a .icon {
    stroke-width: 1.8;
}

body.custom-modern-theme .sidebar-menu li.active > a .icon {
    stroke: #fff;
}

body.custom-modern-theme .sidebar-menu .badge {
    background: var(--rise-accent) !important;
    color: #fff !important;
    font-size: 0.7rem;
    padding: 2px 8px;
}

/* ---- Top bar: search, notification, avatar ---- */
body.custom-modern-theme .navbar-custom {
    background: var(--rise-white) !important;
    box-shadow: var(--rise-shadow-sm) !important;
    padding: 12px 24px !important;
    border-bottom: 1px solid var(--rise-border);
}

body.custom-modern-theme .navbar-custom .nav-link {
    color: var(--rise-text) !important;
    padding: 8px 12px !important;
    border-radius: var(--rise-radius-sm);
    transition: all 0.2s ease;
}

body.custom-modern-theme .navbar-custom .nav-link:hover {
    background: var(--rise-primary-soft) !important;
    color: var(--rise-primary) !important;
}

body.custom-modern-theme .navbar-custom .icon {
    stroke-width: 1.8;
}

/* ---- Cards: 20–24px radius, soft shadow, gradient top border ---- */
body.custom-modern-theme .card {
    background: var(--rise-bg-card) !important;
    border-radius: var(--rise-radius) !important;
    box-shadow: var(--rise-shadow) !important;
    border: none !important;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

body.custom-modern-theme .card:hover {
    box-shadow: 0 14px 40px rgba(82, 43, 132, 0.1) !important;
}

body.custom-modern-theme .card .card-body {
    padding: 24px !important;
}

/* KPI / stat cards with gradient top border */
body.custom-modern-theme .card.rise-kpi-card,
body.custom-modern-theme .rise-kpi-card {
    border-top: 4px solid transparent;
    border-image: linear-gradient(90deg, var(--rise-primary), var(--rise-accent)) 1;
}

body.custom-modern-theme .card.rise-kpi-card .card-body,
body.custom-modern-theme .rise-kpi-card .card-body {
    padding: 20px 24px !important;
}

/* ---- Dashboard grid & spacing (8pt) ---- */
body.custom-modern-theme .row {
    margin-left: -12px;
    margin-right: -12px;
}

body.custom-modern-theme .row > [class*="col-"] {
    padding-left: 12px;
    padding-right: 12px;
    margin-bottom: 24px;
}

/* ---- Buttons ---- */
body.custom-modern-theme .btn-primary {
    background: linear-gradient(135deg, var(--rise-primary) 0%, #6B3BA3 100%) !important;
    border: none !important;
    border-radius: var(--rise-radius-sm) !important;
    padding: 10px 20px;
    font-weight: 600;
    box-shadow: 0 4px 14px rgba(82, 43, 132, 0.35);
    transition: all 0.2s ease;
}

body.custom-modern-theme .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(82, 43, 132, 0.4) !important;
}

body.custom-modern-theme .btn-default {
    border-radius: var(--rise-radius-sm) !important;
    border-color: var(--rise-border);
    transition: all 0.2s ease;
}

body.custom-modern-theme .btn-default:hover {
    border-color: var(--rise-primary);
    color: var(--rise-primary);
    background: var(--rise-primary-soft) !important;
}

/* ---- Page titles ---- */
body.custom-modern-theme .page-title h1,
body.custom-modern-theme .page-title h4 {
    font-family: var(--rise-font) !important;
    font-weight: 700 !important;
    color: var(--rise-text) !important;
    letter-spacing: -0.02em;
}

body.custom-modern-theme .page-title {
    border-bottom: 1px solid var(--rise-border) !important;
    padding-bottom: 16px !important;
    margin-bottom: 24px !important;
}

/* ---- Tables: rounded rows, soft hover ---- */
body.custom-modern-theme .table-responsive {
    border-radius: var(--rise-radius-sm);
    overflow: hidden;
}

body.custom-modern-theme .table thead th {
    background: var(--rise-bg) !important;
    color: var(--rise-text-muted) !important;
    font-weight: 600;
    font-size: 0.8125rem;
    padding: 16px 20px !important;
    border: none !important;
    border-bottom: 1px solid var(--rise-border) !important;
}

body.custom-modern-theme .table tbody td {
    padding: 16px 20px !important;
    border-color: var(--rise-border) !important;
    vertical-align: middle !important;
}

body.custom-modern-theme .table tbody tr {
    transition: background 0.2s ease;
}

body.custom-modern-theme .table tbody tr:hover {
    background: var(--rise-primary-soft) !important;
}

body.custom-modern-theme .table tbody tr:first-child td:first-child {
    border-radius: var(--rise-radius-sm) 0 0 0;
}

/* ---- Status / activity badges ---- */
body.custom-modern-theme .badge,
body.custom-modern-theme .rise-badge {
    font-size: 0.75rem;
    font-weight: 500;
    padding: 4px 10px;
    border-radius: 20px;
}

body.custom-modern-theme .badge.bg-success,
body.custom-modern-theme .rise-badge-success {
    background: rgba(34, 197, 94, 0.15) !important;
    color: #16a34a !important;
}

body.custom-modern-theme .badge.bg-warning,
body.custom-modern-theme .rise-badge-warning {
    background: rgba(234, 179, 8, 0.2) !important;
    color: #ca8a04 !important;
}

body.custom-modern-theme .badge.bg-danger,
body.custom-modern-theme .rise-badge-danger {
    background: var(--rise-accent-soft) !important;
    color: var(--rise-accent) !important;
}

body.custom-modern-theme .badge.bg-primary,
body.custom-modern-theme .rise-badge-primary {
    background: var(--rise-primary-light) !important;
    color: var(--rise-primary) !important;
}

/* ---- List group (activity feed, etc.) ---- */
body.custom-modern-theme .list-group-item {
    border-color: var(--rise-border) !important;
    padding: 16px 20px !important;
    transition: background 0.2s ease;
}

body.custom-modern-theme .list-group-item:hover {
    background: var(--rise-bg) !important;
}

/* ---- Forms ---- */
body.custom-modern-theme .form-control {
    border-radius: var(--rise-radius-sm) !important;
    border-color: var(--rise-border);
    padding: 10px 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

body.custom-modern-theme .form-control:focus {
    border-color: var(--rise-primary) !important;
    box-shadow: 0 0 0 3px var(--rise-primary-soft) !important;
}

/* ---- Progress bars (purple/pink gradient) ---- */
body.custom-modern-theme .progress {
    height: 8px;
    border-radius: 8px;
    background: var(--rise-border) !important;
}

body.custom-modern-theme .progress-bar {
    background: linear-gradient(90deg, var(--rise-primary), var(--rise-accent)) !important;
    border-radius: 8px;
}

/* ---- Chart containers (for Chart.js) ---- */
body.custom-modern-theme .rise-chart-card {
    padding: 24px !important;
    min-height: 280px;
}

body.custom-modern-theme .rise-chart-card canvas {
    max-height: 260px;
}

/* ---- Profile / summary widget ---- */
body.custom-modern-theme .rise-profile-widget {
    background: var(--rise-bg-card);
    border-radius: var(--rise-radius);
    box-shadow: var(--rise-shadow);
    padding: 24px;
    border-top: 4px solid var(--rise-primary);
}

/* ---- Icons: consistent weight ---- */
body.custom-modern-theme [data-feather] {
    stroke-width: 1.8;
}

/* ---- Dropdowns ---- */
body.custom-modern-theme .dropdown-menu {
    border-radius: var(--rise-radius-sm) !important;
    box-shadow: var(--rise-shadow) !important;
    border: 1px solid var(--rise-border) !important;
}

body.custom-modern-theme .dropdown-item {
    padding: 10px 16px;
    transition: background 0.2s ease;
}

body.custom-modern-theme .dropdown-item:hover {
    background: var(--rise-primary-soft) !important;
    color: var(--rise-primary);
}

/* ---- Alerts ---- */
body.custom-modern-theme .alert {
    border-radius: var(--rise-radius-sm) !important;
    border: none;
}

/* ---- Avatar in topbar ---- */
body.custom-modern-theme .navbar-custom .avatar img {
    border-radius: 50%;
    border: 2px solid var(--rise-border);
}

body.custom-modern-theme .navbar-custom .user-name {
    font-weight: 500;
    color: var(--rise-text);
}

/* ---- DataTables (app table) ---- */
body.custom-modern-theme #project-table_wrapper .dataTables_wrapper,
body.custom-modern-theme .dataTables_wrapper {
    font-family: var(--rise-font);
}

body.custom-modern-theme .dataTables_filter input {
    border-radius: var(--rise-radius-sm) !important;
    border-color: var(--rise-border);
}

body.custom-modern-theme .dataTables_length select {
    border-radius: var(--rise-radius-sm) !important;
}

/* ========== Signin page: new UI, white screen, Site Logo 175x40 ========== */
body.custom-modern-theme.signin-page:not(.signin-with-bg) {
    background: #fff !important;
}
body.custom-modern-theme.signin-page {
    min-height: 100vh;
    font-family: var(--rise-font) !important;
}

body.custom-modern-theme.signin-page .scrollable-page {
    background: #fff !important;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

body.custom-modern-theme.signin-page .form-signin {
    width: 100%;
    max-width: 420px;
}

/* Site Logo from Settings > General > Site Logo (175x40) */
body.custom-modern-theme.signin-page .signin-logo {
    max-width: 175px;
    max-height: 40px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: inline-block;
}

body.custom-modern-theme.signin-page .signin-card {
    border-radius: var(--rise-radius) !important;
    box-shadow: var(--rise-shadow) !important;
    border: none !important;
    overflow: hidden;
}

body.custom-modern-theme.signin-page .signin-card-header {
    background: #fff !important;
    border-bottom: 1px solid var(--rise-border) !important;
    padding: 28px 24px !important;
}

body.custom-modern-theme.signin-page .signin-card .card-body {
    padding: 28px 24px !important;
}

body.custom-modern-theme.signin-page .btn-primary {
    background: var(--rise-primary) !important;
    border-color: var(--rise-primary) !important;
    border-radius: var(--rise-radius-sm) !important;
    padding: 12px 20px !important;
    font-weight: 600;
}

body.custom-modern-theme.signin-page .btn-primary:hover {
    background: #3d2066 !important;
    border-color: #3d2066 !important;
}

body.custom-modern-theme.signin-page .form-control {
    border-radius: var(--rise-radius-sm) !important;
    border: 1px solid var(--rise-border);
    padding: 12px 14px;
}

body.custom-modern-theme.signin-page .form-control:focus {
    border-color: var(--rise-primary) !important;
    box-shadow: 0 0 0 3px var(--rise-primary-soft) !important;
}

body.custom-modern-theme.signin-page a {
    color: var(--rise-primary) !important;
}

body.custom-modern-theme.signin-page a:hover {
    color: var(--rise-accent) !important;
}

body.custom-modern-theme.signin-page.signin-with-bg .scrollable-page {
    background: transparent !important;
}

/* ========== Mobile: sidebar open/close toggle always visible ========== */
/* Fixed mobile-only toggle – always visible on small screens, above navbar */
@media (max-width: 990px) {
    body.custom-modern-theme .mobile-sidebar-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 12px;
        left: 12px;
        z-index: 1100;
        width: 44px;
        height: 44px;
        background: var(--app-navbar-bg, #522b84);
        color: #fff;
        border-radius: 8px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.15);
        text-decoration: none;
    }
    body.custom-modern-theme .mobile-sidebar-toggle .icon {
        width: 22px;
        height: 22px;
    }
    html[dir="rtl"] body.custom-modern-theme .mobile-sidebar-toggle {
        left: auto;
        right: 12px;
    }
}
@media (min-width: 991px) {
    body.custom-modern-theme .mobile-sidebar-toggle {
        display: none !important;
    }
}

/* Mobile: only ONE sidebar toggle – the fixed button; hide topbar and sidebar-internal toggles */
@media (max-width: 990px) {
    body.custom-modern-theme .navbar-custom .nav-link.sidebar-toggle-btn {
        display: none !important;
    }
    body.custom-modern-theme .sidebar .sidebar-toggle-btn,
    body.custom-modern-theme .sidebar .sidebar-toggle-in-sidebar {
        display: none !important;
    }
}

/* Desktop: hide the toggle that lives inside the sidebar (use topbar only) */
@media (min-width: 991px) {
    body.custom-modern-theme .sidebar .sidebar-toggle-in-sidebar {
        display: none !important;
    }
}

/* Mobile: hide sidebar brand/logo – invert logo so it’s visible on dark */
@media (max-width: 990px) {
    body.custom-modern-theme:not(.sidebar-toggled) .sidebar .sidebar-brand.brand-logo,
    body.custom-modern-theme:not(.sidebar-toggled) .sidebar a.brand-logo,
    body.custom-modern-theme .sidebar .sidebar-brand.brand-logo-mini,
    body.custom-modern-theme .sidebar a.brand-logo-mini {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
        position: absolute !important;
        left: -9999px !important;
        width: 0 !important;
        height: 0 !important;
        overflow: hidden !important;
    }
    html[dir="rtl"] body.custom-modern-theme:not(.sidebar-toggled) .sidebar .sidebar-brand.brand-logo,
    html[dir="rtl"] body.custom-modern-theme:not(.sidebar-toggled) .sidebar a.brand-logo {
        left: auto !important;
        right: -9999px !important;
    }
    body.custom-modern-theme .sidebar .sidebar-scroll {
        margin-top: 0 !important;
    }
    /* When sidebar is open on mobile: show logo above menu (in flow) */
    body.custom-modern-theme.sidebar-toggled .sidebar .sidebar-brand.brand-logo,
    body.custom-modern-theme.sidebar-toggled .sidebar a.brand-logo {
        display: block !important;
        visibility: visible !important;
        opacity: 1 !important;
        position: relative !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 56px !important;
        padding: 14px 20px !important;
        box-sizing: border-box !important;
        background: #fff !important;
        box-shadow: 0 1px 0 rgba(0,0,0,0.08) !important;
        text-align: center !important;
        overflow: visible !important;
    }
    body.custom-modern-theme.sidebar-toggled .sidebar .brand-logo img.dashboard-image {
        max-width: 100% !important;
        max-height: 40px !important;
        width: auto !important;
        height: auto !important;
    }
    body.custom-modern-theme.sidebar-toggled .sidebar .brand-logo-mini {
        display: none !important;
    }
}

/* Mobile: make content/dashboard boxes a bit wider (less side padding) */
@media (max-width: 990px) {
    body.custom-modern-theme #page-content,
    body.custom-modern-theme .scrollable-page .page-content {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}
@media (max-width: 767px) {
    body.custom-modern-theme #page-content,
    body.custom-modern-theme .scrollable-page .page-content {
        padding-left: 8px !important;
        padding-right: 8px !important;
    }
    body.custom-modern-theme .page-wrapper {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    body.custom-modern-theme .row {
        margin-left: -6px !important;
        margin-right: -6px !important;
    }
    body.custom-modern-theme .row > [class*="col-"] {
        padding-left: 6px !important;
        padding-right: 6px !important;
    }
}

/* ========== Flexible containers: adapt to device width ========== */
/* Dashboard, projects, invoices, settings and all content areas stay within viewport */

body.custom-modern-theme .page-container {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

body.custom-modern-theme .page-container.overflow-auto {
    overflow-x: auto !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
}

body.custom-modern-theme .scrollable-page,
body.custom-modern-theme .main-scrollable-page {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

body.custom-modern-theme #page-content,
body.custom-modern-theme .page-content {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

body.custom-modern-theme .page-wrapper {
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

/* Content containers (dashboard-view, project views, invoice list, settings, etc.) */
body.custom-modern-theme .dashboard-view,
body.custom-modern-theme [id="page-content"],
body.custom-modern-theme .page-wrapper.clearfix {
    max-width: 100% !important;
    min-width: 0 !important;
}

/* Bootstrap container-fluid inside theme: ensure it doesn't overflow */
body.custom-modern-theme .container-fluid {
    max-width: 100% !important;
    padding-left: 1rem;
    padding-right: 1rem;
    box-sizing: border-box !important;
}

body.custom-modern-theme .container {
    max-width: 100% !important;
    box-sizing: border-box !important;
}

/* Tables: horizontal scroll on small screens instead of breaking layout */
body.custom-modern-theme .table-responsive {
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

body.custom-modern-theme .dataTables_wrapper {
    max-width: 100% !important;
    overflow-x: auto !important;
}

/* Cards and widgets: don't force min-width so they can shrink */
body.custom-modern-theme .card,
body.custom-modern-theme .widget-container .card,
body.custom-modern-theme .dashboard-icon-widget {
    max-width: 100% !important;
    min-width: 0 !important;
}

/* Fix flex children so they can shrink below content size */
body.custom-modern-theme .row {
    min-width: 0 !important;
}

body.custom-modern-theme .row > [class*="col-"] {
    min-width: 0 !important;
}

/* ========== Mobile: responsive containers (flexible on small screens) ========== */
@media (max-width: 990px) {
    body.custom-modern-theme .page-container {
        max-width: 100vw !important;
        width: 100% !important;
    }
    body.custom-modern-theme .scrollable-page,
    body.custom-modern-theme .main-scrollable-page {
        max-width: 100vw !important;
    }
    body.custom-modern-theme #page-content,
    body.custom-modern-theme .page-content,
    body.custom-modern-theme .page-wrapper {
        max-width: 100vw !important;
    }
    body.custom-modern-theme .container-fluid,
    body.custom-modern-theme .container {
        max-width: 100vw !important;
        padding-left: 12px !important;
        padding-right: 12px !important;
    }
    body.custom-modern-theme .table-responsive,
    body.custom-modern-theme .dataTables_wrapper {
        max-width: 100vw !important;
    }
}
@media (max-width: 767px) {
    body.custom-modern-theme .page-container,
    body.custom-modern-theme .scrollable-page,
    body.custom-modern-theme #page-content,
    body.custom-modern-theme .page-wrapper {
        max-width: 100vw !important;
    }
    body.custom-modern-theme .container-fluid,
    body.custom-modern-theme .container {
        padding-left: 10px !important;
        padding-right: 10px !important;
    }
}
