/* ============================================
   Layout Styles - Admin Dashboard
   ============================================ */

:root {
    /* Primary Brand Color - Will be overridden by accent */
    --primary: #0078d4;
    --primary-hover: #106ebe;
    --secondary: #6c757d;
    --success: #107c10;
    --danger: #d13438;
    --warning: #ffb900;
    --info: #00b7c3;
    /* Layout Colors - Light Mode */
    --bg-body: #ffffff;
    --bg-card: #f6f6f6; /* f8f9fa */
    --bg-primary-sidebar: #ebebeb;
    --bg-header: #f3f2f1;
    /* Text Colors - Light Mode */
    --text-primary: #323130;
    --text-secondary: #605e5c;
    --text-muted: #8a8886;
    --text-sidebar: #323130;
    --text-sidebar-active: var(--primary);
    /* Border Colors */
    --border-color: #dedede;
    --border-hover: #d2d0ce;
    /* Sidebar Dimensions */
    --primary-sidebar-width: 68px;
    --secondary-sidebar-width: 220px;
    /* Shadows */
    --shadow-sm: 0 1.6px 3.6px 0 rgba(0, 0, 0, 0.132), 0 0.3px 0.9px 0 rgba(0, 0, 0, 0.108);
    --shadow-md: 0 3.2px 7.2px 0 rgba(0, 0, 0, 0.132), 0 0.6px 1.8px 0 rgba(0, 0, 0, 0.108);
    --shadow-lg: 0 6.4px 14.4px 0 rgba(0, 0, 0, 0.132), 0 1.2px 3.6px 0 rgba(0, 0, 0, 0.108);
    /* Transitions */
    --transition-base: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Override Bootstrap default link colors immediately */
a {
    color: inherit !important;
    text-decoration: none !important;
}

a:hover {
    color: inherit !important;
}

a:visited {
    color: inherit !important;
}

/* Dark Theme */
[data-theme="dark"] {
    --bg-body: #1b1a19;
    --bg-card: #252423;
    --bg-primary-sidebar: #252423;
    --bg-secondary-sidebar: #1b1a19;
    --bg-header: #252423;

    --text-primary: #ffffff;
    --text-secondary: #d2d0ce;
    --text-muted: #a19f9d;

    --border-color: #323130;
    --border-hover: #484644;

    --shadow-sm: 0 1.6px 3.6px 0 rgba(0, 0, 0, 0.4), 0 0.3px 0.9px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 3.2px 7.2px 0 rgba(0, 0, 0, 0.4), 0 0.6px 1.8px 0 rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 6.4px 14.4px 0 rgba(0, 0, 0, 0.4), 0 1.2px 3.6px 0 rgba(0, 0, 0, 0.3);
}

/* ============================================
   Reset & Base
   ============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Prevent transitions on page load */
.preload * {
    transition: none !important;
}

html {
    overflow-x: hidden;
    width: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background-color: var(--bg-body);
    transition: var(--transition-base);
    overflow-x: hidden;
    width: 100%;
    margin: 0 !important;
}

/* ============================================
   Layout Wrapper
   ============================================ */

.layout-wrapper {
    display: flex;
    min-height: 100vh;
    width: 100%;
    overflow-x: hidden;
    position: relative;
}

/* ============================================
   Primary Sidebar (Icon-only, left-most)
   ============================================ */

.primary-sidebar {
    width: var(--primary-sidebar-width);
    background-color: var(--bg-primary-sidebar);
    display: flex;
    flex-direction: column;
    align-items: center;
    position: fixed;
    top: 60px;
    left: 0;
    bottom: 0;
    z-index: 1001;
    border-right: 1px solid var(--border-color);
}

.primary-sidebar-logo {
    display: none; /* Hide since logo is now in header */
}

.primary-sidebar-logo:hover {
    opacity: 0.8;
}

.primary-sidebar-logo .logo-svg {
    width: 40px;
    height: 40px;
    fill: var(--primary);
    transition: fill 0.3s ease;
    shape-rendering: geometricPrecision;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

[data-theme="dark"] .primary-sidebar-logo .logo-svg {
    fill: var(--primary);
}

.primary-sidebar-logo .logo-icon {
    width: 36px;
    height: 36px;
    color: var(--primary);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transition: var(--transition-base);
}

.primary-sidebar-logo .logo-icon:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.primary-sidebar-logo .logo-icon {
    width: 36px;
    height: 36px;
    color: var(--primary);
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
    transition: var(--transition-base);
}

.primary-sidebar-logo .logo-icon:hover {
    transform: scale(1.05);
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.15));
}

