/**
 * Portal Responsive CSS
 * Centralized responsive styles for all customer portal pages
 * Include this in layout.blade.php to apply to all portal pages
 */

/* ========================================
   CSS Variables for Responsive Breakpoints
   ======================================== */
:root {
    --portal-breakpoint-xs: 480px;
    --portal-breakpoint-sm: 576px;
    --portal-breakpoint-md: 768px;
    --portal-breakpoint-lg: 992px;
    --portal-breakpoint-xl: 1200px;
}

/* ========================================
   Responsive Grid Utilities
   ======================================== */

/* Stats Grid - 4 columns default */
.portal-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Quick Actions Grid - 3 columns default */
.portal-actions-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

/* 2-column grid */
.portal-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

/* Auto-fit grid for flexible items */
.portal-grid-auto {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

/* ========================================
   Responsive Header Components
   ======================================== */
.portal-header-flex {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.portal-header-info {
    flex: 1;
    min-width: 200px;
}

.portal-header-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* ========================================
   Account Health Badge (Global Styles)
   ======================================== */
.account-health-badge {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 50px;
    backdrop-filter: blur(4px);
    margin-top: 8px;
}

.health-score-mini {
    position: relative;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.health-score-mini::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.25);
}

.health-score-mini::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    border: 4px solid #10b981;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
}

.health-score-mini .score-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    z-index: 1;
}

.health-info-mini {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.health-status-text {
    font-size: 0.875rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
}

.health-status-text.text-success {
    color: #10b981;
}
.health-status-text.text-warning {
    color: #f59e0b;
}
.health-status-text.text-danger {
    color: #ef4444;
}

.health-desc-text {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.8);
}

/* ========================================
   Dashboard Sliding Carousel
   ======================================== */
.dashboard-carousel-wrapper {
    position: relative;
    width: 100%;
    max-width: 280px;
    overflow: hidden;
    border-radius: 16px;
}

.dashboard-carousel {
    display: flex;
    transition: transform 0.5s ease-in-out;
}

.carousel-slide {
    min-width: 100%;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    position: absolute;
    top: 0;
    left: 0;
}

.carousel-slide.active {
    opacity: 1;
    position: relative;
}

