/* Import Professional Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* Dashboard Page Styles */
.opti-behavior-dashboard-page {
    background: #f8f9fa;
    margin: 0;
    padding: 0;
}


    /* Empty state styles - Professional and properly centered */
    .optibehavior-empty-state {
        display: none;
        width: 100%;
        height: 100%;
        min-height: 180px;
        padding: 0;
        margin: 0;
        border: none;
        border-radius: 0;
        background: transparent;
        color: #6b7280;
        align-items: center;
        justify-content: center;
        text-align: center;
        gap: 16px;
        flex-direction: column;
        position: relative;
    }
    .optibehavior-empty-state.is-visible {
        display: flex;
    }

    /* Empty state content styling */
    .optibehavior-empty-state svg {
        width: 48px;
        height: 48px;
        opacity: 0.6;
        margin-bottom: 4px;
    }
    .optibehavior-empty-title {
        font-weight: 600;
        font-size: 14px;
        color: #374151;
        margin: 0;
        line-height: 1.4;
    }
    .optibehavior-empty-sub {
        font-size: 12px;
        color: #9ca3af;
        margin: 0;
        line-height: 1.3;
        max-width: 200px;
    }

    .optibehavior-empty-state svg{width:56px;height:56px;opacity:.85}
    .optibehavior-empty-title{font-weight:600;color:#374151}
    .optibehavior-empty-sub{font-size:12px;color:#6b7280}

/* Dashboard Header */
.dashboard-header {
    background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 50%, #6d28d9 100%);
    color: white;
    padding: 28px 32px;
    margin: -1px -20px 24px -20px;
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.25);
    display: flex;
    justify-content: space-between;
    align-items: center;
    overflow: visible; /* Allow tooltips to overflow */
    position: relative;
}

.dashboard-title-section {
    display: flex;
    align-items: center;
    gap: 16px;
}

.dashboard-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    color: #fff;
}

.dashboard-icon i {
    width: 24px;
    height: 24px;
}

.dashboard-title {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    color: #fff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    line-height: 1.2;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dashboard-subtitle {
    color: rgba(255, 255, 255, 0.8);
    font-size: 13px;
    margin: 4px 0 0 0;
    font-weight: 400;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

.dashboard-controls {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.period-selector {
    height: 36px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: #fff;
    color: #333;
    font-size: 13px;
    outline: none;
    cursor: pointer;
    transition: all 0.2s;
    box-sizing: border-box;
}

.period-selector option {
    background: #fff;
    color: #333;
}

.dashboard-controls input[type="date"] {
    height: 36px;
    padding: 8px 12px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: #fff;
    color: #333;
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
    box-sizing: border-box;
}

.dashboard-controls input[type="date"]:focus {
    border-color: #7c3aed;
    background: #fff;
}

.dashboard-controls input[type="date"]::-webkit-calendar-picker-indicator {
    filter: none;
}

.refresh-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    height: 36px;
    box-sizing: border-box;
}

.refresh-btn svg,
.refresh-btn i {
    width: 16px;
    height: 16px;
}

.refresh-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

/* Exclude Spam Filter Button */
.filter-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    height: 36px;
    box-sizing: border-box;
}

.filter-btn svg,
.filter-btn i {
    width: 16px;
    height: 16px;
}

.filter-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.filter-btn.active {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    border-color: #10b981;
    box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
}