.primary-nav {
    flex: 1;
    width: 100%;
    padding: 1px 0 0 0px;
}

.primary-nav-list {
    list-style: none;
    padding: 0;
    margin: 2px 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.primary-nav-item {
    width: 100%;
    display: flex;
    justify-content: center;
}

a.primary-nav-link {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8d8d8d !important; /* #707070; */
    text-decoration: none;
    border-radius: 4px;
    /*transition: var(--transition-base);*/
    font-size: 1.7rem;
    position: relative;
    background-color: transparent;
    margin-bottom: 4px;
}

a.primary-nav-link i {
    color: #8d8d8d !important;
}

a.primary-nav-link:hover {
    background-color: var(--bg-body) !important;
    color: #6c6c6c !important;
}

    a.primary-nav-link:hover i {
        color: #6c6c6c !important;
    }

    a.primary-nav-link.active {
        color: var(--accent-primary, var(--primary)) !important;
        background-color: var(--bg-body) !important;
    }

a.primary-nav-link.active i {
    color: var(--accent-primary, var(--primary)) !important;
}

.primary-nav-link.active::after {
    display: none;
}

a.primary-nav-link.active::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 15%;
    height: 70%;
    width: 3px;
    border-radius: 2px;
    background-color: var(--accent-primary, var(--primary));
}

/* Label text: hidden on desktop, shown when mobile sidebar is open */
.primary-nav-label {
    display: none;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1;
}

.primary-sidebar-footer {
    padding: 0.5rem;
    width: 100%;
    display: flex;
    justify-content: center;
}

.primary-sidebar-footer .primary-nav-link {
    margin-bottom: -3px;
}

/* Dark theme adjustments for primary sidebar */
[data-theme="dark"] .primary-nav-link {
    color: #a19f9d;
}

[data-theme="dark"] .primary-nav-link:hover {
    background-color: #323130;
    color: #ffffff;
}

[data-theme="dark"] .primary-nav-link.active {
    background-color: #323130;
    color: #ffffff;
}

[data-theme="dark"] .primary-sidebar {
    background-color: var(--bg-header);
}

/* ============================================
   Secondary Sidebar (Community Context)
   ============================================ */

.secondary-sidebar {
    width: var(--secondary-sidebar-width);
    background-color: var(--bg-secondary-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 60px;
    left: var(--primary-sidebar-width);
    bottom: 0;
    z-index: 1000;
}

.mobile-back-btn {
    display: none;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-base);
    width: 100%;
    text-align: left;
}

.mobile-back-btn:hover {
    background: var(--bg-body);
}

.mobile-back-btn i {
    font-size: 1.125rem;
}

.community-selector {
    padding: 1.38rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.community-badge {
    position: relative;
}

.community-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 1.125rem;
}

.community-info {
    flex: 1;
    min-width: 0;
    overflow: hidden;
}

.community-name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text-primary);
    margin: 0.4rem 0 0 0;
    line-height: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.community-type {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
}

.secondary-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0;
    background: var(--bg-secondary-sidebar);
}

.secondary-nav-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.secondary-nav-item {
    margin: 0;
}

.secondary-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    margin: 3px 10px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-base);
    font-size: 0.8rem;
    font-weight: 500;
    border-radius:6px;
}

.secondary-nav-link:hover {
    background-color: var(--bg-card);
    color: var(--text-primary) !important;
}

    .secondary-nav-link.active {
        background-color: var(--bg-card);
        color: var(--primary) !important;
    }

.secondary-nav-link i {
    font-size: 1.125rem;
    width: 1.25rem;
    text-align: center;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* ============================================
   Main Content
   ============================================ */

.main-content {
    flex: 1;
    margin-left: var(--primary-sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - var(--primary-sidebar-width));
    transition: var(--transition-base);
    background-color: #ebebeb;
    overflow-x: clip; /* clip not hidden — hidden breaks position:sticky in descendants */
}

[data-theme="dark"] .main-content {
    background-color: var(--bg-body);
}

.main-content.with-secondary-sidebar {
    margin-left: calc(var(--primary-sidebar-width) + var(--secondary-sidebar-width));
    width: calc(100% - var(--primary-sidebar-width) - var(--secondary-sidebar-width));
}

/* Resident Portal - No admin sidebars */
.main-content.resident-portal {
    margin-left: 0;
    width: 100%;
    padding-top: 0; /* Remove header padding for resident portal */
    display: flex;
    flex-direction: row;
    background-color: var(--bg-body);
}

.main-content.resident-portal .content {
    padding-top: 0; /* Remove content padding when no header */
}

/* ============================================
   Resident Portal Sidebar & Content
   ============================================ */

/* Mobile Toggle Button */
.resident-mobile-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 1003;
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background-color: var(--accent-primary, var(--primary));
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: var(--transition-base);
}