/* Health Card (Slide 2) */
.health-card {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    border-radius: 16px;
    padding: 20px;
    text-align: center;
    color: white;
    min-height: 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.health-label {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 1px;
    opacity: 0.9;
    margin-bottom: 8px;
}

.health-score-ring {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.health-score-ring svg {
    transform: rotate(-90deg);
}

.health-score-value {
    position: absolute;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.health-card .health-status-text {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Carousel Indicators */
.carousel-dots {
    display: flex;
    justify-content: center;
    gap: 6px;
    padding: 8px 0;
    position: absolute;
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
}

.carousel-dots .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    cursor: pointer;
    transition: all 0.3s ease;
}

.carousel-dots .dot.active {
    background: white;
    transform: scale(1.2);
}

/* Compact Health Card (same size as balance card) */
.health-card-compact {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    border-radius: 16px;
    padding: 16px 20px;
    text-align: center;
    color: white;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.health-card-compact .health-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 1px;
    opacity: 0.9;
}

.health-card-compact .health-score-ring {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.health-card-compact .health-score-ring svg {
    transform: rotate(-90deg);
}

.health-card-compact .health-score-value {
    position: absolute;
    font-size: 1.25rem;
    font-weight: 700;
    color: white;
}

.health-card-compact .health-status-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.2);
}

.health-card-compact .health-status-badge.text-success {
    color: #10b981;
}
.health-card-compact .health-status-badge.text-warning {
    color: #f59e0b;
}
.health-card-compact .health-status-badge.text-danger {
    color: #ef4444;
}

/* ========================================
   Mobile-First Table Cards
   Transform tables into stacked cards on mobile
   ======================================== */
.portal-table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Card-based table alternative for mobile */
.portal-data-cards {
    display: none;
}

.portal-data-card {
    background: white;
    border-radius: var(--radius-lg, 12px);
    padding: 1rem;
    margin-bottom: 0.75rem;
    border: 1px solid var(--mw-slate-200, #e2e8f0);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.portal-data-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--mw-slate-100, #f1f5f9);
}

.portal-data-card-row:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.portal-data-card-label {
    font-size: 0.75rem;
    color: var(--mw-slate-500, #64748b);
    text-transform: uppercase;
    font-weight: 600;
}

.portal-data-card-value {
    font-size: 0.875rem;
    color: var(--mw-slate-800, #1e293b);
    font-weight: 500;
    text-align: right;
}

/* ========================================
   Touch-Friendly Components
   ======================================== */
.portal-btn-touch {
    min-height: 44px;
    min-width: 44px;
    padding: 0.625rem 1rem;
}

.portal-link-touch {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0.5rem 0;
}

/* ========================================
   Responsive Typography
   ======================================== */
.portal-heading-lg {
    font-size: clamp(1.25rem, 4vw, 1.75rem);
    font-weight: 700;
    line-height: 1.2;
}

.portal-heading-md {
    font-size: clamp(1rem, 3vw, 1.25rem);
    font-weight: 600;
    line-height: 1.3;
}

.portal-text-responsive {
    font-size: clamp(0.875rem, 2.5vw, 1rem);
}

/* ========================================
   Responsive Spacing Utilities
   ======================================== */
.portal-p-responsive {
    padding: 1.5rem;
}

.portal-m-responsive {
    margin: 1rem;
}

/* ========================================
   TABLET BREAKPOINT (max-width: 992px)
   ======================================== */
@media (max-width: 992px) {
    /* Grids */
    .portal-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .portal-actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Tab navigation horizontal scroll */
    .tab-nav-modern {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .tab-nav-modern::-webkit-scrollbar {
        display: none;
    }

    /* Content layout */
    .col-lg-8,
    .col-lg-4 {
        width: 100%;
        max-width: 100%;
    }

    /* Cards full width */
    .sidebar-card {
        margin-bottom: 1rem;
    }

    /* Spacing adjustments */
    .portal-p-responsive {
        padding: 1rem;
    }
}

/* ========================================
   MOBILE BREAKPOINT (max-width: 768px)
   ======================================== */
@media (max-width: 768px) {
    /* Header stacking */
    .portal-header-flex {
        flex-direction: column;
        text-align: center;
    }

    .portal-header-actions {
        width: 100%;
        justify-content: center;
    }

    /* Balance card full width */
    .balance-card {
        width: 100%;
    }

    /* Welcome section */
    .dashboard-header .welcome-section {
        flex-direction: column;
        text-align: center;
    }

    /* Readings header */
    .readings-info-section {
        flex-direction: column;
        text-align: center;
    }

    .readings-meta {
        justify-content: center;
    }

    .readings-actions {
        margin-left: 0;
        justify-content: center;
        width: 100%;
    }

    /* Usage stats row */
    .usage-stats-row {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Quick actions */
    .portal-actions-grid,
    .quick-actions-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    /* Tab buttons */
    .tab-nav-modern .tab-btn span {
        display: none;
    }

    .tab-nav-modern .tab-btn {
        padding: 0.75rem 1rem;
        justify-content: center;
    }

    /* Chart container */
    .chart-body canvas {
        max-height: 200px;
    }

    /* Connection cards */
    .connections-grid {
        grid-template-columns: 1fr;
    }

    /* Modal padding */
    .modal-body {
        padding: 1rem;
    }

    .modal-header {
        padding: 1rem;
    }

    /* Spacing */
    .portal-p-responsive {
        padding: 0.75rem;
    }

    .portal-m-responsive {
        margin: 0.75rem;
    }

    /* Page headers */
    .readings-header,
    .dashboard-header,
    .transactions-header,
    .connections-header {
        margin: 12px;
        margin-bottom: 2.5rem !important;
        padding: 1.25rem;
        border-radius: var(--radius-xl, 16px);
    }

    /* Stats section */
    .stats-section {
        margin: 12px;
        margin-top: 0 !important;
        margin-bottom: 2.5rem !important;
        padding: 1rem;
    }

    /* Content wrapper */
    .content-wrapper {
        padding: 0.75rem;
    }
}

/* ========================================
   SMALL MOBILE BREAKPOINT (max-width: 576px)
   ======================================== */
@media (max-width: 576px) {
    /* Single column grids */
    .portal-stats-grid,
    .stats-grid,
    .stats-grid-horizontal {
        grid-template-columns: 1fr;
    }

    .portal-actions-grid,
    .quick-actions-grid {
        grid-template-columns: 1fr;
    }

    .portal-grid-2 {
        grid-template-columns: 1fr;
    }

    /* Usage stats */
    .usage-stats-row {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }

    /* Show card-based data, hide tables */
    .portal-table-desktop {
        display: none !important;
    }

    .portal-data-cards {
        display: block;
    }

    /* Smaller stat cards */
    .stat-card,
    .stat-card-mini {
        padding: 0.875rem;
    }

    .stat-card .stat-icon,
    .stat-card-mini .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }

    .stat-card .stat-value,
    .stat-card-mini .stat-value {
        font-size: 1.25rem;
    }

    /* Action buttons full width */
    .readings-actions .btn-readings {
        width: 100%;
        justify-content: center;
    }

    /* Tab navigation icons only */
    .tab-nav-modern {
        justify-content: space-around;
    }

    .tab-nav-modern .tab-btn {
        flex: 1;
        padding: 0.625rem;
    }

    /* Smaller header icons */
    .readings-icon {
        width: 70px;
        height: 70px;
        font-size: 2rem;
    }

    /* Header typography */
    .readings-details h2,
    .dashboard-header .welcome-info h1 {
        font-size: 1.25rem;
    }

    /* ========================================
       CHART / GRAPH RESPONSIVENESS
       ======================================== */

    /* Chart card - full width, proper padding */
    .chart-card {
        margin: 8px !important;
        padding: 0 !important;
        border-radius: 12px !important;
        overflow: hidden !important;
    }

    .chart-header {
        padding: 12px 16px !important;
        flex-wrap: wrap !important;
        gap: 8px !important;
    }

    .chart-header h6 {
        font-size: 14px !important;
        margin: 0 !important;
    }

    .chart-header .badge-modern {
        font-size: 10px !important;
        padding: 4px 8px !important;
    }

    .chart-body {
        padding: 12px !important;
    }

    /* Usage stats row - 2 columns on mobile */
    .usage-stats-row {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        margin-bottom: 16px !important;
    }

    .usage-stat-mini {
        padding: 12px !important;
        text-align: center !important;
        background: #f8fafc !important;
        border-radius: 8px !important;
    }

    .usage-stat-mini .stat-value {
        font-size: 20px !important;
        font-weight: 700 !important;
        color: #1e293b !important;
    }

    .usage-stat-mini .stat-label {
        font-size: 10px !important;
        color: #64748b !important;
        text-transform: uppercase !important;
        letter-spacing: 0.5px !important;
    }

    /* Chart container - proper sizing */
    [style*="height: 280px"] {
        height: 200px !important;
        min-height: 180px !important;
        max-height: 220px !important;
    }

    .chart-body canvas,
    [style*="height: 280px"] canvas {
        max-height: 200px !important;
        width: 100% !important;
    }

    /* Ensure chart respects container */
    canvas {
        max-width: 100% !important;
    }

    /* Balance card */
    .balance-card .balance-amount {
        font-size: 1.5rem;
    }

    /* Alert cards */
    .alert-card {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }

    .alert-card .btn-modern {
        width: 100%;
    }

    /* Empty state */
    .empty-state-modern {
        padding: 2rem 1rem;
    }

    .empty-state-modern .empty-icon {
        width: 60px;
        height: 60px;
        font-size: 1.5rem;
    }

    /* Content card header */
    .content-card-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: stretch;
    }

    .content-card-header .search-box {
        width: 100%;
    }

    .content-card-header .search-box .input-group {
        max-width: 100% !important;
    }

    /* Sidebar cards */
    .sidebar-card {
        padding: 1rem;
    }

    /* Activity items */
    .activity-item {
        padding: 0.875rem 1rem;
    }

    /* Pagination */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.25rem;
    }

    .pagination .page-link {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* ========================================
   EXTRA SMALL MOBILE (max-width: 380px)
   ======================================== */
@media (max-width: 380px) {
    /* Further reduce spacing */
    .readings-header,
    .dashboard-header {
        margin: 0.5rem;
        padding: 1rem;
    }

    .stats-section {
        margin: 0.5rem;
        padding: 0.75rem;
    }

    .content-wrapper {
        padding: 0.5rem;
    }

    /* Smaller typography */
    .readings-details h2,
    .dashboard-header .welcome-info h1 {
        font-size: 1.125rem;
    }

    .balance-card .balance-amount {
        font-size: 1.25rem;
    }

    /* Meta items stacking */
    .readings-meta {
        flex-direction: column;
        gap: 0.5rem;
    }

    .readings-meta-item {
        font-size: 0.75rem;
    }
}

/* ========================================
   Landscape Phone Adjustments
   ======================================== */
@media (max-height: 500px) and (orientation: landscape) {
    .portal-sidebar {
        top: 60px;
        height: calc(100vh - 60px);
    }

    .dashboard-wrap {
        padding-top: 60px !important;
    }

    .readings-header,
    .dashboard-header {
        padding: 1rem;
    }

    .readings-icon {
        width: 60px;
        height: 60px;
    }
}

/* ========================================
   Print Styles
   ======================================== */
@media print {
    .portal-sidebar,
    .mobNavigation,
    .portal-sidebar-backdrop,
    .readings-actions,
    .tab-nav-modern {
        display: none !important;
    }

    .dashboard-content,
    .dashboard-wrap .dashboard-content {
        margin-left: 0 !important;
    }

    .readings-header,
    .dashboard-header {
        background: #f5f5f5 !important;
        color: #333 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ========================================
   Mobile Navigation Enhancements
   Override conflicting styles from styles.css
   ======================================== */

/* Sidebar Backdrop - Must be visible on mobile */
.portal-sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1049;
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.portal-sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* Mobile Navigation Button - Fixed at bottom */
@media (max-width: 991px) {
    /* Override the conflicting styles from styles.css */
    .dashboard-wrap a.mobNavigation {
        position: fixed !important;
        bottom: 20px !important;
        left: 50% !important;
        transform: translateX(-50%) !important;
        width: auto !important;
        height: auto !important;
        padding: 14px 28px !important;
        background: linear-gradient(
            135deg,
            var(--mw-primary, #2596be),
            var(--mw-primary-700, #1a6382)
        ) !important;
        border-radius: 50px !important;
        margin-bottom: 0 !important;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25) !important;
        z-index: 1048 !important;
        font-size: 0.9375rem !important;
        font-weight: 600 !important;
        color: white !important;
        text-decoration: none !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.5rem !important;
        transition: all 0.3s ease !important;
    }

    .dashboard-wrap a.mobNavigation:hover,
    .dashboard-wrap a.mobNavigation:focus {
        transform: translateX(-50%) translateY(-2px) !important;
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3) !important;
    }

    /* Hide the icon text on very small screens */
    @media (max-width: 380px) {
        .dashboard-wrap a.mobNavigation {
            padding: 14px 20px !important;
            font-size: 0.875rem !important;
        }
    }

    /* Ensure sidebar appears above backdrop */
    .portal-sidebar {
        z-index: 1050 !important;
    }

    .portal-sidebar.mobile-open {
        left: 0 !important;
        box-shadow: 10px 0 40px rgba(0, 0, 0, 0.2);
    }

    /* Hide mobile nav when sidebar is open */
    .portal-sidebar.mobile-open ~ a.mobNavigation,
    .portal-sidebar-backdrop.active ~ a.mobNavigation {
        opacity: 0;
        pointer-events: none;
    }

    /* Dashboard content - ensure proper spacing at bottom for floating button */
    .dashboard-content {
        padding-bottom: 80px !important;
    }

    /* Sidebar close button enhancement */
    .portal-sidebar .portal-sidebar-toggle {
        display: flex !important;
    }
}

/* ========================================
   Safe Area Insets (iPhone X+ notch support)
   ======================================== */
@supports (padding: max(0px)) {
    .portal-sidebar {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }

    @media (max-width: 991px) {
        .dashboard-wrap a.mobNavigation {
            bottom: max(
                20px,
                calc(env(safe-area-inset-bottom) + 10px)
            ) !important;
        }

        .dashboard-content {
            padding-bottom: max(
                80px,
                calc(env(safe-area-inset-bottom) + 80px)
            ) !important;
        }
    }
}

/* ========================================
   Reduced Motion Preference
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .portal-sidebar,
    .portal-sidebar-backdrop,
    .portal-nav-link,
    .stat-card,
    .quick-action-card,
    .connection-card,
    .dashboard-wrap a.mobNavigation {
        transition: none !important;
    }
}

/* ========================================
   CRITICAL MOBILE FIXES
   Fix for Dashboard Layout, Top Padding, Card Widths
   ======================================== */
@media (max-width: 991px) {
    /* Add spacing between navbar and first card */
    .dashboard-wrap {
        padding-top: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        min-height: 100vh !important;
        margin-top: 0 !important;
        margin-left: 0 !important;
    }

    /* Fix header height and position - KEEP FIXED ON MOBILE */
    .header.header-light.head-fixed {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        z-index: 1020 !important; /* Higher z-index to stay above everything */
        height: auto !important;
        padding-top: 10px !important;
        padding-bottom: 10px !important;
        background: #ffffff !important;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1) !important;
    }

    /* Dashboard content - full width, no left margin from sidebar */
    .dashboard-content,
    .dashboard-wrap .dashboard-content,
    .portal-sidebar ~ .dashboard-content,
    .portal-sidebar.collapsed ~ .dashboard-content,
    body .dashboard-wrap .dashboard-content {
        margin-left: 0 !important;
        padding: 0 !important;
        padding-top: 90px !important; /* Visual separation: Fixed header (60px) + Gap (30px) */
        padding-bottom: 80px !important;
        width: 100% !important;
        max-width: 100% !important;
        left: 0 !important;
        transform: none !important;
        min-height: 100vh !important;
    }

    /* Portal dashboard container - remove extra padding */
    .portal-dashboard {
        padding: 0 !important;
        margin: 0 !important;
    }

    /* All page headers and sections - uniform 12px side margin */
    .dashboard-header,
    .readings-header,
    .connections-header,
    .payments-header,
    .reports-header,
    .profile-header,
    .alerts-section,
    .bill-header {
        margin: 0 12px 12px 12px !important;
        width: auto !important;
    }

    /* Stats section with uniform margin */
    .stats-section {
        margin: 0 12px !important;
        padding: 0 !important;
    }

    /* Content wrapper uniform padding */
    .content-wrapper {
        padding: 0 12px !important;
    }

    /* Stats grid - 2 columns, uniform side margin */
    .stats-grid,
    .portal-stats-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        margin: 0 12px 12px 12px !important;
        padding: 0 !important;
    }

    /* Remove individual margins from stat cards when inside grid */
    .stats-grid .stat-card,
    .stats-grid .stat-card-mini,
    .portal-stats-grid .stat-card,
    .portal-stats-grid .stat-card-mini {
        margin: 0 !important;
        width: auto !important;
    }

    /* Content cards - uniform side margin */
    .card-modern,
    .chart-card,
    .glass-card,
    .content-card {
        margin: 0 12px 12px 12px !important;
    }

    /* TABS - Horizontal scrollable on mobile */
    .nav-pills-modern,
    .nav-pills,
    .tab-nav-modern,
    .chart-tabs,
    #mainTabs,
    #chartTabs {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        gap: 4px !important;
        padding: 0.5rem !important;
        margin: 0 !important;
        scrollbar-width: none !important; /* Firefox */
        -ms-overflow-style: none !important; /* IE */
    }

    .nav-pills-modern::-webkit-scrollbar,
    .nav-pills::-webkit-scrollbar,
    .tab-nav-modern::-webkit-scrollbar,
    #mainTabs::-webkit-scrollbar,
    #chartTabs::-webkit-scrollbar {
        display: none !important; /* Chrome/Safari */
    }

    .nav-pills-modern .nav-link,
    .nav-pills .nav-link,
    .nav-pills-modern .nav-item .nav-link,
    #mainTabs .nav-link,
    #chartTabs .nav-link {
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
    }

    .nav-pills-modern .nav-item,
    .nav-pills .nav-item {
        flex-shrink: 0 !important;
    }

    /* Container fluid - consistent 12px padding */
    .container-fluid {
        padding-left: 12px !important;
        padding-right: 12px !important;
    }

    /* Row margins */
    .row {
        margin-left: -6px !important;
        margin-right: -6px !important;
    }

    /* Column padding - balanced with row margins */
    /* Large columns become full width on mobile */
    .col-lg-8,
    .col-lg-4,
    .col-md-12,
    .col-lg-6,
    .col-md-6 {
        padding-left: 6px !important;
        padding-right: 6px !important;
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }

    /* Keep col-6 at 50% width for 2-column grids on mobile */
    .col-6 {
        padding-left: 6px !important;
        padding-right: 6px !important;
        width: 50% !important;
        max-width: 50% !important;
        flex: 0 0 50% !important;
    }

    /* Stats grid - 2 columns */
    .stats-grid {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    .stats-grid .stat-card {
        margin: 0 !important;
    }

    /* Hide sidebar completely on mobile - all states */
    .portal-sidebar,
    .portal-sidebar.collapsed,
    .portal-sidebar.mobile-open,
    .dashboard-wrap .portal-sidebar,
    body .portal-sidebar {
        display: none !important;
        visibility: hidden !important;
        left: -9999px !important;
        width: 0 !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    .portal-sidebar-backdrop,
    .dashboard-wrap .portal-sidebar-backdrop,
    .portal-sidebar-backdrop.active {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }

    /* Hide the old mobile navigation button */
    .mobNavigation,
    .dashboard-wrap a.mobNavigation,
    a.mobNavigation {
        display: none !important;
    }

    /* Hide sidebar toggle button on mobile */
    .portal-sidebar-toggle,
    #sidebarToggle {
        display: none !important;
    }

    /* ========================================
       ULTRA-COMPACT PAGE HEADERS ON MOBILE
       Horizontal layout with inline icon
       ======================================== */

    /* Page header containers - horizontal layout */
    /* .connections-header,
    .readings-header,
    .bill-readings-header,
    .payments-header,
    [class*="-header"]:not(.chart-header):not(.sidebar-header):not(
            .content-card-header
        ):not(.modal-header) {
        padding: 12px 16px !important;
    } */

    /* Info section - horizontal flex layout */
    .connections-info-section,
    .readings-info-section,
    [class*="-info-section"] {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 12px !important;
        text-align: left !important;
    }

    /* Make icons much smaller and inline */
    .connections-icon-wrapper,
    .readings-icon-wrapper,
    [class*="-icon-wrapper"] {
        margin: 0 !important;
    }

    .connections-icon,
    .readings-icon,
    [class*="-icon"]:not(.activity-icon):not(.stat-icon):not(.link-icon):not(
            .alert-icon
        ):not(.empty-icon) {
        width: 40px !important;
        height: 40px !important;
        font-size: 1rem !important;
        border-width: 2px !important;
        flex-shrink: 0 !important;
    }

    /* Title and details section */
    .connections-details,
    .readings-details,
    [class*="-details"] {
        flex: 1 !important;
        margin: 0 !important;
    }

    .connections-details h2,
    .readings-details h2,
    [class*="-details"] h2 {
        font-size: 1rem !important;
        margin-bottom: 2px !important;
    }

    .connections-details .subtitle,
    .readings-details .subtitle,
    [class*="-details"] p.subtitle,
    [class*="-details"] .lead {
        font-size: 0.7rem !important;
        margin-bottom: 4px !important;
        display: none !important; /* Hide subtitles to save space */
    }

    /* Stats meta - inline compact pills */
    .connections-meta,
    .readings-stats,
    [class*="-meta"] {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 4px !important;
        margin-top: 4px !important;
    }

    .connections-meta-item,
    .readings-stats .stat-pill,
    [class*="-meta-item"],
    .stat-pill {
        padding: 2px 8px !important;
        font-size: 0.65rem !important;
    }

    /* HIDE ALL ACTION BUTTONS in headers on mobile */
    .connections-actions,
    .readings-actions,
    [class*="-actions"]:not(.card-actions) {
        display: none !important;
    }

    /* Hide breadcrumb on mobile to save space */
    [class*="-header"] .breadcrumb,
    [class*="-header"] nav[aria-label="breadcrumb"] {
        display: none !important;
    }

    /* Compact stats badges in headers */
    .readings-stats,
    .stats-pills,
    [class*="stats-row"] {
        gap: 4px !important;
        flex-wrap: wrap !important;
    }

    .readings-stats .stat-pill,
    .stats-pills .stat-pill,
    .stat-pill {
        padding: 3px 8px !important;
        font-size: 0.65rem !important;
    }

    /* ========================================
       COMPACT CONNECTION CARDS ON MOBILE
       ======================================== */

    .connection-card {
        padding: 12px !important;
        margin-bottom: 8px !important;
    }

    /* Smaller connection number font */
    .connection-card .connection-number,
    .connection-card h4,
    .connection-card .meter-number {
        font-size: 1rem !important;
    }

    /* Compact connection card info rows */
    .connection-card .info-row,
    .connection-card [class*="info"] {
        font-size: 0.75rem !important;
        padding: 4px 0 !important;
        gap: 4px !important;
    }

    /* Hide some secondary info on mobile connection cards */
    .connection-card .account-type-label,
    .connection-card .billing-cycle {
        display: none !important;
    }

    /* Compact connection card actions */
    .connection-card .card-actions,
    .connection-card [class*="actions"] {
        gap: 4px !important;
        padding-top: 8px !important;
    }

    .connection-card .card-actions .btn,
    .connection-card [class*="btn"] {
        padding: 6px 10px !important;
        font-size: 0.7rem !important;
    }

    /* Hide extra connection details on mobile - keep it essential */
    .connection-card .billing-info,
    .connection-card .location-info {
        display: none !important;
    }

    /* ========================================
       ACCOUNT HEALTH BADGE WITH CIRCULAR RING
       ======================================== */

    .account-health-badge {
        display: inline-flex !important;
        align-items: center !important;
        gap: 12px !important;
        padding: 10px 16px !important;
        background: rgba(255, 255, 255, 0.15) !important;
        border-radius: 50px !important;
        backdrop-filter: blur(4px) !important;
        margin-top: 8px !important;
    }

    .health-score-mini {
        position: relative !important;
        width: 50px !important;
        height: 50px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .health-score-mini::before {
        content: "" !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 50px !important;
        height: 50px !important;
        border-radius: 50% !important;
        border: 4px solid rgba(255, 255, 255, 0.25) !important;
    }

    .health-score-mini::after {
        content: "" !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 50px !important;
        height: 50px !important;
        border-radius: 50% !important;
        border: 4px solid transparent !important;
        border-top-color: #10b981 !important;
        border-right-color: #10b981 !important;
        border-bottom-color: #10b981 !important;
        border-left-color: #10b981 !important;
        animation: none !important;
    }

    .health-score-mini .score-value {
        font-size: 1.1rem !important;
        font-weight: 700 !important;
        color: white !important;
        z-index: 1 !important;
    }

    .health-info-mini {
        display: flex !important;
        flex-direction: column !important;
        gap: 2px !important;
    }

    .health-status-text {
        font-size: 0.875rem !important;
        font-weight: 600 !important;
        color: #10b981 !important;
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
    }

    .health-status-text.text-success {
        color: #10b981 !important;
    }
    .health-status-text.text-warning {
        color: #f59e0b !important;
    }
    .health-status-text.text-danger {
        color: #ef4444 !important;
    }

    .health-desc-text {
        font-size: 0.75rem !important;
        color: rgba(255, 255, 255, 0.8) !important;
    }

    /* ========================================
       STATS CARDS - PROPER HORIZONTAL LAYOUT
       ======================================== */

    .stats-grid-horizontal,
    .stats-section .stats-grid-horizontal {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
    }

    /* Individual stat cards - horizontal flex with compact padding */
    .stat-card-mini {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        padding: 8px 10px !important;
        width: 100% !important;
        min-width: 0 !important;
    }

    /* Reduce the stats section container padding */
    .stats-section {
        padding: 8px !important;
    }

    .stats-section .content-card {
        padding: 8px !important;
    }

    /* Icon on left - smaller */
    .stat-card-mini .stat-icon {
        width: 36px !important;
        height: 36px !important;
        font-size: 0.9rem !important;
        flex-shrink: 0 !important;
        order: 0 !important;
    }

    /* Content on right - stacked */
    .stat-card-mini .stat-content {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        text-align: left !important;
        order: 1 !important;
        min-width: 0 !important;
    }

    /* Value - smaller */
    .stat-card-mini .stat-value,
    .stat-card-mini .stat-content .stat-value {
        font-size: 1.1rem !important;
        font-weight: 700 !important;
        line-height: 1.2 !important;
        order: 0 !important;
    }

    /* Label - smaller */
    .stat-card-mini .stat-label,
    .stat-card-mini .stat-content .stat-label {
        font-size: 0.65rem !important;
        line-height: 1.2 !important;
        order: 1 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    /* ========================================
       RESPONSIVE TABLES - CARD LAYOUT ON MOBILE
       Transform table rows into stacked cards
       ======================================== */

    .table-responsive {
        overflow-x: visible !important;
    }

    table.table {
        display: block !important;
        width: 100% !important;
    }

    table.table thead {
        display: none !important;
    }

    table.table tbody {
        display: flex !important;
        flex-direction: column !important;
        gap: 12px !important;
    }

    table.table tbody tr {
        display: flex !important;
        flex-direction: column !important;
        background: #f8fafc !important;
        border-radius: 12px !important;
        padding: 12px !important;
        border: 1px solid #e2e8f0 !important;
        gap: 6px !important;
    }

    table.table tbody tr td {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        padding: 6px 0 !important;
        border: none !important;
        font-size: 0.8125rem !important;
    }

    table.table tbody tr td::before {
        content: attr(data-label) !important;
        font-weight: 600 !important;
        color: #64748b !important;
        font-size: 0.75rem !important;
        text-transform: uppercase !important;
        flex-shrink: 0 !important;
        margin-right: 8px !important;
    }

    /* Hide empty data-labels */
    table.table tbody tr td:empty::before {
        display: none !important;
    }

    /* Action buttons in table cards */
    table.table tbody tr td:last-child {
        justify-content: flex-end !important;
        padding-top: 8px !important;
        border-top: 1px solid #e2e8f0 !important;
        margin-top: 4px !important;
    }

    /* Alternative: horizontal scroll instead of card layout */
    .table-scroll-mobile {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    .table-scroll-mobile table {
        min-width: 600px !important;
        display: table !important;
    }

    .table-scroll-mobile table thead {
        display: table-header-group !important;
    }

    .table-scroll-mobile table tbody {
        display: table-row-group !important;
    }

    .table-scroll-mobile table tbody tr {
        display: table-row !important;
    }

    .table-scroll-mobile table tbody tr td {
        display: table-cell !important;
    }
}

/* ========================================
   MOBILE BOTTOM NAVIGATION BAR
   Fixed at bottom, always visible on mobile
   ======================================== */

/* Hidden by default on desktop */
nav.portal-bottom-nav,
.portal-bottom-nav {
    display: none !important;
    visibility: hidden !important;
}

/* Show on mobile */
@media screen and (max-width: 991px) {
    nav.portal-bottom-nav,
    .portal-bottom-nav {
        display: flex !important;
        visibility: visible !important;
        position: fixed !important;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        height: 65px !important;
        min-height: 65px !important;
        max-height: 65px !important;
        background: #ffffff !important;
        border-top: 1px solid #e5e7eb !important;
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1) !important;
        z-index: 20000 !important; /* Extremely high z-index */
        justify-content: space-around !important;
        align-items: center !important;
        padding: 4px 0 !important;
        margin: 0 !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        transform: translateZ(0) !important; /* Force hardware acceleration */
        -webkit-transform: translateZ(0) !important;
        overscroll-behavior: none !important;
        touch-action: none !important; /* Prevent touch interactions from scrolling the body */
    }

    .portal-bottom-nav-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-decoration: none !important;
        color: #9ca3af !important;
        font-size: 10px !important;
        font-weight: 500 !important;
        padding: 4px 8px !important;
        border-radius: 8px !important;
        transition: all 0.2s ease !important;
        min-width: 56px !important;
        flex: 1 !important;
        max-width: 80px !important;
    }

    .portal-bottom-nav-item:hover {
        color: #2596be !important;
        text-decoration: none !important;
    }

    .portal-bottom-nav-icon {
        width: 32px !important;
        height: 32px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 16px !important;
        margin-bottom: 2px !important;
        border-radius: 8px !important;
        background: transparent !important;
        color: inherit !important;
    }

    .portal-bottom-nav-label {
        font-size: 9px !important;
        font-weight: 500 !important;
        letter-spacing: 0 !important;
        white-space: nowrap !important;
        text-align: center !important;
    }

    /* Active state */
    .portal-bottom-nav-item.active {
        color: #2596be !important;
    }

    .portal-bottom-nav-item.active .portal-bottom-nav-icon {
        background: linear-gradient(135deg, #2596be, #1a6382) !important;
        color: white !important;
        border-radius: 10px !important;
        transform: translateY(-4px) !important;
        box-shadow: 0 4px 12px rgba(37, 150, 190, 0.35) !important;
    }

    .portal-bottom-nav-item.active .portal-bottom-nav-label {
        color: #2596be !important;
        font-weight: 600 !important;
    }
}

/* Extra small screens */
@media screen and (max-width: 380px) {
    nav.portal-bottom-nav,
    .portal-bottom-nav {
        height: 60px !important;
        min-height: 60px !important;
        max-height: 60px !important;
    }

    .portal-bottom-nav-item {
        min-width: 48px !important;
        padding: 2px 4px !important;
    }

    .portal-bottom-nav-icon {
        width: 28px !important;
        height: 28px !important;
        font-size: 14px !important;
    }

    .portal-bottom-nav-icon.primary {
        width: 38px !important;
        height: 38px !important;
        font-size: 16px !important;
    }

    .portal-bottom-nav-label {
        font-size: 8px !important;
    }
}

/* Safe area for iPhone X+ */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media screen and (max-width: 991px) {
        nav.portal-bottom-nav,
        .portal-bottom-nav {
            padding-bottom: env(safe-area-inset-bottom) !important;
            height: calc(65px + env(safe-area-inset-bottom)) !important;
            min-height: calc(65px + env(safe-area-inset-bottom)) !important;
        }

        .dashboard-content,
        .dashboard-wrap .dashboard-content {
            padding-bottom: calc(80px + env(safe-area-inset-bottom)) !important;
        }
    }
}

/* Print - hide bottom nav */
@media print {
    .portal-bottom-nav {
        display: none !important;
    }
}

/* ========================================
   RESPONSIVE WEB NAVBAR FIXES
   ======================================== */
/* ========================================
   RESPONSIVE WEB NAVBAR FIXES - TOP HEADER ALIGNMENT
   ======================================== */
@media (max-width: 991px) {
    /* Fix header container to be flex and centered - APPLY TO ALL STATES */
    .header .container,
    .header.head-fixed .container {
        height: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important; /* Start, we use margin-auto to push items */
        padding: 0 16px !important;
        max-width: 100% !important;
        gap: 0 !important;
    }

    /* 1. LOGO - Left */
    .nav-brand,
    .header .logo {
        display: flex !important;
        align-items: center !important;
        height: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        margin-right: auto !important; /* Push everything else to right */
        order: 1 !important;
    }

    .nav-brand img,
    .header .logo img {
        max-height: 32px !important;
        width: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        vertical-align: middle !important;
    }

    /* 2. PROFILE SECTION (.mobile_nav) - Right center */
    .mobile_nav.dhsbrd {
        display: flex !important;
        align-items: center !important;
        height: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        order: 2 !important;
        margin-right: 16px !important; /* Spacing between Profile and Menu */
    }

    .mobile_nav.dhsbrd > li {
        display: flex !important;
        align-items: center !important;
        height: 100% !important;
    }

    /* RESET BUTTON VARIANTS for Avatar Wrapper */
    .mobile_nav.dhsbrd .btn-group,
    .mobile_nav.dhsbrd .btn-group .btn,
    .mobile_nav.dhsbrd button {
        margin: 0 !important;
        padding: 8px 4px !important; /* Clear padding for click area */
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        display: flex !important;
        align-items: center !important;
        height: 100% !important;
    }

    /* Fix Avatar Profile Image */
    .mobile_nav.dhsbrd img.rounded-circle {
        height: 36px !important;
        width: 36px !important;
        min-height: 36px !important;
        min-width: 36px !important;
        object-fit: cover !important;
        margin: 0 !important;
        display: block !important;
        border: 2px solid #f1f5f9 !important;
    }

    /* Ensure Dropdown Works */
    .mobile_nav.dhsbrd .dropdown-menu {
        position: absolute !important;
        right: 0 !important;
        left: auto !important;
        top: 100% !important;
        margin-top: 0 !important;
    }

    /* 3. HAMBURGER MENU - Far Right */
    .header .nav-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        height: 100% !important;
        width: 40px !important; /* Ensure click target */
        top: 0 !important;
        right: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        position: relative !important;
        order: 3 !important;
    }

    /* Mobile Menu Toggle Icon centering */
    .nav-toggle::before,
    .nav-toggle::after {
        vertical-align: middle !important;
        margin-top: 0 !important;
        right: 0 !important;
    }

    /* Fix Mobile Footer Labels Disappearing */
    .portal-bottom-nav-label {
        display: block !important;
        opacity: 1 !important;
        visibility: visible !important;
        font-size: 10px !important;
        line-height: 1.2 !important;
        margin-top: 2px !important;
        font-weight: 600 !important;
    }

    /* Ensure nav items don't shrink too much */
    .portal-bottom-nav-item {
        flex-shrink: 0 !important;
        min-height: 100% !important;
        justify-content: center !important;
    }

    /* Fix offcanvas/mobile menu width */
    .offcanvas,
    .nav-menus-wrapper {
        max-width: 280px !important;
    }
}

/* ========================================
   FLOATING ACTION BUTTON (FAB)
   Quick actions button for mobile
   ======================================== */

/* Hidden by default */
.portal-fab-container {
    display: none;
}

@media screen and (max-width: 991px) {
    .portal-fab-container {
        display: block;
        position: fixed;
        bottom: 80px; /* Above the bottom nav */
        right: 16px;
        left: auto;
        z-index: 10000;
    }

    .portal-fab-container.open {
        z-index: 10010;
    }

    /* Main FAB trigger button */
    .portal-fab-trigger {
        width: 52px;
        height: 52px;
        border-radius: 16px;
        background: linear-gradient(135deg, #2596be, #1a6382);
        border: none;
        color: white;
        font-size: 20px;
        cursor: pointer;
        box-shadow: 0 4px 15px rgba(37, 150, 190, 0.4);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        position: relative;
        z-index: 9999;
    }

    .portal-fab-trigger:hover {
        transform: scale(1.05);
        box-shadow: 0 6px 20px rgba(37, 150, 190, 0.5);
    }

    .portal-fab-trigger:active {
        transform: scale(0.95);
    }

    /* Rotate icon when menu is open */
    .portal-fab-container.open .portal-fab-trigger {
        transform: rotate(45deg);
        background: linear-gradient(135deg, #ef4444, #dc2626);
    }

    .portal-fab-container.open .portal-fab-trigger i {
        transform: rotate(-45deg);
    }

    .portal-fab-container.open .portal-fab-trigger i::before {
        content: "\f00d"; /* X icon */
    }

    /* FAB menu container - aligned to right */
    .portal-fab-menu {
        position: absolute;
        bottom: 60px;
        right: 0;
        left: auto;
        display: flex;
        flex-direction: column;
        align-items: flex-end;
        gap: 10px;
        opacity: 0;
        visibility: hidden;
        transform: translateY(20px) scale(0.8);
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        pointer-events: none;
    }

    .portal-fab-container.open .portal-fab-menu {
        opacity: 1;
        visibility: visible;
        transform: translateY(0) scale(1);
        pointer-events: auto;
        z-index: 10011;
    }

    /* FAB menu items */
    .portal-fab-item {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 8px 14px 8px 8px;
        background: white;
        border-radius: 28px;
        text-decoration: none;
        box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
        transition: all 0.2s ease;
        position: relative;
        z-index: 10012;
        white-space: nowrap;
    }

    .portal-fab-item:hover {
        transform: translateX(4px);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    }

    .portal-fab-item-icon {
        width: 36px;
        height: 36px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 14px;
        flex-shrink: 0;
    }

    .portal-fab-item-label {
        font-size: 13px;
        font-weight: 600;
        color: #1e293b;
    }

    /* Stagger animation for menu items */
    .portal-fab-container.open .portal-fab-item:nth-child(1) {
        transition-delay: 0ms;
    }
    .portal-fab-container.open .portal-fab-item:nth-child(2) {
        transition-delay: 50ms;
    }
    .portal-fab-container.open .portal-fab-item:nth-child(3) {
        transition-delay: 100ms;
    }

    /* Backdrop */
    .portal-fab-backdrop {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.3);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        z-index: 9997;
        pointer-events: none;
    }

    .portal-fab-container.open .portal-fab-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    /* Hide ALL Quick Links & Quick Action cards on mobile since we have FAB */
    .sidebar-card,
    .quick-links-card,
    .quick-action-card,
    [class*="quick-link"],
    .sidebar-card-title:has(i.fa-link),
    .col-lg-4 > .sidebar-card {
        display: none !important;
    }

    /* Exception: Keep the main content cards visible */
    .main-content .sidebar-card,
    .dashboard-content .content-card {
        display: block !important;
    }
}

/* Extra small screens */
@media screen and (max-width: 380px) {
    .portal-fab-container {
        bottom: 72px;
        right: 12px;
        left: auto;
    }

    .portal-fab-trigger {
        width: 46px;
        height: 46px;
        font-size: 18px;
        border-radius: 14px;
    }

    .portal-fab-item {
        padding: 6px 12px 6px 6px;
    }

    .portal-fab-item-icon {
        width: 32px;
        height: 32px;
        font-size: 12px;
    }

    .portal-fab-item-label {
        font-size: 12px;
    }
}

/* Print - hide FAB */
@media print {
    .portal-fab-container {
        display: none !important;
    }
}

/* ========================================
   GLOBAL MODAL Z-INDEX FIX
   Ensures Bootstrap modals appear above all portal elements
   ======================================== */
.modal {
    z-index: 2000000 !important;
}

.modal-backdrop {
    z-index: 1999999 !important;
}

.modal-dialog {
    z-index: 2000001 !important;
}

.modal-content {
    z-index: 2000002 !important;
}