.filter-btn.active:hover {
    background: linear-gradient(135deg, #059669 0%, #047857 100%);
}

.filter-btn .filter-icon {
    display: flex;
    align-items: center;
}

.filter-btn .filter-icon svg {
    width: 16px;
    height: 16px;
}

.filter-btn.active .filter-icon svg {
    stroke: white;
}

/* Dashboard Stats */
.dashboard-stats {
    display: grid;
    /* Exactly 3 cards per row on desktop to create two lines of 3 */
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    padding: 30px 40px;
    margin: 0 auto;
    max-width: 1200px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative; /* For absolute tooltip positioning */
    overflow: visible; /* Allow tooltips to overflow */
    z-index: 1; /* Base z-index */
    transition: z-index 0s;
}

.stat-card:hover {
    z-index: 100; /* Higher z-index on hover to ensure tooltip appears above siblings */
}

.stat-icon {
    font-size: 32px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8f9fa;
    border-radius: 12px;
}

.stat-content {
    flex: 1;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 4px;
}

.stat-change {
    font-size: 12px;
    font-weight: 500;
}

.stat-change.positive {
    color: #28a745;
}

.stat-change.negative {
    color: #dc3545;
}

.stat-change.neutral {
    color: #6c757d;
}

/* Stat History Mini Chart */
.stat-history {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e5e7eb;
}

.stat-history canvas {
    max-height: 50px !important;
    width: 100% !important;
    display: block;
}

/* Dashboard Content */
.dashboard-content {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 40px 40px;
}

.dashboard-grid {
    display: grid;
    /* Flexible grid layout matching online version */
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}
/* Tablet: 2 columns */
@media (max-width: 1200px) {
    .dashboard-grid { grid-template-columns: repeat(2, 1fr); }
}

.dashboard-widget {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(2,6,23,0.06);
    overflow: visible; /* Allow tooltips to overflow */
    border: 1px solid #e8ebf2;
    display: flex;
    flex-direction: column;
    min-height: 260px;
}

.widget-header {
    padding: 20px 24px;
    border-bottom: 1px solid #f1f3f4;
    overflow: visible; /* Allow tooltips to show */
    position: relative; /* Establish stacking context */
}

.widget-title {
    font-size: 16px;
    font-weight: 650;
    color: #111827;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    overflow: visible; /* Allow tooltips to overflow */
}

.widget-icon {
    font-size: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.widget-icon-svg {
    flex-shrink: 0;
}

.widget-content {
    padding: 20px 24px;
    flex: 1 1 auto;
    display: flex;
    align-items: flex-start;
    justify-content: flex-start;
    min-height: 220px;
    position: relative;
    overflow: hidden; /* Keep content contained, tooltips are in widget-header */
}
/* Lists (not centered) */
.realtime-widget .widget-content,
.pages-widget .widget-content { display:block; min-height:260px; }


        /* Widget-specific empty state adjustments */
        .top-users-widget .widget-content { display:block; min-height:260px; }
        /* chart-widget styles are defined below */

        /* Empty states in compact widgets */
        .widget-content.compact .optibehavior-empty-state {
            min-height: 200px;
        }

        /* Empty states in larger widgets */
        .chart-widget .optibehavior-empty-state {
            min-height: 320px;
        }

        /* Traffic Overview Chart Styling - Clean Professional Design */
        .chart-widget {
            position: relative;
            overflow: hidden;
        }

        .chart-widget .widget-content {
            position: relative;
            display: block;
            padding: 10px 15px 10px 15px;
            background: transparent;
            border-radius: 0;
            box-shadow: none;
            margin-top: 0;
            min-height: auto;
        }

        .chart-widget .chart-container {
            position: relative;
            height: 300px;
            width: 100%;
            max-width: 100%;
            overflow: visible;
            box-sizing: border-box;
            padding: 0;
            margin: 0;
        }

        .chart-widget canvas {
            width: 100% !important;
            height: 100% !important;
            max-height: 300px !important;
            max-width: 100% !important;
            border-radius: 0;
            display: block;
            box-sizing: border-box;
        }

        .chart-widget .widget-header {
            margin-bottom: 0;
            padding: 12px 20px;
            border-bottom: 1px solid #f1f3f4;
            background: transparent;
            position: relative;
            z-index: 1;
        }

        .chart-widget .widget-title {
            font-size: 16px;
            font-weight: 700;
            color: #111827;
            letter-spacing: -0.02em;
            display: flex;
            align-items: center;
            gap: 10px;
            margin: 0;
        }

        .chart-widget .widget-icon {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 24px;
            height: 24px;
            color: #1f2937; /* Dark gray/black color for icon */
            flex-shrink: 0;
        }

        .chart-widget .widget-icon svg {
            width: 20px;
            height: 20px;
            stroke-width: 2;
        }

        .top-users-widget .optibehavior-empty-state,
        .realtime-widget .optibehavior-empty-state,
        .pages-widget .optibehavior-empty-state {
            min-height: 220px;
        }

    /* Compact widget content for small charts */
    .widget-content.compact {
        padding: 16px 20px;
        display: flex;
        align-items: stretch;
        justify-content: stretch;
        position: relative;
    }
    /* Make canvases fill the available widget space */
    .widget-content.compact canvas { width: 100% !important; height: 100% !important; max-width: 100%; }
    .device-widget .widget-content.compact canvas { height: 100% !important; }
    .browsers-widget .widget-content.compact canvas,
    .os-widget .widget-content.compact canvas,
    .referrers-widget .widget-content.compact canvas { height: 100% !important; }

    /* Ensure chart widgets match Top Pages height */
    .referrers-widget .widget-content.compact,
    .browsers-widget .widget-content.compact { min-height: 260px; }
        .os-widget .widget-content.compact { min-height: 260px; }


    /* Chart widgets use standard compact padding */

    /* Top Countries Widget - Professional Table Layout */
    .countries-widget .widget-content {
        padding: 20px 24px; /* Keep standard widget padding for scrollbar positioning */
        display: block;
        min-height: auto;
        background: #ffffff;
    }

    .countries-table-container {
        width: 100%;
        overflow-x: auto;
    }

    .countries-table {
        width: 100%;
        border-collapse: separate;
        border-spacing: 0;
        font-size: 14px;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    }

    .countries-table thead {
        background-color: transparent;
        border-bottom: 1px solid #e5e7eb;
    }

    .countries-table thead th {
        padding: 16px 24px;
        text-align: left;
        font-weight: 600;
        font-size: 13px;
        color: #374151;
        letter-spacing: 0;
        border-bottom: 1px solid #e5e7eb;
    }

    .countries-table thead th.country-visitors-col {
        text-align: right;
    }

    /* Top Countries: use shared ob-metric-row pattern */
    .countries-table {
        width: 100%;
        table-layout: fixed; /* Fixed table layout for consistent column widths */
    }

    .countries-table tbody tr.ob-metric-row {
        border-bottom: 1px solid #f3f4f6;
        transition: background-color 0.12s ease;
    }

    .countries-table tbody tr.ob-metric-row:last-child {
        border-bottom: none;
    }

    .countries-table tbody tr.ob-metric-row:hover {
        background-color: #f9fafb;
    }

    .countries-table tbody td {
        padding: 6px 0;
        vertical-align: middle;
    }

    .country-name-cell {
        width: 40%; /* Fixed width for country name column */
        text-align: left;
        padding-right: 12px;
    }

    .country-visitors-cell {
        width: 60%; /* Fixed width for stats column */
        text-align: right;
    }

    /* Country flag icon - same size as bot icons */
    .country-flag {
        width: 20px;
        height: 14px;
        flex-shrink: 0;
        display: inline-block;
        background-size: cover;
        background-position: center;
        background-repeat: no-repeat;
        border-radius: 2px;
        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
    }

    /* Country name - use shared ob-metric-label styling */
    .country-name {
        color: #374151;
        font-weight: 400;
        font-size: 13px;
        line-height: 1.4;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        max-width: 140px;
    }

    /* Top Countries: ensure .ob-metric-main and .ob-metric-values are properly aligned */
    .countries-widget .ob-metric-main {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        flex: 1; /* Allow it to take available space */
    }

    .countries-widget .ob-metric-values {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        justify-content: flex-end;
        white-space: nowrap;
    }

    /* Visitor count badge - consistent with other widgets */
    .countries-widget .visitor-count {
        background-color: #10b981;
        color: #ffffff;
        font-weight: 600;
        font-size: 12px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 42px;
        height: 22px;
        padding: 0 8px;
        border-radius: 11px;
        flex-shrink: 0;
        box-sizing: border-box;
    }

    /* Visitor percentage - consistent styling */
    .countries-widget .visitor-percentage {
        color: #6b7280;
        font-size: 13px;
        font-weight: 400;
        display: inline-block;
        min-width: 60px;
        text-align: left;
        flex-shrink: 0;
    }

    .visitor-trend {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        font-size: 12px;
        font-weight: 500;
        flex-shrink: 0;
        min-width: 50px;
        justify-content: flex-start;
    }

    .visitor-trend.trend-up {
        color: #10b981;
    }

    .visitor-trend.trend-down {
        color: #ef4444;
    }

    .visitor-trend.trend-neutral {
        color: #6b7280;
    }

    .visitor-trend svg {
        width: 14px;
        height: 14px;
    }

	    /* Shared metric row layout (used by Traffic Classification, Bot Traffic, etc.) */
	    .ob-metric-row {
	        display: flex;
	        align-items: center;
	        gap: 12px;
	        padding: 6px 0;
	        border-bottom: 1px solid #f3f4f6;
	    }

	    .ob-metric-row:last-child {
	        border-bottom: none;
	    }

	    .ob-metric-main {
	        display: inline-flex;
	        align-items: center;
	        gap: 8px;
	        min-width: 0;
	        padding-right: 24px; /* create comfortable space before stats block */
	    }

			.ob-referrer-favicon {
				width: 16px;
				height: 16px;
				border-radius: 4px;
				object-fit: contain;
				flex-shrink: 0;
			}


	    .ob-metric-label {
	        font-size: 13px;
	        color: #374151;
	        white-space: nowrap;
	        text-overflow: ellipsis;
	        overflow: hidden;
	        max-width: 140px;
	    }

	    .ob-metric-values {
	        display: inline-flex;
	        align-items: center;
	        white-space: nowrap;
	        margin-left: auto;
	    }

	    /* Use the exact same metric spacing as the Traffic Classification template */
	    .ob-metric-values .visitor-count {
	        background-color: #10b981;
	        color: #ffffff;
	        font-weight: 600;
	        font-size: 13px;
	        display: inline-flex;
	        align-items: center;
	        justify-content: center;
	        min-width: 42px;
	        height: 24px;
	        padding: 0 10px;
	        border-radius: 12px;
	        margin-right: 8px;
	    }

	    .ob-metric-values .visitor-percentage {
	        color: #6b7280;
	        font-size: 13px;
	        font-weight: 600;
	        margin-right: 8px;
	        display: inline-block;
	        min-width: 40px;
	        text-align: left;
	    }

	    .ob-metric-values .visitor-trend {
	        display: inline-flex;
	        align-items: center;
	        gap: 2px;
	        font-size: 13px;
	        font-weight: 600;
	        min-width: 55px;
	    }


    /* Empty state for countries table */
    .countries-table .empty-cell,
    .countries-table .loading-cell {
        padding: 40px 24px;
        text-align: center;
    }

    .countries-table .optibehavior-empty-state {
        min-height: 200px;
    }

    /* ============================================
       TOP REFERRERS TABLE STYLING
       ============================================ */

    .referrers-table-container {
        width: 100%;
        overflow-x: hidden;
    }

    .referrers-table {
        width: 100%;
        border-collapse: collapse;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
        table-layout: fixed; /* Fixed table layout for consistent column widths */
    }

    .referrers-table tbody td {
        padding: 6px 8px;
        vertical-align: middle;
        border-bottom: 1px solid #f3f4f6;
    }

    .referrers-table tbody tr:last-child td {
        border-bottom: none;
    }

    .referrers-table tbody tr:hover {
        background-color: #f9fafb;
    }

    /* Referrer name cell */
    .referrer-name-cell {
        width: 40%; /* Fixed width for referrer name column */
        text-align: left;
        padding-right: 2px; /* slightly reduce gap before stats */
    }

    .referrer-name-cell > span {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        vertical-align: middle;
    }

    .referrer-icon {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
        display: inline-block;
        background-size: contain;
        background-position: center;
        background-repeat: no-repeat;
        border-radius: 3px;
        vertical-align: middle;
    }

    .referrer-icon-svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        vertical-align: middle;
    }

    .referrer-icon-svg svg {
        width: 20px;
        height: 20px;
        display: block;
    }

    .referrer-name {
        color: #1f2937;
        font-weight: 400;
        font-size: 13px;
        line-height: 1.4;
        display: inline-block;
        vertical-align: middle;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
        max-width: 90px; /* Reduced width to prevent crossing into stats badges */
    }

    /* Referrer visitors cell: reuse shared metric template */
    .referrer-visitors-cell {
        width: 60%; /* Fixed width for stats column */
        text-align: right;
        white-space: nowrap;
        /* Extra right padding so stats never sit under the vertical scrollbar */
        padding-right: 18px;
    }

    /* Top Referrers: ensure .ob-metric-main and .ob-metric-values are properly aligned */
    .referrers-widget .ob-metric-main {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        flex: 1; /* Allow it to take available space */
        padding-right: 4px;
    }

    .referrers-widget .ob-metric-values {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        justify-content: flex-end;
        white-space: nowrap;
    }

    /* Top Referrers: keep growth indicator fully inside the scroll area */
    .referrers-widget .ob-metric-values .visitor-trend {
        min-width: 40px;
        max-width: 40px;
    }

    /* Empty state for referrers table */
    .referrers-table .empty-cell,
    .referrers-table .loading-cell {
        padding: 40px 24px;
        text-align: center;
    }

    .referrers-table .optibehavior-empty-state {
        min-height: 200px;
    }

    /* ============================================
       BROWSERS TABLE STYLING
       ============================================ */

    .browsers-table-container {
        width: 100%;
        overflow-x: auto;
        /* Add scrollbar - show max 6 items by default (6 rows × 40px per row = 240px) */
        max-height: 240px; /* show 6 complete items before scroll */
        overflow-y: auto;   /* show scrollbar when there are many entries */
        margin-right: -24px; /* push scrollbar to widget border */
        padding-right: 24px; /* keep content aligned with other widgets */
    }

    .browsers-table {
        width: 100%;
        border-collapse: collapse;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    }

    .browsers-table tbody td {
        padding: 6px 16px;
        vertical-align: middle;
        border-bottom: 1px solid #f3f4f6;
    }

    .browsers-table tbody tr:last-child td {
        border-bottom: none;
    }

    .browsers-table tbody tr:hover {
        background-color: #f9fafb;
    }

    /* Browser name cell */
    .browser-name-cell {
        text-align: left;
    }

    .browser-name-cell > span {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        vertical-align: middle;
    }

    .browser-icon-svg {
        width: 20px;
        height: 20px;
        flex-shrink: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        vertical-align: middle;
    }

    .browser-icon-svg svg {
        width: 20px;
        height: 20px;
        display: block;
    }

    .browser-name {
        color: #1f2937;
        font-weight: 400;
        font-size: 13px;
        line-height: 1.4;
        display: inline-block;
        vertical-align: middle;
    }

    /* Browser visitors cell */
    .browser-visitors-cell {
        text-align: right;
        white-space: nowrap;
    }

    /* Reuse the same visitor count, percentage, and trend styles */
    .browser-visitors-cell .visitor-count {
        background-color: #10b981;
        color: #ffffff;
        font-weight: 600;
        font-size: 13px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 42px;
        height: 24px;
        padding: 0 10px;
        border-radius: 12px;
        margin-right: 8px;
    }

    .browser-visitors-cell .visitor-percentage {
        color: #6b7280;
        font-size: 13px;
        font-weight: 400;
        display: inline-block;
    }

    .browser-visitors-cell .visitor-trend {
        display: inline-flex;
        align-items: center;
        gap: 3px;
        font-size: 12px;
        font-weight: 500;
        margin-left: 8px;
    }

    .browser-visitors-cell .visitor-trend.trend-up {
        color: #10b981;
    }

    .browser-visitors-cell .visitor-trend.trend-down {
        color: #ef4444;
    }

    .browser-visitors-cell .visitor-trend.trend-neutral {
        color: #6b7280;
    }

    .browser-visitors-cell .visitor-trend svg {
        width: 14px;
        height: 14px;
    }

    /* Empty state for browsers table */
    .browsers-table .empty-cell,
    .browsers-table .loading-cell {
        padding: 40px 24px;
        text-align: center;
    }

    .browsers-table .optibehavior-empty-state {
        min-height: 200px;
    }

    /* ========================================
       Traffic Classification Widget Styles
       ======================================== */

    .traffic-classification-legend {
        width: 100%;
        border-collapse: collapse;
        table-layout: auto;
    }

    .traffic-classification-legend tbody tr {
        border-bottom: 1px solid #f3f4f6;
    }

    .traffic-classification-legend tbody tr:last-child {
        border-bottom: none;
    }

    .traffic-classification-legend td {
        padding: 6px 0;
        vertical-align: middle;
    }

    /* Traffic type cell (left column) */
    .traffic-type-cell {
        width: auto;
        text-align: left;
        padding-right: 20px;
    }

    .traffic-type-cell > span {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        vertical-align: middle;
    }

    .traffic-color-dot {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        flex-shrink: 0;
        display: inline-block;
    }

    .traffic-type-name {
        color: #1f2937;
        font-weight: 400;
        font-size: 13px;
        line-height: 1.4;
        display: inline-block;
        vertical-align: middle;
        white-space: nowrap;
    }

    /* Traffic stats cell (right column) */
    .traffic-stats-cell {
        text-align: right;
        white-space: nowrap;
        width: 100%;
    }

    /* Reuse the same visitor count, percentage, and trend styles */
    .traffic-stats-cell .visitor-count {
        background-color: #10b981;
        color: #ffffff;
        font-weight: 600;
        font-size: 13px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 42px;
        height: 24px;
        padding: 0 10px;
        border-radius: 12px;
        margin-right: 8px;
        vertical-align: middle;
    }

    .traffic-stats-cell .visitor-percentage {
        color: #6b7280;
        font-size: 13px;
        font-weight: 600;
        margin-right: 8px;
        display: inline-block;
        min-width: 40px;
        text-align: left;
        vertical-align: middle;
    }

    .traffic-stats-cell .visitor-trend {
        display: inline-flex;
        align-items: center;
        gap: 2px;
        font-size: 13px;
        font-weight: 600;
        min-width: 55px;
        vertical-align: middle;
    }

    .traffic-stats-cell .visitor-trend.trend-up {
        color: #10b981;
    }

    .traffic-stats-cell .visitor-trend.trend-down {
        color: #ef4444;
    }

    .traffic-stats-cell .visitor-trend.trend-neutral {
        color: #6b7280;
    }

    .traffic-stats-cell .visitor-trend svg {
        width: 14px;
        height: 14px;
    }

    /* Empty state for traffic classification legend */
    .traffic-classification-legend .empty-cell,
    .traffic-classification-legend .loading-cell {
        padding: 40px 24px;
        text-align: center;
    }

    .traffic-classification-legend .optibehavior-empty-state {
        min-height: 200px;
    }

    /* ========================================
       Visited Directories Widget Styles
       ======================================== */

    .visited-directories-list {
        width: 100%;
        margin-top: 8px;
    }

    .visited-directories-widget .traffic-classification-legend {
        width: 100%;
    }

    .visited-directories-widget .traffic-type-name {
        transition: color 0.2s ease;
    }

    .visited-directories-widget .traffic-type-name:hover {
        color: #6366F1 !important;
        text-decoration: underline !important;
    }


	/* ========================================
	   Bot Traffic Widget Styles
	   ======================================== */

	.bot-traffic-widget .bot-traffic-list {
		display: flex;
		flex-direction: column;
		gap: 6px;
	}

	/* Shared vertical scroll treatment for Bot Traffic + Top Referrers widgets */
	.bot-traffic-widget .bot-traffic-list,
	.referrers-widget .referrers-table-container {
		max-height: 270px; /* show limited items before scroll */
		overflow-y: auto;   /* show scrollbar when there are many entries */
		margin-right: -24px; /* push scrollbar to widget border */
		padding-right: 24px; /* keep content aligned with other widgets */
	}

		/* Top Referrers: adjust height so about 7 rows are visible before scroll */
		.referrers-widget .referrers-table-container {
			max-height: 262px; /* ~7 x 36.7px rows + small buffer */
		}

	/* Top Referrers: share same scroll treatment as Bot Traffic */
	.referrers-widget .referrers-table-container {
		margin-right: -24px;
		padding-right: 24px;
	}


	.bot-traffic-widget .bot-item:last-child {
		border-bottom: none;
	}

	.bot-traffic-widget .bot-info {
		display: inline-flex;
		align-items: center;
		gap: 8px;
		min-width: 0;
	}

	.bot-traffic-widget .bot-icon {
		display: inline-flex;
		align-items: center;
		justify-content: center;
		width: 28px;
		height: 28px;
		border-radius: 9999px;
		background-color: #f3f4f6;
		color: #6b7280;
		flex-shrink: 0;
	}

	.bot-traffic-widget .bot-icon i,
	.bot-traffic-widget .bot-icon svg {
		width: 16px;
		height: 16px;
	}

	.bot-traffic-widget .bot-label {
		font-size: 13px;
		color: #374151;
		white-space: nowrap;
		text-overflow: ellipsis;
		overflow: hidden;
		max-width: 140px;
	}


    /* ========================================
       Device Types Widget Styles
       ======================================== */

    .device-types-legend {
        width: 100%;
        border-collapse: collapse;
        table-layout: auto;
    }

    .device-types-legend tbody tr {
        border-bottom: 1px solid #f3f4f6;
    }

    .device-types-legend tbody tr:last-child {
        border-bottom: none;
    }

    .device-types-legend td {
        padding: 6px 0;
        vertical-align: middle;
    }

    /* Device type cell (left column) */
    .device-type-cell {
        width: auto;
        text-align: left;
    }

    .device-type-cell > span {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        vertical-align: middle;
        margin-right: 16px;
    }

    .device-color-dot {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        flex-shrink: 0;
        display: inline-block;
    }

    .device-type-name {
        color: #1f2937;
        font-weight: 400;
        font-size: 13px;
        line-height: 1.4;
        white-space: nowrap;
    }

    /* Device stats cell (right column) - matching Traffic Classification pattern */
    .device-stats-cell {
        text-align: right;
        white-space: nowrap;
        width: 100%;
    }

    /* Reuse the same visitor count, percentage, and trend styles */
    .device-stats-cell .visitor-count {
        background-color: #10b981;
        color: #ffffff;
        font-weight: 600;
        font-size: 13px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 42px;
        height: 24px;
        padding: 0 10px;
        border-radius: 12px;
        margin-right: 8px;
        vertical-align: middle;
    }

    .device-stats-cell .visitor-percentage {
        color: #6b7280;
        font-size: 13px;
        font-weight: 600;
        margin-right: 8px;
        display: inline-block;
        min-width: 40px;
        text-align: left;
        vertical-align: middle;
    }

    .device-stats-cell .visitor-trend {
        display: inline-flex;
        align-items: center;
        gap: 2px;
        font-size: 13px;
        font-weight: 600;
        min-width: 55px;
        vertical-align: middle;
    }

    .device-stats-cell .visitor-trend.trend-up {
        color: #10b981;
    }

    .device-stats-cell .visitor-trend.trend-down {
        color: #ef4444;
    }

    .device-stats-cell .visitor-trend.trend-neutral {
        color: #6b7280;
    }

    /* Empty state for device types legend */
    .device-types-legend .empty-cell,
    .device-types-legend .loading-cell {
        padding: 40px 24px;
        text-align: center;
    }

    .device-types-legend .optibehavior-empty-state {
        min-height: 200px;
    }

    /* ========================================
       Operating Systems Widget Styles
       ======================================== */

    /* OS table container with scrollbar - show max 4 items by default */
    .os-table-container {
        width: 100%;
        overflow-x: auto;
        max-height: 148px; /* show 4 complete items before scroll (4 rows × 37px per row ≈ 148px) */
        overflow-y: auto;   /* show scrollbar when there are many entries */
        margin-right: -24px; /* push scrollbar to widget border */
        padding-right: 24px; /* keep content aligned with other widgets */
    }

    .os-legend {
        width: 100%;
        border-collapse: collapse;
        table-layout: auto;
    }

    .os-legend tbody tr {
        border-bottom: 1px solid #f3f4f6;
    }

    .os-legend tbody tr:last-child {
        border-bottom: none;
    }

    .os-legend td {
        padding: 6px 0;
        vertical-align: middle;
    }

    /* OS type cell (left column) */
    .os-type-cell {
        width: auto;
        text-align: left;
    }

    .os-type-cell > span {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        vertical-align: middle;
        margin-right: 16px;
    }

    .os-color-dot {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        flex-shrink: 0;
        display: inline-block;
    }

    .os-type-name {
        color: #1f2937;
        font-weight: 400;
        font-size: 13px;
        line-height: 1.4;
        white-space: nowrap;
    }

    /* OS stats cell (right column) - matching Traffic Classification pattern */
    .os-stats-cell {
        text-align: right;
        white-space: nowrap;
        width: 100%;
    }

    /* Reuse the same visitor count, percentage, and trend styles */
    .os-stats-cell .visitor-count {
        background-color: #10b981;
        color: #ffffff;
        font-weight: 600;
        font-size: 13px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 42px;
        height: 24px;
        padding: 0 10px;
        border-radius: 12px;
        margin-right: 8px;
        vertical-align: middle;
    }

    .os-stats-cell .visitor-percentage {
        color: #6b7280;
        font-size: 13px;
        font-weight: 600;
        margin-right: 8px;
        display: inline-block;
        min-width: 40px;
        text-align: left;
        vertical-align: middle;
    }

    .os-stats-cell .visitor-trend {
        display: inline-flex;
        align-items: center;
        gap: 2px;
        font-size: 13px;
        font-weight: 600;
        min-width: 55px;
        vertical-align: middle;
    }

    .os-stats-cell .visitor-trend.trend-up {
        color: #10b981;
    }

    .os-stats-cell .visitor-trend.trend-down {
        color: #ef4444;
    }

    .os-stats-cell .visitor-trend.trend-neutral {
        color: #6b7280;
    }

    /* Empty state for OS legend */
    .os-legend .empty-cell,
    .os-legend .loading-cell {
        padding: 40px 24px;
        text-align: center;
    }

    .os-legend .optibehavior-empty-state {
        min-height: 200px;
    }

    /* ========================================
       User Intent Widget Styles
       ======================================== */

    .user-intent-chart-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;
        width: 100%;
        height: 100%;
    }

    .user-intent-chart-container canvas {
        max-width: 180px;
        max-height: 180px;
    }

    /* User Intent Legend Table */
    .user-intent-legend {
        width: 100%;
        border-collapse: collapse;
        table-layout: auto;
    }

    .user-intent-legend tbody tr {
        border-bottom: 1px solid #f3f4f6;
    }

    .user-intent-legend tbody tr:last-child {
        border-bottom: none;
    }

    .user-intent-legend td {
        padding: 6px 0;
        vertical-align: middle;
    }

    /* Intent type cell (left column) */
    .intent-type-cell {
        width: auto;
        text-align: left;
        padding-right: 20px;
    }

    .intent-type-cell > span {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        vertical-align: middle;
    }

    .intent-color-dot {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        flex-shrink: 0;
        display: inline-block;
    }

    .intent-type-name {
        color: #1f2937;
        font-weight: 400;
        font-size: 13px;
        line-height: 1.4;
        display: inline-block;
        vertical-align: middle;
        white-space: nowrap;
    }

    /* Intent stats cell (right column) */
    .intent-stats-cell {
        text-align: right;
        white-space: nowrap;
        width: 100%;
    }

    /* Reuse the same visitor count, percentage, and trend styles */
    .intent-stats-cell .visitor-count {
        background-color: #10b981;
        color: #ffffff;
        font-weight: 600;
        font-size: 13px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 42px;
        height: 24px;
        padding: 0 10px;
        border-radius: 12px;
        margin-right: 8px;
        vertical-align: middle;
    }

    .intent-stats-cell .visitor-percentage {
        color: #6b7280;
        font-size: 13px;
        font-weight: 600;
        margin-right: 8px;
        display: inline-block;
        min-width: 40px;
        text-align: left;
        vertical-align: middle;
    }

    .intent-stats-cell .visitor-trend {
        display: inline-flex;
        align-items: center;
        gap: 2px;
        font-size: 13px;
        font-weight: 600;
        min-width: 55px;
        vertical-align: middle;
    }

    .intent-stats-cell .visitor-trend.trend-up {
        color: #10b981;
    }

    .intent-stats-cell .visitor-trend.trend-down {
        color: #ef4444;
    }

    .intent-stats-cell .visitor-trend.trend-neutral {
        color: #6b7280;
    }

    .intent-stats-cell .visitor-trend svg {
        width: 14px;
        height: 14px;
    }

    .user-intent-widget .widget-content.compact {
        min-height: 260px;
    }

    /* Device Types Widget Styling */
    .device-types-chart-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    .device-types-chart-container canvas {
        max-width: 140px;
        max-height: 140px;
    }

    .device-legend {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 12px;
        margin-top: 16px;
        padding-top: 12px;
        padding-right: 4px;
        border-top: 1px solid #e5e7eb;
        max-height: 200px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .legend-color.desktop-device {
        background-color: #3b82f6;
    }

    .legend-color.mobile-device {
        background-color: #10b981;
    }

    .legend-color.tablet-device {
        background-color: #f59e0b;
    }

    .device-widget .widget-content.compact {
        min-height: 260px;
    }

    /* Operating Systems Widget Styling */
    .opti-behavior-os-chart {
        display: flex;
        flex-direction: column;
        align-items: center;
        width: 100%;
    }

    .opti-behavior-os-chart canvas {
        max-width: 140px;
        max-height: 140px;
    }

    /* Screen Resolution Widget Styles */
    .resolution-table-container {
        width: 100%;
        overflow-x: auto;
        /* Add scrollbar - show max 4 items by default (4 rows × 36.8px per row ≈ 148px) */
        max-height: 148px; /* show 4 complete items before scroll */
        overflow-y: auto;   /* show scrollbar when there are many entries */
        margin-right: -24px; /* push scrollbar to widget border */
        padding-right: 24px; /* keep content aligned with other widgets */
    }

    .resolution-legend {
        width: 100%;
        border-collapse: collapse;
        table-layout: auto;
    }

    .resolution-legend tbody tr {
        border-bottom: 1px solid #f3f4f6;
    }

    .resolution-legend tbody tr:last-child {
        border-bottom: none;
    }

    .resolution-legend td {
        padding: 6px 0;
        vertical-align: middle;
    }

    /* Resolution type cell (left column) */
    .resolution-type-cell {
        width: auto;
        text-align: left;
    }

    .resolution-type-cell > span {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        vertical-align: middle;
        margin-right: 16px;
    }

    /* Resolution stats cell (right column) - matching Traffic Classification pattern */
    .resolution-stats-cell {
        text-align: right;
        white-space: nowrap;
        width: 100%;
    }

    /* Reuse the same visitor count, percentage, and trend styles */
    .resolution-stats-cell .visitor-count {
        background-color: #10b981;
        color: #ffffff;
        font-weight: 600;
        font-size: 13px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 42px;
        height: 24px;
        padding: 0 10px;
        border-radius: 12px;
        margin-right: 8px;
        vertical-align: middle;
    }

    .resolution-stats-cell .visitor-percentage {
        color: #6b7280;
        font-size: 13px;
        font-weight: 600;
        margin-right: 8px;
        display: inline-block;
        min-width: 40px;
        text-align: left;
        vertical-align: middle;
    }

    .resolution-stats-cell .visitor-trend {
        display: inline-flex;
        align-items: center;
        gap: 2px;
        font-size: 13px;
        font-weight: 600;
        min-width: 55px;
        vertical-align: middle;
    }

    .resolution-stats-cell .visitor-trend.trend-up {
        color: #10b981;
    }

    .resolution-stats-cell .visitor-trend.trend-down {
        color: #ef4444;
    }

    .resolution-stats-cell .visitor-trend.trend-neutral {
        color: #6b7280;
    }

    /* Custom scrollbar styles for legend containers */
    .device-legend::-webkit-scrollbar,
    .os-legend::-webkit-scrollbar,
    .resolution-legend::-webkit-scrollbar {
        width: 6px;
    }

    .device-legend::-webkit-scrollbar-track,
    .os-legend::-webkit-scrollbar-track,
    .resolution-legend::-webkit-scrollbar-track {
        background: #f1f1f1;
        border-radius: 3px;
    }

    .device-legend::-webkit-scrollbar-thumb,
    .os-legend::-webkit-scrollbar-thumb,
    .resolution-legend::-webkit-scrollbar-thumb {
        background: #c1c1c1;
        border-radius: 3px;
    }

    .device-legend::-webkit-scrollbar-thumb:hover,
    .os-legend::-webkit-scrollbar-thumb:hover,
    .resolution-legend::-webkit-scrollbar-thumb:hover {
        background: #a8a8a8;
    }

    .legend-color.windows-os {
        background-color: #0078d4;
    }

    .legend-color.macos-os {
        background-color: #000000;
    }

    .legend-color.ios-os {
        background-color: #007aff;
    }

    .legend-color.android-os {
        background-color: #3ddc84;
    }

    .legend-color.linux-os {
        background-color: #fcc624;
    }

    .legend-color.chromeos-os {
        background-color: #4285f4;
    }

    .legend-color.unknown-os {
        background-color: #6b7280;
    }

    .os-widget .widget-content.compact {
        min-height: 260px;
    }

/* Full-width widgets on desktop */
.chart-widget { grid-column: 1 / -1; }
.visitor-heatmap-widget { grid-column: 1 / -1; }

/* Top Pages single column inside the grid */
.pages-widget { grid-column: auto; }

/* ═══════════════════════════════════════════════════════════════════════════
   WIDGET DISPLAY ORDER - CONTROLLED IN PHP ONLY
   ═══════════════════════════════════════════════════════════════════════════

   ⚠️ IMPORTANT: Widget order is controlled ONLY in the PHP file:
      opti-behavior/includes/trait-opti-behavior-dashboard-views.php (lines 139-407)

   ⚠️ DO NOT use CSS 'order' property on dashboard widgets!
      Widgets appear in their natural HTML order as defined in PHP.

   VERIFIED ORDER (matching https://optiuser.com):

   LEVEL 1: Stats cards (6 cards)
   LEVEL 2: Real-time Visitors (2-col) + Real-time Visitor Map (1-col)
   LEVEL 3: Traffic Overview (3-col span / full-width)
   LEVEL 4: Top Engaged Users (2-col) + Top Pages (1-col)
   LEVEL 5: Visitor Activity Heatmap (3-col span / full-width)
   LEVEL 6: Traffic Classification (1-col) + Bot Traffic (1-col) + User Intent (1-col)
   LEVEL 7: Top Referrers (1-col) + Top Countries (1-col) + Browsers (1-col)
   LEVEL 8: Device Types (1-col) + Operating Systems (1-col) + Screen Resolution (1-col)

   ═══════════════════════════════════════════════════════════════════════════ */

/* Widget sizing - 2-column widgets */
.realtime-widget        { grid-column: span 2; }
.top-users-widget       { grid-column: span 2; }

    /* Responsive adjustments */
    @media (max-width: 640px) {
        .realtime-widget, .top-users-widget { grid-column: auto; }
        .visitor-heatmap-widget { grid-column: auto; }
        .chart-widget { grid-column: auto; }
    }

    /* Real-time details: URL and meta line */
    .realtime-widget .visitor-url { font-size:11px; color:#6c757d; display:block; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; margin-top:2px; }

        /* Top Engaged Users modern table styling */
        .top-users-widget .optibehavior-table-wrap { overflow-x:auto; overflow-y:auto; max-height:380px; }
        .top-users-widget table.widefat { width:100%; border-collapse:separate; border-spacing:0; table-layout:fixed; min-width:100%; }
        .top-users-widget thead th { position:sticky; top:0; background:#10b981 !important; border-bottom:2px solid #059669; color:#ffffff !important; font-weight:700; padding:12px 10px; z-index:2; white-space:nowrap; font-size:10px; text-transform:uppercase; letter-spacing:0.5px; vertical-align:middle; }
        .top-users-widget tbody td { padding:12px 10px; border-bottom:1px solid #e5e7eb; font-size:11px; color:#111827; white-space:nowrap; vertical-align:middle; }
        .top-users-widget tbody tr:hover { background:#f9fafb; }
        .top-users-widget th:nth-child(1), .top-users-widget td:nth-child(1) { text-align:center; width:30px; }
        .top-users-widget td:nth-child(1) { color:#64748b; font-weight:600; }
        .top-users-widget th:nth-child(2), .top-users-widget td:nth-child(2) { text-align:left; width:65px; max-width:65px; }
        .top-users-widget td:nth-child(2) { font-family:monospace; font-size:9px; color:#6b7280; overflow:hidden; text-overflow:ellipsis; }
        .top-users-widget th:nth-child(3), .top-users-widget td:nth-child(3) { text-align:center; width:55px; }
        .top-users-widget th:nth-child(4), .top-users-widget td:nth-child(4) { text-align:center; width:65px; }
        .top-users-widget th:nth-child(5), .top-users-widget td:nth-child(5) { text-align:center; width:65px; }
        .top-users-widget th:nth-child(6), .top-users-widget td:nth-child(6) { text-align:center; width:55px; }
        .top-users-widget th:nth-child(7), .top-users-widget td:nth-child(7) { text-align:center; width:65px; }
        .top-users-widget th:nth-child(8), .top-users-widget td:nth-child(8) { text-align:left; width:100px; max-width:100px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
        .top-users-widget td:nth-child(8) .tu-country-name { display:inline-block; max-width:70px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; vertical-align:middle; }
        .top-users-widget th:nth-child(9), .top-users-widget td:nth-child(9) { text-align:center; width:80px; min-width:80px; white-space:nowrap; }
        .top-users-widget .tu-sub-inline { color:#6b7280; font-size:11px; margin-left:8px; }
        .top-users-widget .tu-badge { display:inline-flex; align-items:center; justify-content:center; background:#e0f2fe; color:#075985; border:1px solid #bae6fd; padding:2px 8px; border-radius:9999px; font-weight:600; }
        .top-users-widget .tu-chip { display:inline-block; background:#ecfeff; color:#0e7490; border:1px solid #a5f3fc; padding:2px 8px; border-radius:9999px; }
        .top-users-widget .tu-flag { margin-right:6px; }
        .top-users-widget .tu-country-name { color:#334155; }

        /* Hide horizontal scrollbar but keep functionality */
        .top-users-widget .optibehavior-table-wrap::-webkit-scrollbar { height:0px; }
        .top-users-widget .optibehavior-table-wrap { scrollbar-width:none; -ms-overflow-style:none; }

    .realtime-widget .visitor-meta-line { display:flex; gap:10px; align-items:center; margin-top:2px; }
    .realtime-widget .visitor-ip { font-size:11px; color:#6b7280; }


        /* Real-time modern row layout */
        .realtime-widget .visitor-item.row { display:flex; align-items:center; justify-content:space-between; padding:8px 12px; border-bottom:1px solid #F3F4F6; }
        .realtime-widget .visitor-left { display:flex; align-items:center; gap:10px; flex-wrap:wrap; min-width:0; }
        .realtime-widget .visitor-datetime { color:#6b7280; font-size:12px; font-variant-numeric: tabular-nums; }
        .realtime-widget .visitor-title { font-weight:600; color:#111827; }
        .realtime-widget .visitor-sep { color:#9ca3af; }
        .realtime-widget .visitor-url { color:#2563eb; font-size:11px; text-decoration:none; display:inline-block; max-width:520px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
        .realtime-widget .visitor-url:hover { text-decoration:underline; }
        .realtime-widget .visitor-ip-pill { background:#2563eb; color:#fff; padding:4px 10px; border-radius:9999px; font-size:12px; box-shadow:0 1px 2px rgba(0,0,0,0.04); display:inline-flex; align-items:center; justify-content:center; width:16ch; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace; font-variant-numeric: tabular-nums; }
        .realtime-widget .visitor-ip-pill.visitor-ip-anon,
        .realtime-widget .visitor-ip-pill .visitor-ip-anon { background: linear-gradient(135deg, #10b981, #059669); color: #fff; font-family: system-ui, -apple-system, sans-serif; font-weight: 600; letter-spacing: 0.02em; width: auto; min-width: 12ch; }
        @media (max-width: 640px) { .realtime-widget .visitor-item.row { padding:8px; } }

/* Device Stats */

        /* Real-time grid layout for precise spacing */
        .realtime-widget .visitor-item.grid { display:grid; grid-template-columns: 160px 160px 1fr 1.6fr auto; column-gap:12px; align-items:center; padding:8px 12px; border-bottom:1px solid #F3F4F6; }
        .realtime-widget .visitor-flag-country { display:flex; align-items:center; gap:8px; }
        .realtime-widget .visitor-title { font-weight:600; color:#111827; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
        .realtime-widget .visitor-url a { color:#2563eb; text-decoration:none; display:inline-block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:12px; }
        .realtime-widget .visitor-url a:hover { text-decoration:underline; }
        .realtime-widget .visitor-datetime { color:#6b7280; font-size:12px; font-variant-numeric:tabular-nums; }
        .realtime-widget .visitor-datetime .ago { color:#059669; font-weight:600; }
        .realtime-widget .visitor-ip-col { text-align:right; }
        @media (max-width: 900px) { .realtime-widget .visitor-item.grid { grid-template-columns: 140px 140px 1fr auto; } }
        @media (max-width: 640px) { .realtime-widget .visitor-item.grid { grid-template-columns: 1fr; row-gap:4px; } .realtime-widget .visitor-ip-col { justify-self:start; } }

        /* Overrides to refine grid columns and page block */

        /* Real-time Map widget layout and sizing */
        .realtime-map { width: 100%; height: 360px; background:#f8fafc; }
        .realtime-map .map-fallback { display:flex; align-items:center; justify-content:center; height:100%; color:#6b7280; font-size:13px; }

        @media (max-width: 640px) { .realtime-map { height: 280px; } }

        .realtime-widget .visitor-item.grid { grid-template-columns: 160px 160px 1fr auto; }
        .realtime-widget .visitor-pageblock { display:flex; flex-direction:column; gap:2px; min-width:0; }
        .realtime-widget a.visitor-url { color:#2563eb; text-decoration:none; display:inline-block; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; font-size:12px; }
        .realtime-widget a.visitor-url:hover { text-decoration:underline; }

        /* Fine-tune spacing between Country and Title/URL */
        .realtime-widget .visitor-item.grid { grid-template-columns: 160px 140px 1fr auto; column-gap:8px; }
        /* Tighten the space between Country and URL */
        .realtime-widget .visitor-flag-country { gap:6px; }
        .realtime-widget .visitor-item.grid { grid-template-columns: 160px 110px 1fr auto; column-gap:6px; }
        @media (max-width: 900px) { .realtime-widget .visitor-item.grid { grid-template-columns: 140px 120px 1fr auto; column-gap:6px; } }



.device-stats {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.device-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.device-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.device-icon {
    font-size: 18px;
}

.device-name {
    font-weight: 500;
    color: #1a1a1a;
}

.device-stats-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.device-count {
    color: #6c757d;
}

.device-percentage {
    font-weight: 600;
    color: #6c5ce7;
}

.device-bar {
    height: 6px;
    background: #f1f3f4;
    border-radius: 3px;
    overflow: hidden;
}

.device-progress {
    height: 100%;
    background: #6c5ce7;
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Real-time Visitors */
.live-badge { display:inline-flex; align-items:center; gap:6px; background:#ECFDF5; color:#065F46; border:1px solid #A7F3D0; padding:3px 8px; border-radius:9999px; font-size:12px; font-weight:700; margin-right:8px; }
.live-dot { width:8px; height:8px; border-radius:50%; background:#10B981; box-shadow:0 0 0 0 rgba(16,185,129,0.7); animation: livePulse 1.5s ease-out infinite; }
@keyframes livePulse { 0%{ box-shadow:0 0 0 0 rgba(16,185,129,0.7);} 70%{ box-shadow:0 0 0 8px rgba(16,185,129,0);} 100%{ box-shadow:0 0 0 0 rgba(16,185,129,0);} }

.realtime-visitors {
    max-height: 300px;
    overflow-y: auto;
}

.visitor-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f3f4;
}

.visitor-item:last-child {
    border-bottom: none;
}

.visitor-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.visitor-flag {
    font-size: 16px;
}

.visitor-location {
    font-size: 14px;
    color: #1a1a1a;
    font-weight: 500;
}

.visitor-activity {
    text-align: right;
}

.visitor-page {
    font-size: 12px;
    color: #6c757d;
    display: block;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.visitor-time {
    font-size: 11px;
    color: #28a745;
    font-weight: 500;
}

.no-visitors {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

/* Top Pages: title row with inline actions */
.top-pages .page-title-row {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.top-pages .page-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Hide legacy buttons in the right column after moving actions next to title */
.pages-widget .page-stats .optibehavior-heatmap-btn {
    display: none !important;
}

/* Top Pages */
.top-pages {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.page-item {
    display: flex;
    flex-wrap: nowrap; /* prevent wrapping */
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #f1f3f4;
}

.page-item:last-child {
    border-bottom: none;
}

/* Top Pages: Use CSS Grid for perfect alignment */
.top-pages .page-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    align-items: start; /* Align to top to prevent URL from overlapping icons */
}

.top-pages .page-left {
    min-width: 0; /* Enable text truncation */
    display: flex;
    flex-direction: column;
}

.top-pages .page-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
    padding-top: 0px; /* Push metrics down to avoid overlapping with URL */
}

/* Level 2: metrics on a single horizontal row */
.top-pages .page-metrics {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    margin-top: 0; /* Remove margin for better alignment */
    margin-bottom: 0; /* Remove margin for better alignment */
}

.top-pages .metric {
    display: inline-flex;
    align-items: center;
    gap: 0px; /* No gap between icon and number */
    font-size: 11px;
    color: #0f172a;
    white-space: nowrap; /* Prevent wrapping */
}

.top-pages .metric-icon {
    width: 14px;
    height: 14px;
    flex-shrink: 0; /* Prevent icon from shrinking */
    margin-right: -6px; /* Pull value closer to icon */
}

.top-pages .metric-views .metric-icon {
    color: #f97316; /* flame */
}

.top-pages .metric-clicks .metric-icon {
    color: #0f766e; /* clicks */
}

.top-pages .metric-value {
    font-weight: 600;
    min-width: 30px; /* Ensure consistent width for alignment */
    text-align: right; /* Right-align numbers */
}

.top-pages .metric-change {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 999px;
}

.top-pages .metric-arrow {
    font-size: 10px;
}

.top-pages .metric-change.positive {
    color: #16a34a; /* green */
    background-color: #dcfce7; /* light green */
}

.top-pages .metric-change.negative {
    color: #dc2626; /* red */
    background-color: #fee2e2; /* light red */
}

.top-pages .metric-change.neutral {
    color: #64748b; /* gray */
    background-color: #e5e7eb; /* light gray */
}


.page-info {
    flex: 1;
    min-width: 0; /* allow flex child to shrink so ellipsis works */
    max-width: 100%; /* ensure it doesn't overflow */
}

.page-title {
    font-size: 13px;
    font-weight: 500;
    color: #1a1a1a;
    margin-bottom: 6px; /* Increased spacing to push URL down */
    max-width: 100%; /* use available space */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.page-url {
    font-size: 9px;
    color: #6c757d;
    max-width: 100%; /* use available space */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-decoration: none;
}

.page-url:hover {
    text-decoration: underline;
}

.page-stats {
    text-align: right;
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 0 0 auto; /* do not shrink buttons */
}
.optibehavior-heatmap-btn { white-space: nowrap; }
/* Modern pill buttons */
.optibehavior-heatmap-btn {
    border: 1px solid #e5e7eb;
    background: linear-gradient(180deg,#ffffff,#f9fafb);
    color: #111827;
    padding: 3px 6px; /* even smaller padding */
    border-radius: 9999px;
    font-size: 10px; /* smaller text */
    font-weight: 600;
    text-decoration: none;
    line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
    gap: 6px;
    min-height: 20px; /* shorter height */
    box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 1px 0 rgba(255,255,255,0.6) inset;
    transition: all .15s ease-in-out;
}
.optibehavior-heatmap-btn:hover { background: linear-gradient(180deg,#f8fafc,#f3f4f6); border-color:#d1d5db; transform: translateY(-1px); }
.optibehavior-heatmap-btn.alt { background: linear-gradient(180deg,#eef2ff,#e0e7ff); border-color:#c7d2fe; color:#3730a3; }
.optibehavior-heatmap-btn:focus { outline:2px solid #6366f1; outline-offset:2px; }
.optibehavior-heatmap-btn:active { transform: translateY(0); }

.page-views {
    font-size: 14px;
    font-weight: 600;
    color: #1a1a1a;
    display: block;
}

.page-percentage {
    font-size: 12px;
    color: #6c5ce7;
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
        padding: 20px;
    }

    .dashboard-stats {
        grid-template-columns: 1fr;
        padding: 20px;
    }

    .dashboard-content {
        padding: 0 20px 20px;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Realtime Map Tooltip Styles */
#realtime-map .leaflet-tooltip, .realtime-map .leaflet-tooltip{
    font-size: 11px !important;
    line-height: 1.2;
    padding: 2px 6px;
    background: rgba(255,255,255,0.95);
    border: 1px solid #cbd5e1;
}
#realtime-map .leaflet-tooltip .leaflet-tooltip-content{
    writing-mode: vertical-rl;
    text-orientation: mixed;
    white-space: normal;
}

/* Pulsing blue live marker */
.leaflet-div-icon.realtime-pulse-icon, .leaflet-marker-icon.realtime-pulse-icon {
    position: absolute !important;
    width: 28px;
    height: 28px;
    background: transparent;
    border: none;
}

/* Pulse animation (expanding circle) */
.leaflet-div-icon.realtime-pulse-icon::before, .leaflet-marker-icon.realtime-pulse-icon::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    margin-left: -20px;
    margin-top: -20px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.3);
    animation: rt-pulse 1.5s ease-out infinite;
}

/* Blue dot (center marker) */
.leaflet-div-icon.realtime-pulse-icon::after, .leaflet-marker-icon.realtime-pulse-icon::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin-left: -6px;
    margin-top: -6px;
    border-radius: 50%;
    background: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.6), 0 0 10px rgba(59, 130, 246, 0.8);
}

@keyframes rt-pulse {
    0% {
        transform: scale(0.3);
        opacity: 1;
    }
    50% {
        transform: scale(1.5);
        opacity: 0.5;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Visitor Heatmap Widget Styles */
.visitor-heatmap-container {
    width: 100%;
    min-height: 400px;
    overflow-x: auto;
    overflow-y: hidden;
    box-sizing: border-box;
}

.heatmap-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #6b7280;
    padding: 40px;
}

/* Wrapper for heatmap and legend side-by-side */
.heatmap-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    min-width: fit-content;
    box-sizing: border-box;
}

/* Heatmap grid container */
.heatmap-grid {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
    box-sizing: border-box;
}

.heatmap-header {
    display: grid;
    grid-template-columns: 100px repeat(24, minmax(32px, 1fr));
    gap: 1px;
    margin-bottom: 1px;
    box-sizing: border-box;
}

.heatmap-corner {
    background: transparent;
    min-width: 100px;
    max-width: 100px;
    box-sizing: border-box;
}

.heatmap-hour-label {
    background: #f8fafc;
    color: #334155;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    border-radius: 4px 4px 0 0;
    min-width: 32px;
    box-sizing: border-box;
}

.heatmap-row {
    display: grid;
    grid-template-columns: 100px repeat(24, minmax(32px, 1fr));
    gap: 1px;
    margin-bottom: 1px;
    box-sizing: border-box;
}

.heatmap-day-label {
    background: #f8fafc;
    color: #334155;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    padding: 0 12px;
    border-radius: 4px 0 0 4px;
    min-width: 100px;
    max-width: 100px;
    box-sizing: border-box;
}

.heatmap-cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    border-radius: 4px;
    transition: all 0.2s ease;
    cursor: pointer;
    min-height: 40px;
    min-width: 32px;
    box-sizing: border-box;
    position: relative;
}

.heatmap-cell:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 10;
}

.heatmap-value {
    pointer-events: none;
}

/* Vertical legend beside heatmap */
.heatmap-legend {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    padding: 0;
    background: transparent;
    border-radius: 8px;
    flex-shrink: 0;
    width: 70px;
    min-width: 70px;
    max-width: 70px;
    height: 100%;
    box-sizing: border-box;
}

.legend-label {
    font-size: 11px;
    color: #64748b;
    font-weight: 500;
    text-align: center;
    line-height: 1.2;
}

.legend-label-top {
    order: 1;
    margin-top: 48px;
}

.legend-gradient {
    order: 2;
    width: 24px;
    flex: 1;
    background: linear-gradient(to bottom, #DC143C, #FF9800, #FFEB3B, #4CAF50, #00CED1, #2196F3, #F0F8FF);
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    min-height: 200px;
}

.legend-label-bottom {
    order: 3;
    margin-bottom: 8px;
}

/* Logged-in User Row Highlighting */
.tu-logged-in-user {
    background-color: rgba(16, 185, 129, 0.08) !important;
    border-left: 3px solid #10b981 !important;
}

.tu-logged-in-user:hover {
    background-color: rgba(16, 185, 129, 0.15) !important;
}

/* Make the row stand out more on hover */
.tu-logged-in-user td {
    position: relative;
}