.resident-mobile-toggle:hover {
    background-color: var(--accent-secondary, var(--primary-hover));
    transform: scale(1.05);
}

.resident-mobile-toggle:active {
    transform: scale(0.95);
}

/* Sidebar Overlay for Mobile */
.resident-sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1001;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.resident-sidebar-overlay.show {
    display: block;
    opacity: 1;
    pointer-events: auto;
}

.resident-sidebar {
    width: 280px;
    min-width: 280px;
    background-color: var(--bg-body);
    border-right: 1px solid var(--border-color);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1002;
    overflow-y: auto;
    transition: transform 0.3s ease;
}

.resident-sidebar .sidebar-content {
    padding: 2rem 1.5rem;
}

.resident-sidebar .resident-profile {
    padding: 1.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1.5rem;
}

.resident-sidebar .nav {
    list-style: none;
    padding: 0;
    margin: 0;
}

.resident-sidebar .nav-item {
    margin-bottom: 0.25rem;
}

.resident-sidebar .nav-link {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: var(--text-primary);
    text-decoration: none;
    border-radius: 6px;
    transition: var(--transition-base);
}

.resident-sidebar .nav-link:hover {
    background-color: #f3f2f1;
    color: var(--text-primary);
}

.resident-sidebar .nav-link.active {
    background-color: #f3f2f1;
    color: var(--accent-primary, var(--primary));
}

.resident-sidebar .nav-link i {
    font-size: 1.125rem;
}

.resident-content {
    margin-left: 280px;
    flex: 1;
    min-height: 95vh;
    background-color: #ffffff; /* #f8f9fa; */
    padding: 1rem;
}

.resident-content .content-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.resident-content .content-header h1 {
    margin: 0;
    color: var(--text-primary);
}

/* Mobile Responsive for Resident Portal */
@media (max-width: 991px) {
    .resident-mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .resident-sidebar-overlay {
        display: block;
    }

    .resident-sidebar {
        width: 280px;
        min-width: 280px;
        transform: translateX(-100%);
        box-shadow: none;
        border-bottom: none;
    }

    .resident-sidebar.show {
        transform: translateX(0);
        box-shadow: 2px 0 8px rgba(0,0,0,0.15);
    }

    .resident-content {
        margin-left: 0;
        padding: 5rem 1rem 1rem 1rem;
    }

    .resident-content .content-header {
        margin-bottom: 1rem;
    }

    /* Stack cards on mobile */
    .resident-content .row.g-3 {
        --bs-gutter-x: 0.75rem;
        --bs-gutter-y: 0.75rem;
    }
}

@media (max-width: 767px) {
    .resident-content {
        padding: 4.5rem 0.75rem 0.75rem 0.75rem;
    }

    .resident-mobile-toggle {
        width: 44px;
        height: 44px;
        font-size: 1.25rem;
    }

    /* Payment form in bills table: hide amount input on mobile, show icon-only submit */
    .portal-pay-form {
        width: auto !important;
    }
    .portal-pay-form .form-control {
        display: none;
    }
}

/* Desktop/tablet payment form width */
@media (min-width: 768px) {
    .portal-pay-form {
        width: 180px;
    }
}

/* ============================================
   Header
   ============================================ */

.header {
    background-color: var(--bg-primary-sidebar);
    padding: 0.5rem 0.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1003;
    height: 60px;
    transition: var(--transition-base);
    border-bottom: 1px solid var(--border-color);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 280px;
    padding-left: 0rem;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    transition: opacity 0.2s ease;
}

.header-logo:hover {
    opacity: 0.85;
}

.header-logo-container {
    padding: 0.25rem 0.6rem;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.header-logo:hover .header-logo-container {
    opacity: 0.85;
}

.header-logo-svg {
    height: 36px;
    width: auto;
    display: block;
    shape-rendering: geometricPrecision;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
}

.header-logo-img {
    height: 40px;
    width: auto;
    display: block;
}

.header-logo-icon {
    width: 36px;
    height: 36px;
    fill: var(--accent-primary, #0078d4);
}

.header-company-name {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    display: none;
}

.with-secondary-sidebar .header {
    left: 0;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    z-index: 1;
    min-width: 280px;
    justify-content: flex-end;
}

/* Search Bar — absolutely centred so it is always in the middle of the header
   regardless of the logo/actions widths on either side. */
.header-search {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    max-width: 600px;
    width: 50%;
    min-width: 300px;
    pointer-events: auto;
}

    .header-search .search-wrapper {
        position: relative;
        width: 100%;
    }

.header-search .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
}


    .header-search .search-input {
        width: 100%;
        padding: 0.5rem 1rem 0.5rem 2.75rem;
        border: 1px solid var(--border-color);
        border-radius: 6px;
        background-color: var(--bg-body);
        color: var(--text-primary);
        font-size: 0.875rem;
        transition: var(--transition-base);
        caret-color: var(--primary);
    }

        .header-search .search-input:hover {
            border-color: var(--primary);
        }

.header-search .search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 120, 212, 0.1);
}

.header-search .search-input::placeholder {
    color: var(--text-muted);
}

    .header-search .clear-btn {
        position: absolute;
        right: 0.75rem;
        top: 50%;
        transform: translateY(-50%);
        font-size: 0.9rem;
        color: var(--text-muted);
        cursor: pointer;
        display: none;
    }

    .header-search .search-input:not(:placeholder-shown) ~ .clear-btn {
        display: block;
    }


/* Sidebar Toggle Mobile */
.sidebar-toggle-mobile {
    display: none;
}

@media (max-width: 768px) {
    .sidebar-toggle-mobile {
        display: flex;
    }

    .header {
        justify-content: space-between;
    }

    .header-search {
        position: static;
        transform: none;
        width: 100%;
        max-width: none;
        min-width: 0;
        flex: 1;
        margin: 0 0.5rem;
    }
}

/* Content padding for fixed header */
.content {
    padding-top: calc(60px + 2rem);
    background-color: #ffffff;
}

[data-theme="dark"] .content {
    background-color: var(--bg-body);
}

/* Breadcrumbs */
.breadcrumb {
    margin: 0;
    padding: 0;
    background: transparent;
    font-size: 0.875rem;
}

.breadcrumb-item {
    color: var(--text-secondary);
}

.breadcrumb-item.active {
    color: var(--text-primary);
    font-weight: 500;
}

.breadcrumb-item a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-base);
}

.breadcrumb-item a:hover {
    color: var(--primary);
}

/* ============================================
   Buttons
   ============================================ */

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.125rem;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition-base);
    position: relative;
}

.btn-icon:hover {
    background-color: var(--bg-body);
    color: var(--text-primary);
}

.badge-dot {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--bg-header);
}

/* Notification Bell Badge */
.notification-bell-badge {
    position: absolute;
    top: 0px;
    right: 4px;
    background: #dc3545;
    color: white;
    border-radius: 10px;
    font-size: 0.7rem;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    display: grid;
    place-items: center;
    box-shadow: 0 0 0 2px var(--bg-header);
    line-height: 1;
}

/* Theme Toggle */
.theme-toggle {
    position: relative;
}

.theme-icon-light {
    display: none;
}

[data-theme="dark"] .theme-icon-dark {
    display: none;
}

[data-theme="dark"] .theme-icon-light {
    display: inline;
}

/* Sidebar Toggle Mobile */
.sidebar-toggle-mobile {
    display: none;
}

@media (max-width: 768px) {
    .sidebar-toggle-mobile {
        display: flex;
    }
}

/* ============================================
   User Avatar
   ============================================ */

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--accent-primary, #0078d4);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.8125rem;
    flex-shrink: 0;
}

.user-avatar-large {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-primary, #0078d4);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 600;
    font-size: 0.875rem;
    flex-shrink: 0;
}

.avatar-text {
    text-transform: uppercase;
}

.user-avatar-large-container {
    position: relative;
    display: inline-block;
}

.avatar-camera-overlay {
    position: absolute;
    bottom: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: var(--accent-primary, #0078d4);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 9px;
    border: 2px solid var(--bg-card);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.user-avatar-large-container:hover .avatar-camera-overlay {
    opacity: 1;
}

/* Avatar Modal Styles */
.avatar-cropper-container {
    width: 350px;
    height: 350px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--border-color);
    background: #f5f5f5;
    position: relative;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.avatar-cropper-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Hide Cropper.js elements we don't need */
.avatar-cropper-container .cropper-view-box {
    border-radius: 50%;
    outline: 0;
}

.avatar-cropper-container .cropper-face {
    background-color: transparent !important;
}

.avatar-cropper-container .cropper-line,
.avatar-cropper-container .cropper-point {
    display: none !important;
}

/* Remove the dark overlay/modal that creates the inner darker circle */
.avatar-cropper-container .cropper-modal {
    display: none !important;
    opacity: 0 !important;
}

.avatar-cropper-container .cropper-crop-box {
    border-radius: 50% !important;
}

.cropper-controls .btn-group {
    box-shadow: none;
}

/* Blade Avatar Styles */
.blade-avatar-container {
    position: relative;
    display: inline-block;
}

.blade-avatar-large {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--accent-primary, var(--bs-primary));
    color: white;
    font-size: 2.5rem;
    font-weight: 600;
    overflow: hidden;
    border: 3px solid var(--bs-border-color);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.blade-avatar-large .avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.blade-avatar-large .avatar-text {
    text-transform: uppercase;
}

.blade-avatar-upload-btn {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: var(--accent-primary, var(--bs-primary));
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.blade-avatar-upload-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    background-color: var(--accent-hover, var(--bs-primary));
}

.blade-avatar-upload-btn i {
    color: white;
    font-size: 16px;
}


.user-info {
    overflow: hidden;
}

.user-name {
    font-size: 0.875rem;
    color: #ffffff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-sidebar);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* User Menu Button */
.btn-user-menu {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    background: transparent;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition-base);
    color: var(--text-primary);
}

.btn-user-menu:hover,
.btn-user-menu[aria-expanded="true"] {
    background-color: var(--bg-body);
}

.user-name-header {
    font-size: 0.875rem;
    font-weight: 400;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

@media (max-width: 1024px) {
    .user-name-header {
        display: none;
    }
}

.btn-user-menu i {
    font-size: 0.75rem;
}

.btn-user-menu .bi-chevron-down {
    transition: transform 0.15s ease;
}

.btn-user-menu[aria-expanded="true"] .bi-chevron-down {
    transform: rotate(180deg);
}

@media (max-width: 768px) {
    .user-name-header {
        display: none;
    }

    .btn-user-menu .bi-chevron-down {
        display: none;
    }
}

/* ============================================
   Dropdowns
   ============================================ */

.dropdown-menu {
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    border-radius: 0.5rem;
    padding: 0.5rem;
    min-width: 280px;
    background-color: var(--bg-body);
}

.dropdown-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.dropdown-header h6 {
    margin: 0;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.dropdown-header-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.875rem;
    line-height: 1.2;
}

.dropdown-header-email {
    font-size: 0.75rem;
    color: var(--text-secondary);
    line-height: 1.2;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    border-radius: 0.375rem;
    color: var(--text-primary);
    text-decoration: none;
    transition: var(--transition-base);
    font-size: 0.875rem;
}

.dropdown-item:hover {
    background-color: var(--bg-body);
    color: var(--text-primary);
}

.dropdown-item i {
    width: 1.25rem;
    text-align: center;
    color: var(--text-secondary);
}

.dropdown-item.text-danger {
    color: var(--danger);
}

.dropdown-item.text-danger:hover {
    background-color: rgba(220, 53, 69, 0.1);
}

.dropdown-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
    text-align: center;
}

.dropdown-footer a {
    font-size: 0.8125rem;
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.dropdown-footer a:hover {
    text-decoration: underline;
}

/* Notification Dropdown */
.notification-dropdown {
    min-width: 360px;
    max-height: 480px;
    overflow-y: auto;
}

.dropdown-body {
    padding: 0;
}

.notification-item {
    display: flex;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    border-radius: 0.375rem;
    text-decoration: none;
    color: var(--text-primary);
    transition: var(--transition-base);
    border-left: 3px solid transparent;
}

.notification-item:hover {
    background-color: var(--bg-body);
}

.notification-item.unread {
    background-color: rgba(13, 110, 253, 0.05);
    border-left-color: var(--primary);
}

.notification-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    flex-shrink: 0;
}

.notification-content {
    flex: 1;
    min-width: 0;
}

.notification-title {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.notification-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.notification-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   Content
   ============================================ */

.content {
    flex: 1;
    padding: 2rem;
    padding-top: calc(48px + 2rem);
    background-color: var(--bg-body);
    max-width: 100%;
    overflow-x: clip; /* clip not hidden — hidden creates a scroll context that breaks position:sticky */
}

/* ============================================
   Footer
   ============================================ */

.footer {
    border-top: 1px solid var(--border-color);
    padding: 1rem 1.5rem;
    background-color: var(--bg-header);
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.footer-right a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition-base);
}

.footer-right a:hover {
    color: var(--primary);
}

.footer-divider {
    color: var(--text-muted);
}

/* ============================================
   Auth Layout (Login/Register)
   ============================================ */

.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-body);
    padding: 1rem;
}

/* ============================================
   Responsive
   ============================================ */

/* Dim overlay shown behind mobile sidebars */
.sidebar-mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    cursor: pointer;
}
.sidebar-mobile-overlay.show {
    display: block;
}

/* Prevent background scrolling while a sidebar is open */
body.sidebar-open {
    overflow: hidden;
}

@media (max-width: 992px) {
    .primary-sidebar {
        transform: translateX(-100%);
        transition: var(--transition-base);
    }

    .primary-sidebar.mobile-open {
        transform: translateX(0);
        width: 100%;
        align-items: flex-start;
        z-index: 1002;
    }

    .primary-sidebar.mobile-open .primary-nav {
        padding: 0.5rem 0;
        width: 100%;
    }

    .primary-sidebar.mobile-open .primary-nav-item {
        justify-content: flex-start;
    }

    .primary-sidebar.mobile-open a.primary-nav-link {
        width: 100%;
        height: auto;
        padding: 0.875rem 1.25rem;
        flex-direction: row;
        justify-content: flex-start;
        gap: 0.875rem;
        border-radius: 0;
        font-size: 1.4rem;
    }

    .primary-sidebar.mobile-open .primary-nav-label {
        display: block;
    }

    .primary-sidebar.mobile-open .primary-sidebar-footer {
        width: 100%;
        justify-content: flex-start;
        padding: 0.25rem 0;
        border-top: 1px solid var(--border-color);
    }

    .primary-sidebar.mobile-open .primary-sidebar-footer .primary-nav-list {
        width: 100%;
    }

    .primary-sidebar.mobile-open .primary-sidebar-footer .primary-nav-link {
        width: 100%;
        height: auto;
        padding: 0.875rem 1.25rem;
        flex-direction: row;
        justify-content: flex-start;
        gap: 0.875rem;
        border-radius: 0;
        font-size: 1.4rem;
        margin-bottom: 0;
    }

    .secondary-sidebar {
        left: 0;
        width: 100%;          /* full-width on mobile */
        transform: translateX(-100%);
        transition: var(--transition-base);
        z-index: 1003;        /* above primary and overlay */
    }

    .secondary-sidebar.mobile-open {
        transform: translateX(0);
        background-color: var(--bg-body, #ffffff);
    }

    .secondary-sidebar.mobile-open .secondary-nav-link {
        padding: 0.875rem 1.25rem;
        margin: 2px 0.5rem;
        font-size: 1rem;
        border-radius: 8px;
    }

    .secondary-sidebar.mobile-open .secondary-nav-link i {
        font-size: 1.35rem;
        width: 1.5rem;
    }

    .secondary-sidebar.mobile-open .mobile-back-btn {
        padding: 1rem 1.25rem;
        font-size: 1rem;
    }

    .secondary-sidebar.mobile-open .mobile-back-btn i {
        font-size: 1.25rem;
    }

    /* Show back button on mobile when secondary sidebar is open */
    .secondary-sidebar.mobile-open .mobile-back-btn {
        display: flex !important;
    }

    .main-content,
    .main-content.with-secondary-sidebar {
        margin-left: 0;
        width: 100%;
    }

    .breadcrumb {
        display: none;
    }

    .sidebar-toggle-mobile {
        display: flex !important;
    }

    .header-company-name {
        display: none;
    }

    .header-left {
        min-width: auto;
    }

    .header-right {
        min-width: auto;
    }
}

/* User profile dropdown mobile override is at the END of this file. */

@media (max-width: 768px) {
    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
    }

    .dashboard-container,
    .communities-page {
        padding: 1rem;
    }

    .header-search {
        display: none;
    }

    /* Remove the 2rem side padding from .content on mobile — inner containers
       (.community-content, .content-body) provide their own padding.
       padding-top is overridden at end-of-file to 60px. */
    .content {
        padding-left: 0;
        padding-right: 0;
    }

    /* Sticky header mobile overrides are at the END of this file (after the base
       .sticky-header rule) so they win the CSS cascade. See bottom of file. */
}

/* ============================================
   Scrollbar
   ============================================ */

.sidebar-nav::-webkit-scrollbar,
.notification-dropdown::-webkit-scrollbar {
    width: 6px;
}

.sidebar-nav::-webkit-scrollbar-track,
.notification-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb,
.notification-dropdown::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover,
.notification-dropdown::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   Utilities
   ============================================ */

.d-none {
    display: none !important;
}

.d-block {
    display: block !important;
}

@media (max-width: 768px) {
    .d-md-none {
        display: none !important;
    }
}

/* ============================================
   Sticky Page Header
   ============================================ */

.sticky-header {
    position: relative;
    z-index: 99; /* Below fixed header (1003) but above content */
    background-color: var(--bg-body); /* background: rgba(255, 255, 255, 0.85); | background-color: var(--bg-body);*/
    backdrop-filter: blur(8px);
    padding: 0rem 2rem; /* Reduced top padding, keep horizontal */
    margin: 0 -2rem 1.5rem -2rem; /* Negative margins extend to edges of .content padding */
    border-bottom: 1px solid transparent;
    transition: all 0.2s ease;
}

/* When fixed by JavaScript */
.sticky-header.scrolled {
    padding: 0.75rem 3rem 0.75rem 2rem; /* Match the base padding */
    margin: 0 -4rem 1.5rem -2rem;
    border-bottom-color: var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 999;
    background-color: #fafafad9;
}

/* Ensure content-body has proper spacing after sticky header */
.content-body {
    padding-top: 0;
}

[data-theme="dark"] .sticky-header {
    background-color: var(--bg-body);
}

    [data-theme="dark"] .sticky-header.scrolled {
        border-bottom-color: var(--border-color);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
        background-color: #1b1a19cc;
    }

/* ============================================
   Floating Bulk Actions
   ============================================ */

.floating-bulk-actions {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    transform: translateY(150%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    max-width: 600px;
}

.floating-bulk-actions.show {
    transform: translateY(0);
}

.floating-bulk-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 1rem 1.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.floating-bulk-info {
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    font-size: 0.95rem;
}

.floating-bulk-buttons {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

[data-theme="dark"] .floating-bulk-content {
    background: var(--bg-card);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

@media (max-width: 768px) {
    .floating-bulk-actions {
        bottom: 1rem;
        right: 1rem;
        left: 1rem;
        max-width: none;
    }

    .floating-bulk-content {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }

    .floating-bulk-info {
        justify-content: center;
    }

    .floating-bulk-buttons {
        justify-content: center;
    }
}

/* ============================================
   Polls - Voting Results
   ============================================ */

/* Poll results progress bar - use accent color */
#resultsContent .progress-bar {
    background-color: var(--accent-primary, #0078d4);
}

[data-theme="dark"] #resultsContent .progress-bar {
    background-color: var(--accent-primary, #0078d4);
}

/* ============================================
   Page Tabs — shared by Billing, Accounts, Property Detail, etc.
   Desktop: pill buttons. Mobile: native <select> dropdown.
   ============================================ */

.billing-tabs-container {
    background: var(--bg-subtle, rgba(0,0,0,0.06));
    border-radius: 12px;
    padding: 8px;
}

[data-theme="dark"] .billing-tabs-container {
    background: rgba(255,255,255,0.07);
}

/* Mobile select — shown only on small screens (see mobile override below) */
.billing-tab-select {
    display: none;
}

/* Desktop tab row */
.billing-tabs {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.billing-tab {
    flex: 0 1 auto;
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-muted, #6c757d);
    font-weight: 500;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: fit-content;
}

.billing-tab:hover {
    color: var(--text-body, #495057);
    background: rgba(128,128,128,0.12);
}

.billing-tab.active {
    background: var(--accent-primary);
    color: white;
}

.billing-tab i {
    font-size: 16px;
}

/* Tab panels */
.billing-tab-content {
    display: none;
}

.billing-tab-content.active {
    display: block;
}

.tab-content-container {
    background: transparent;
    border-radius: 8px;
}

/* ============================================
   Mobile overrides — must be at end of file so they win
   over base rules defined above.
   ============================================ */

@media (max-width: 768px) {
    /* Content: start flush with the app header (60px), no extra gap.
       The sticky-header's own 0.75rem padding provides visual breathing room. */
    .content {
        padding-top: 60px !important;
    }

    /* Header: give right-side icons breathing room from screen edge */
    .header {
        padding-right: 0.75rem;
    }

    /* Sticky page header: row layout, strapline hidden.
       !important beats the base .sticky-header rule defined later in this file. */
    .sticky-header {
        padding: 0.75rem 1rem !important;
        margin: 0 0 1rem 0 !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between;
        gap: 0;
    }
    /* Hide ALL paragraphs inside the sticky header (straplines) */
    .sticky-header p {
        display: none !important;
    }
    .sticky-header.scrolled {
        padding: 0.75rem 1rem !important;
        margin: 0 0 1rem 0 !important;
        border-bottom-color: var(--border-color);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    }

    /* Settings nav-tabs: scrollable row, icon-only on mobile */
    .nav-tabs {
        flex-wrap: nowrap !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 1px;
    }
    .nav-tabs .nav-link {
        white-space: nowrap;
    }

    /* Table rows: more touch-friendly padding on mobile */
    .table > tbody > tr > td,
    .table > thead > tr > th {
        padding-top: 0.75rem !important;
        padding-bottom: 0.75rem !important;
    }

    /* Tabs on mobile: hide pill buttons, show the native <select> instead */
    .billing-tab-select {
        display: block;
    }

    .billing-tabs {
        display: none;
    }

}

/* Mobile search bar — drops below the header when search icon is tapped */
.mobile-search-bar {
    display: none;
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    z-index: 1002;
    background: var(--bg-primary-sidebar);
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.mobile-search-bar.show {
    display: flex;
    align-items: center;
}
.mobile-search-bar .search-wrapper {
    position: relative;
    width: 100%;
}
.mobile-search-bar .search-icon {
    position: absolute;
    left: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}
.mobile-search-bar .search-input {
    width: 100%;
    padding: 0.5rem 2.5rem 0.5rem 2.5rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-body);
    color: var(--text-primary);
    font-size: 0.9rem;
}
.mobile-search-bar .search-input:focus {
    outline: none;
    border-color: var(--primary);
}
.mobile-search-bar .clear-btn {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: var(--text-muted);
    display: none;
    font-size: 0.8rem;
}
.mobile-search-bar .search-input:not(:placeholder-shown) ~ .clear-btn {
    display: block;
}
/* When mobile search is open, push content down */
body.mobile-search-open .content {
    padding-top: calc(60px + 44px + 0.75rem);
}
/* Show mobile search icon only on mobile */
.mobile-search-toggle {
    display: none;
}
@media (max-width: 768px) {
    .mobile-search-toggle {
        display: flex;
    }
}
/* User menu: blade button on mobile, dropdown on desktop */
.user-menu-blade-btn {
    display: none;
}
@media (max-width: 768px) {
    .user-menu-blade-btn {
        display: flex;
    }
    .user-menu-dropdown {
        display: none;
    }
}

/* ============================================
   Community Switcher
   ============================================ */

.community-switcher-mobile-btn {
    display: none;
}

/* Square avatar — same size/colours as .user-avatar but rounded-square not circle */
.community-avatar {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    background: var(--accent-primary, #0078d4);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-size: 1rem;
    flex-shrink: 0;
}

/* Align the dropdown wrapper with adjacent icon buttons */
.community-switcher-dropdown {
    display: flex;
    align-items: center;
}

/* The trigger button reuses .btn-user-menu for layout/hover; suppress the
   focus ring Bootstrap/browsers add to dropdown triggers */
.btn-community-switcher:focus,
.btn-community-switcher:focus-visible {
    outline: none;
    box-shadow: none;
}

.btn-community-switcher > .bi-chevron-down {
    font-size: 0.65rem;
    flex-shrink: 0;
    transition: transform 0.15s ease;
}

.btn-community-switcher[aria-expanded="true"] > .bi-chevron-down {
    transform: rotate(180deg);
}

.community-switcher-menu {
    min-width: 240px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    padding: 0.25rem;
}

.community-switcher-list {
    overflow: visible;
}

.community-switcher-loading,
.community-switcher-empty {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.875rem 1rem;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.community-switcher-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    color: var(--text-primary) !important;
    text-decoration: none;
    transition: var(--transition-base);
}

.community-switcher-item:hover {
    background-color: var(--accent-light);
    color: var(--accent-primary) !important;
}

.community-switcher-item:hover .community-item-icon {
    color: var(--accent-primary);
}

.community-switcher-item.community-current {
    font-weight: 600;
    color: var(--accent-primary) !important;
}

.community-switcher-item.community-current .community-item-icon {
    color: var(--accent-primary);
}

.community-item-icon {
    flex-shrink: 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.community-item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.community-item-check {
    margin-left: auto;
    flex-shrink: 0;
    color: var(--accent-primary);
    font-size: 0.875rem;
}

.community-add-item {
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    color: var(--accent-primary) !important;
    font-weight: 500;
    padding: 0.5rem 0.75rem !important;
}

.community-add-item:hover {
    background-color: var(--accent-light) !important;
    color: var(--accent-primary) !important;
}

[data-theme="dark"] .community-switcher-item:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: var(--text-primary) !important;
}

    [data-theme="dark"] .community-switcher-item:hover .community-item-icon {
        color: var(--text-muted) !important;
    }


[data-theme="dark"] .community-add-item:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
}

@media (max-width: 768px) {
    .community-switcher-mobile-btn {
        display: flex;
    }
    .community-switcher-dropdown {
        display: none;
    }
}

/* Blade: community list items get extra padding for thumb-friendliness */
#communitySwitcherBladeList .community-switcher-item {
    padding: 0.75rem 1.25rem;
    border-radius: 0;
    border-bottom: 1px solid var(--border-color);
}

#communitySwitcherBladeList .community-switcher-item:last-child {
    border-bottom: none;
}
