﻿* { margin: 0; padding: 0; box-sizing: border-box; }

/* Custom Scrollbar for a sleeker look */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

body {
    display: block;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8fafc;
    min-height: 100vh;
    margin-top: 0px; 
    margin-left: 200px;
    padding-top: 70px;
    color: #1e293b;

    --role-color: #2471a3;
}

a {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-weight: 500;
    font-size: 1rem;
}

/* --- Shared Header --- */
.top-nav {
    height: 70px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between; /* Brand on left, User on right */
    align-items: center;
    padding: 0 30px;
    z-index: 100; /* Keeps it above everything else */
    position: fixed;
    top: 0; 
    right: 0;
    width: 100%;
    transition: background 0.3s ease;
}

#nav-overview,
#nav-admin,
#nav-errors,
#nav-performance,
#nav-sessions,
#nav-reports {
    padding: 14px 20px;
    width: 100%;

    /* 1. Typography */
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-weight: 500;
    color: #94a3b8; 
    text-decoration: none;
    
    /* 2. Smooth Transition */
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    cursor: pointer;
    border-left: 3px solid transparent;
}

#nav-overview:hover,
#nav-admin:hover,
#nav-errors:hover,
#nav-performance:hover,
#nav-sessions:hover,
#nav-reports:hover {
    background-color: rgba(56, 189, 248, 0.1); 
    
    color: #e2e8f0;
    padding-left: 24px;
}

.nav-link-active {
    background-color: rgba(56, 189, 248, 0.15) !important; 
    color: #38bdf8 !important; 
    font-weight: 600;
    border-left: 3px solid #38bdf8 !important;
}

.user-profile, .brand {
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
}

#user-display-name {
    /* 1. Typography */
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;

    /* 2. Layout & Spacing */
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;

    /* 3. Modern "Pill" Styling */
    background-color: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    
    /* 4. Subtle Interactive Shadow */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    cursor: default;
}

/* 5. Hover Effect (Optional) */
#user-display-name:hover {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* 6. Optional: Add a small status dot next to the name */
#user-display-name::before {
    content: "";
    width: 8px;
    height: 8px;
    background-color: var(--role-color);
    border-radius: 50%;
    margin-right: 10px;
}

#logout-btn {
    /* 1. Typography */
    font-size: 0.95rem;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;

    /* 2. Layout */
    display: inline-flex;
    align-items: center;
    padding: 8px 16px;
    cursor: pointer;

    /* 3. Styling */
    background-color: white;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    
    /* 4. Smooth Interaction */
    transition: all 0.2s ease-in-out;
}

/* 5. Hover State: Soft Danger */
#logout-btn:hover {
    color: #ef4444;           
    background-color: #fef2f2; 
    border-color: #fecaca;     
    box-shadow: 0 2px 4px rgba(239, 68, 68, 0.1);
}

/* 6. Active State: Click feel */
#logout-btn:active {
    transform: translateY(1px);
    background-color: #fed7d7;
}

.user-profile a {
    cursor: pointer;
}

.header {
    background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%); 
    color: #f8fafc; 
    padding: 0px;
    display: flex; align-items: center; justify-content: space-between;
    box-shadow: 4px 0 10px rgba(0,0,0,0.05); position: fixed;
    top: 0; left: 0; z-index: 1000; min-height: 100vh; width: 200px; max-width: 200px;
    flex-direction: column; overflow-x: auto; justify-content: start; margin-top: 70px; box-sizing: border-box;
    transition: all 0.3s ease;
}
.header h1 { font-size: 1.4em; font-weight: 700; margin: 0; padding: 20px; text-align: center; color: #38bdf8; letter-spacing: 0.5px;}
#header-group { display: flex; width: 100%; height: 100%; flex-direction: column; padding: 10px 0;}
.header a { display: block; color: #cbd5e1; text-decoration: none; font-size: 0.95rem; cursor: pointer; box-sizing: border-box; padding: 14px 20px; transition: all 0.2s ease; border-left: 3px solid transparent;}
.header a:hover { color: #ffffff; background: rgba(56, 189, 248, 0.1); border-left: 3px solid #38bdf8; padding-left: 24px; }

/* --- Dashboard Specific --- */
#welcome-text { padding: 10px 0 0 20px; width: fit-content; }
#analytics-table-wrapper {
    overflow-x: auto; 
    margin: 20px; 
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1); 
    border-radius: 8px; 
}
table { width: 100%; border-collapse: collapse; background-color: white; font-size: 14px;}
th { background-color: #007bff; color: white; text-align: left; padding: 15px; position: sticky; top: 0; }
td { padding: 12px 15px; border-bottom: 1px solid #ddd; vertical-align: top; color: #333; }
tr:nth-child(even) { background-color: #f8f9fa; }
tr:hover { background-color: #f1f4f9; }
.json-cell {
    display: block; max-width: 400px; max-height: 120px; overflow: auto;
    background-color: #272822; color: #f8f8f2; padding: 10px; border-radius: 4px;
    font-family: 'Courier New', monospace; font-size: 12px; white-space: pre-wrap; word-break: break-all;
}

/* --- Admin Specific --- */
.container {padding: 0px 0px 10px 0px; margin-top: 0px; width: 100%;}
.card { background: white; border-radius: 12px; box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03); padding: 30px; width: 80%; margin: 0 auto 30px; border: 1px solid #f1f5f9; transition: transform 0.2sease, box-shadow 0.2sease;}
.card:hover { box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.02); }
.card h2 { font-size: 1.25rem; color: #1e293b; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 2px solid #e2e8f0; font-weight: 600;}
.table-wrap th { background: #f8fafc; font-weight: 600; color: #475569; font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.5px;}
.role-badge { display: inline-block; padding: 4px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px;}
.role-analyst { background: #ffedd5; color: #9a3412; }
.role-super-admin { background: #dcfce7; color: #166534; }
.role-viewer { background: #e0f2fe; color: #075985; }
.btn { padding: 6px 14px; border: none; border-radius: 6px; font-size: 0.85em; cursor: pointer; font-weight: 500; transition: all 0.2s ease;}
.btn:hover { transform: translateY(-1px); box-shadow: 0 2px 4px rgba(0,0,0,0.05); }
.btn-edit { background: #e0f2fe; color: #0284c7; }
.btn-edit:hover { background: #bae6fd; }
.btn-delete { background: #fee2e2; color: #dc2626; margin-left: 8px; }
.btn-delete:hover { background: #fecaca; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-end; }
.form-group { flex: 1; min-width: 160px; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; color: #475569; margin-bottom: 8px; }
.form-group input, .form-group select { width: 100%; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 6px; transition: all 0.2s ease; font-family: inherit; font-size: 0.95rem; color: #334155; }
.form-group input:focus, .form-group select:focus { outline: none; border-color: #38bdf8; box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.1); }
.btn-submit { padding: 10px 24px; background: #0ea5e9; color: white; border: none; border-radius: 6px; font-weight: 600; cursor: pointer; margin-top: 4px; transition: all 0.2s ease;}
.btn-submit:hover { background: #0284c7; transform: translateY(-1px); box-shadow: 0 4px 6px rgba(14, 165, 233, 0.2); }
.message { padding: 12px 16px; border-radius: 6px; font-size: 0.95em; margin-bottom: 20px; width: 80%; font-weight: 500;}
.message-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; width: 80%;}
.message-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; width: 80%;}
.empty-state { text-align: center; padding: 40px; color: #94a3b8; font-style: italic;}
#message-area {width: 100%; display: flex; justify-content: center;}

.multiselect-container {
    position: relative;
    width: 100%;
}

.select-box {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    color: #334155;
    transition: all 0.2s ease;
}
.select-box:hover { border-color: #94a3b8; }

.checkbox-dropdown {
    display: none; /* Hidden by default */
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    margin-top: 4px;
    z-index: 10;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

/* We merged the Flexbox centering directly into your existing label rule */
.checkbox-dropdown label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px; /* Perfect spacing between box and text */
    padding: 8px 12px;
    margin: 0;
    cursor: pointer;
    font-weight: normal;
}

.checkbox-dropdown label:hover {
    background: #f0f7ff;
}

/* Target the checkbox directly to remove default browser weirdness */
.checkbox-dropdown input[type="checkbox"] {
    margin: 0;
    cursor: pointer;

    width: fit-content;
}

/* --- Dashboard Dashboard Layouts --- */
.dashboard-header { padding: 0; margin-bottom: 30px; color: #1e293b; text-align: left; font-size: 2.2rem; font-weight: 700; padding-top: 20px; width: 80%; margin-left: auto; margin-right: auto;}
.summary-cards {
    width: 80%;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin: 0 auto;
    margin-bottom: 30px;
}
.summary-card {
    background: white; padding: 24px; border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03); 
    text-align: left;
    border: 1px solid #f1f5f9;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.summary-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.05), 0 4px 6px -2px rgba(0,0,0,0.02);
}
.summary-card h3 { font-size: 0.85em; color: #64748b; text-transform: uppercase; margin-bottom: 12px; font-weight: 600; letter-spacing: 0.5px;}
.summary-card .value { font-size: 2.2em; font-weight: 700; color: #0f172a; }

.top-pages-card {
    width: 80%;
    margin: 0 auto;
    margin-top: 0px;
    overflow-x: auto;
    margin-bottom: 2rem;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    border: 1px solid #f1f5f9;
}

.top-pages-card h2 { padding: 20px; font-size: 1.25rem; font-weight: 600; color: #1e293b; border-bottom: 1px solid #f1f5f9; margin: 0; }

.top-pages-card table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    min-width: 0;
}

.top-pages-card th, .top-pages-card td {
    padding: 14px 20px;
}

.top-pages-card th {
    background-color: #f8fafc;
    color: #475569;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    border-bottom: 1px solid #e2e8f0;
}

.top-pages-card td {
    word-wrap: break-word; 
    overflow-wrap: break-word; 
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
    font-size: 0.95rem;
}

.top-pages-card tr:last-child td {
    border-bottom: none;
}

.top-pages-card tr:hover { background-color: #f8fafc; }

.chart-container {
    background: white; padding: 24px; border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03); 
    margin-bottom: 30px;
    border: 1px solid #f1f5f9;
    width: 80%;
    margin: 0 auto 30px auto;
}

/* --- Errors Detail Panel --- */
#stack-trace-panel {
    display: none; background: #272822; color: #f8f8f2;
    padding: 15px; border-radius: 8px; margin-top: 20px;
    font-family: monospace; white-space: pre-wrap; overflow-x: auto;
}
.clickable-row { cursor: pointer; }
.clickable-row:hover { background-color: #e3f2fd !important; }

/* page permissions */
.access-denied-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    height: 60vh; /* Centers it vertically in the content area */
    padding: 20px;
    background-color: #f8fafc;
    border: 2px dashed #e2e8f0;
    border-radius: 12px;
    margin: 20px;
}

.lock-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

.access-denied-container h2 {
    color: #2d3748;
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.access-denied-container p {
    color: #718096;
    margin-bottom: 1.5rem;
}

.permission-tag {
    background: #edf2f7;
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 0.9rem;
    color: #4a5568;
    border: 1px solid #cbd5e0;
    margin-bottom: 2rem;
}

.back-btn {
    background-color: #3182ce;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
}

.back-btn:hover {
    background-color: #2b6cb0;
}

/* sessions */
/* Layout */
/* =========================================
   1. MAIN LAYOUT & CONTAINERS
   ========================================= */
.header-actions {
    width: 80%;
    margin: 0 auto;
}

.header-actions .dashboard-header {
    width: 100%;
    margin-bottom: 10px;
}

.header-actions .text-muted {
    display: block;
    margin-bottom: 20px;
}

.session-tracer-layout {
    display: flex;
    gap: 24px;
    height: calc(100vh - 180px); /* Adjust based on top nav + margins */
    width: 80%;
    margin: 0px auto 40px auto;
}

/* Left Sidebar: Session List */
.session-list {
    width: 350px;
    background: white;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    overflow-y: auto;
    padding: 20px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

/* Right Main: Timeline View */
.session-timeline {
    flex: 1;
    background: white;
    border-radius: 12px;
    border: 1px solid #f1f5f9;
    padding: 30px;
    overflow-y: auto;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

/* General UI States */
.loading-text, .error-text, .text-muted {
    color: #64748b;
    font-size: 0.95rem;
}
.error-text { color: #ef4444; }


/* =========================================
   2. SIDEBAR SESSION CARDS
   ========================================= */
.session-card {
    padding: 14px 16px;
    border: 1px solid #f1f5f9;
    border-radius: 10px;
    margin-bottom: 12px;
    cursor: pointer;
    background: white;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    transition: all 0.2s ease-in-out;
}

.session-card:hover { 
    border-color: #cbd5e1; 
    background: #f8fafc; 
    transform: translateX(4px);
}

.session-card.active { 
    border-color: #38bdf8; 
    background: #f0f9ff; 
    box-shadow: 0 0 0 1px #38bdf8; 
}

.session-card-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 8px;
    color: #1e293b;
}

.session-card-date { 
    font-size: 0.85rem; 
    color: #64748b; 
}

.badge { 
    background: #f1f5f9; 
    padding: 4px 10px; 
    border-radius: 20px; 
    font-size: 0.75rem; 
    color: #475569; 
    font-weight: 600;
}


/* =========================================
   3. USER PROFILE HEADER CARD
   ========================================= */
.session-profile-card {
    background: white;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 30px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #edf2f7;
}

.profile-avatar {
    font-size: 2.5rem;
    background: #ebf8ff;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 2px solid #bee3f8;
}

.profile-title h3 { 
    margin: 0 0 5px 0; 
    color: #2d3748; 
    font-size: 1.2rem;
}

.profile-title p { 
    margin: 0; 
    font-size: 0.85rem; 
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 15px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    background: white;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

.stat-box .label { 
    font-size: 0.7rem; 
    color: #a0aec0; 
    text-transform: uppercase; 
    letter-spacing: 0.5px; 
    margin-bottom: 4px;
}

.stat-box .val { 
    font-size: 1.05rem; 
    font-weight: bold; 
    color: #2d3748; 
}


/* =========================================
   4. TIMELINE STRUCTURE & TRACK
   ========================================= */
.timeline-container-header {
    margin-top: 30px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
    margin-bottom: 20px;
}

.timeline-container-header h4 {
    margin: 0;
    color: #4a5568;
    font-size: 1.1rem;
}

.timeline-track { 
    margin-top: 20px; 
    padding-left: 14px; 
    border-left: 2px solid #e2e8f0; 
}

.timeline-item {
    position: relative;
    padding-left: 25px;
    padding-bottom: 25px;
}

/* The dot on the timeline line */
.timeline-marker {
    position: absolute;
    left: -32px; /* Pulls it exactly over the 2px border-left */
    top: 0;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #cbd5e0; /* Default color */
    border: 3px solid white;
    box-shadow: 0 0 0 1px #e2e8f0; /* Outer ring */
}

.timeline-content { 
    background: white; 
    padding: 16px; 
    border-radius: 10px; 
    border: 1px solid #f1f5f9; 
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03); 
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.timeline-item:hover .timeline-content {
    transform: translateX(4px);
    box-shadow: 0 6px 10px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
}

.timeline-header { 
    display: flex; 
    justify-content: space-between; 
    margin-bottom: 8px; 
}

.event-type { 
    font-weight: bold; 
    font-size: 0.75rem; 
    letter-spacing: 0.5px;
}

.event-time { 
    font-size: 0.8rem; 
    color: #a0aec0; 
}

.event-url { 
    font-size: 0.85rem; 
    color: #4a5568; 
    word-break: break-all; 
    margin-bottom: 8px;
}


/* =========================================
   5. SPECIFIC EVENT UI BOXES
   ========================================= */
.event-details {
    margin-top: 10px;
    border-top: 1px dashed #e2e8f0;
    padding-top: 10px;
    font-size: 0.9rem;
}

/* Micro-events (Dots for mousemove/heartbeat) */
.timeline-micro-event {
    width: 8px;
    height: 8px;
    background: #cbd5e0;
    border-radius: 50%;
    margin: 8px 0 8px -4px; /* Aligns with the vertical line */
    cursor: crosshair;
    transition: transform 0.2s;
}

.timeline-micro-event:hover {
    transform: scale(1.5);
    background: #a0aec0;
}

/* Click Events */
.click-box {
    background: #f0fff4;
    border: 1px solid #c6f6d5;
    padding: 10px 12px;
    border-radius: 6px;
    color: #276749;
}
.click-box code {
    background: rgba(255,255,255,0.7);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #2f855a;
}

/* Error Events */
.error-box {
    background: #fff5f5;
    border: 1px solid #fed7d7;
    padding: 12px;
    border-radius: 6px;
}
.error-message {
    color: #c53030;
    font-weight: bold;
    margin-bottom: 6px;
}
.error-stack {
    background: #2d3748;
    color: #fc8181;
    padding: 10px;
    border-radius: 4px;
    font-size: 0.75rem;
    margin-top: 8px;
    overflow-x: auto;
    max-height: 200px;
}

/* Idle Events */
.idle-box { 
    background: #fdf6e3; 
    color: #744210; 
    padding: 8px 12px; 
    border-radius: 6px; 
    border: 1px solid #feebc8;
}

/* Small UI Tags */
.tag { 
    padding: 3px 8px; 
    border-radius: 4px; 
    font-size: 0.75rem; 
    color: white; 
    font-weight: bold;
    display: inline-block;
    margin-right: 8px;
}
.bg-blue { background: #4299e1; }
.bg-purple { background: #805ad5; }


/* =========================================
   6. EVENT COLOR CODING (MARKERS)
   ========================================= */
/* Utility Text Colors */
.text-success { color: #38a169 !important; }
.text-danger { color: #e53e3e !important; }

/* Timeline Dot Colors based on Event Type */
.timeline-marker.type-pageview { background: #3182ce; }
.timeline-marker.type-page-exit,
.timeline-marker.type-pagehide { background: #805ad5; }
.timeline-marker.type-click { background: #38a169; }
.timeline-marker.type-custom { background: #805ad5; }

/* Errors & Warnings */
.timeline-marker.type-error,
.timeline-marker.type-noscript { 
    background: #e53e3e; 
    box-shadow: 0 0 0 3px #fed7d7; /* Red glowing ring */
}

/* Scroll Events */
.timeline-marker.type-scroll-depth, 
.timeline-marker.type-scroll-final { background: #a0aec0; }

/* Keyboard Events */
.timeline-marker.type-keydown, 
.timeline-marker.type-keyup { background: #4a5568; }

/* Idle Events */
.timeline-marker.type-idle-break-start, 
.timeline-marker.type-idle-break-end { 
    background: #d6bcfa; 
}

/* Special Micro-Events */
.timeline-micro-event.heartbeat { 
    background: #f6ad55; 
    opacity: 0.6; 
}

.bg-green { background: #38a169; color: white; }
.bg-red { background: #e53e3e; color: white; }

/* reports */
/* Modal Overlay Background */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    backdrop-filter: blur(2px);
    transition: opacity 0.2s;
}

/* Base Button Styling */
.modal-btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

/* Primary Action (Generate/Save) */
.btn-save {
    background-color: #3182ce;
    color: white;
}

.btn-save:hover {
    background-color: #2b6cb0;
    box-shadow: 0 4px 6px rgba(49, 130, 206, 0.2);
}

/* Secondary Action (Cancel/Close) */
.btn-cancel {
    background-color: #edf2f7;
    color: #4a5568;
}

.btn-cancel:hover {
    background-color: #e2e8f0;
}

/* Active/Click State */
.modal-btn:active {
    transform: scale(0.98);
}

/* Disabled State (For when the PDF is generating) */
.modal-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    filter: grayscale(0.5);
}

.modal-overlay.hidden {
    display: none;
    opacity: 0;
}

/* Modal Box */
.modal-content {
    background: white;
    padding: 30px;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

.modal-content h2 { margin-bottom: 8px; color: #1e293b; font-size: 1.4rem; }
.modal-content p { color: #64748b; font-size: 0.95rem; margin-bottom: 20px; }

.modal-content textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 14px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    margin: 15px 0 24px;
    font-family: inherit;
    resize: vertical;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.modal-content textarea:focus {
    outline: none;
    border-color: #38bdf8;
    box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.15);
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-primary { background: #0ea5e9; color: white; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: 600; transition: all 0.2s ease; }
.btn-primary:hover { background: #0284c7; transform: translateY(-1px); box-shadow: 0 4px 6px rgba(14, 165, 233, 0.2); }
.btn-secondary { background: #f1f5f9; color: #475569; border: none; padding: 10px 20px; border-radius: 8px; cursor: pointer; font-weight: 500; transition: all 0.2s ease; }
.btn-secondary:hover { background: #e2e8f0; color: #1e293b; }

#reports-container {
    width: 80%;
    margin: 0 auto 40px auto;
}

/* Reports Grid Layout */
.reports-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 24px;
    margin-top: 20px;
}

/* Individual Report Card */
.report-card {
    background: white;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -1px rgba(0,0,0,0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.report-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.03);
    border-color: #e2e8f0;
}

.report-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 15px;
}

.report-icon {
    font-size: 2rem;
    background: #ebf8ff;
    padding: 10px;
    border-radius: 8px;
}

.report-title {
    margin: 0 0 5px 0;
    font-size: 1.1rem;
    color: #2d3748;
}

.report-meta {
    font-size: 0.8rem;
    color: #718096;
    margin-bottom: 15px;
}

.report-comments {
    font-size: 0.9rem;
    color: #4a5568;
    background: #f7fafc;
    padding: 10px;
    border-radius: 6px;
    border-left: 3px solid #cbd5e0;
    margin-bottom: 20px;
    flex-grow: 1; /* Pushes the button to the bottom */
    display: -webkit-box;
    -webkit-line-clamp: 3; /* Truncates long comments to 3 lines */
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.btn-download {
    display: block;
    text-align: center;
    background: #edf2f7;
    color: #2b6cb0;
    text-decoration: none;
    padding: 10px;
    border-radius: 6px;
    font-weight: bold;
}

.btn-download:hover {
    background: #e2e8f0;
    color: #2c5282;
}

.report-btn-wrapper {
    width: 80%;
    margin: 0 auto; 
    padding-bottom: 20px;
}

/* Make headers look clickable */
th.sortable {
    cursor: pointer;
    user-select: none; /* Prevents text highlighting when clicking rapidly */
    transition: background-color 0.2s ease;
    position: relative;
    padding-right: 20px; /* Make room for the arrow */
}

th.sortable:hover {
    background-color: #e2e8f0; 
}

/* Default state: subtle up/down arrows indicating it CAN be sorted */
th.sortable .sort-icon::after {
    content: '↕'; 
    position: absolute;
    right: 8px;
    opacity: 0.3;
    font-size: 0.9em;
}

/* Active states: Bold, colored arrows based on direction */
th.sortable.sort-asc .sort-icon::after {
    content: '↑';
    opacity: 1;
    color: #2b6cb0;
    font-weight: bold;
}

th.sortable.sort-desc .sort-icon::after {
    content: '↓';
    opacity: 1;
    color: #2b6cb0;
    font-weight: bold;
}

/* page view transitions */

/* The Core Keyframe Animation */
@keyframes fadeSlideUp {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Apply the animation to all major layout blocks */
.dashboard-header,
.header-actions,
.report-btn-wrapper,
.summary-cards,
.chart-container,
.card,
.session-list,
.session-timeline,
#reports-container,
.access-denied-container,
.container /* Admin Panel */ {
    animation: fadeSlideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    opacity: 0; /* Ensures elements are invisible before the animation starts */
}

/* --- STAGGER DELAYS FOR PAGE LOAD --- */
/* Creates a top-to-bottom cascading entrance */
.dashboard-header, .header-actions {
    animation-delay: 0s;
}

.report-btn-wrapper {
    animation-delay: 0.05s;
}

.summary-cards, .session-list {
    animation-delay: 0.1s;
}

.chart-container, .session-timeline, #reports-container {
    animation-delay: 0.15s;
}

.card {
    animation-delay: 0.2s;
}

/* --- STAGGER DELAYS FOR INDIVIDUAL ITEMS --- */
/* Animate the individual metric cards once the fetch() completes */
.summary-card {
    animation: fadeSlideUp 0.4s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    opacity: 0;
}
.summary-card:nth-child(1) { animation-delay: 0.05s; }
.summary-card:nth-child(2) { animation-delay: 0.1s; }
.summary-card:nth-child(3) { animation-delay: 0.15s; }
.summary-card:nth-child(4) { animation-delay: 0.2s; }

/* Animate Session & Report cards when lists are rendered */
.report-card, .session-card {
    animation: fadeSlideUp 0.3s cubic-bezier(0.2, 0.8, 0.2, 1) forwards;
    opacity: 0;
}
.report-card:nth-child(1), .session-card:nth-child(1) { animation-delay: 0.05s; }
.report-card:nth-child(2), .session-card:nth-child(2) { animation-delay: 0.1s; }
.report-card:nth-child(3), .session-card:nth-child(3) { animation-delay: 0.15s; }
.report-card:nth-child(4), .session-card:nth-child(4) { animation-delay: 0.2s; }
.report-card:nth-child(5), .session-card:nth-child(5) { animation-delay: 0.25s; }
/* =========================================
   DARK THEME TOGGLE & OVERRIDES
   ========================================= */
.theme-toggle {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: background 0.2s ease, transform 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    line-height: 1;
    user-select: none;
    margin-right: 10px;
}
.theme-toggle:hover {
    background: #f1f5f9;
    transform: scale(1.1);
}

/* Base Dark Variables implicitly overriden by class */
html.dark-theme, html.dark-theme body {
    background: #0f172a;
    color: #f8fafc;
}

html.dark-theme .top-nav {
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid rgba(51, 65, 85, 0.8);
}

html.dark-theme .theme-toggle:hover {
    background: #1e293b;
}

html.dark-theme .dashboard-header, 
html.dark-theme .card h2, 
html.dark-theme .top-pages-card h2,
html.dark-theme .timeline-container-header h4,
html.dark-theme .report-title,
html.dark-theme .header-actions .dashboard-header {
    color: #f8fafc;
    border-color: #334155;
}

/* Common Containers */
html.dark-theme .card, 
html.dark-theme .summary-card, 
html.dark-theme .chart-container, 
html.dark-theme .top-pages-card,
html.dark-theme .session-list,
html.dark-theme .session-timeline,
html.dark-theme .session-profile-card,
html.dark-theme .timeline-content,
html.dark-theme .report-card,
html.dark-theme .modal-content,
html.dark-theme .stat-box {
    background: #1e293b;
    border-color: #334155;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.3);
}

/* User & Buttons */
html.dark-theme #user-display-name {
    background-color: #0f172a;
    border-color: #334155;
    color: #cbd5e1;
}
html.dark-theme #logout-btn {
    background-color: #0f172a;
    border-color: #334155;
    color: #94a3b8;
}
html.dark-theme #logout-btn:hover { background-color: #450a0a; color: #fca5a5; border-color: #7f1d1d; }

/* Text Muted / Subtitles */
html.dark-theme .summary-card h3,
html.dark-theme .text-muted, html.dark-theme .loading-text,
html.dark-theme .report-meta,
html.dark-theme .session-card-date,
html.dark-theme .event-time,
html.dark-theme .modal-content p {
    color: #94a3b8;
}

/* Emphasized Values */
html.dark-theme .summary-card .value,
html.dark-theme .stat-box .val,
html.dark-theme .profile-title h3 {
    color: #f8fafc;
}

/* Tables */
html.dark-theme th, html.dark-theme .table-wrap th {
    background-color: #0f172a;
    color: #94a3b8;
    border-color: #334155;
}
html.dark-theme .top-pages-card td,
html.dark-theme td {
    color: #cbd5e1;
    border-color: #334155;
}
html.dark-theme .top-pages-card tr:nth-child(even),
html.dark-theme tr:nth-child(even) { background-color: #0f172a !important; }

html.dark-theme .top-pages-card tr:hover,
html.dark-theme tr:hover { background-color: #334155 !important; }

/* Session Tracking Specific */
html.dark-theme .session-card {
    background: #0f172a;
    border-color: #334155;
}
html.dark-theme .session-card-header { color: #f8fafc; }
html.dark-theme .session-card:hover { background: #334155; }
html.dark-theme .session-card.active { background: #1e3a8a; border-color: #0ea5e9; }
html.dark-theme .badge { background: #334155; color: #cbd5e1; }
html.dark-theme .profile-avatar { background: #0f172a; border-color: #0ea5e9; }
html.dark-theme .timeline-track { border-color: #334155; }
html.dark-theme .timeline-marker { background: #475569; border-color: #1e293b; box-shadow: 0 0 0 1px #334155; }
html.dark-theme .timeline-item:hover .timeline-content {
    background-color: #0f172a;
    border-color: #475569;
}
html.dark-theme .event-details { border-top-color: #334155; }
html.dark-theme .event-url { color: #cbd5e1; }
html.dark-theme .timeline-container-header { border-bottom-color: #334155; }
html.dark-theme .timeline-micro-event { background: #475569; }

/* Form inputs & Selects */
html.dark-theme .form-group input, 
html.dark-theme .form-group select,
html.dark-theme .modal-content textarea,
html.dark-theme .select-box,
html.dark-theme .checkbox-dropdown,
html.dark-theme .checkbox-dropdown label {
    background-color: #0f172a;
    border-color: #334155;
    color: #cbd5e1;
}
html.dark-theme .select-box:hover,
html.dark-theme .form-group input:focus,
html.dark-theme .modal-content textarea:focus {
    border-color: #38bdf8;
}
html.dark-theme .checkbox-dropdown label:hover,
html.dark-theme .empty-state {
    background: #1e293b;
    color: #cbd5e1;
}
html.dark-theme .form-group label { color: #cbd5e1; }

/* Reports */
html.dark-theme .report-comments { background: #0f172a; border-color: #334155; color: #cbd5e1; }
html.dark-theme .report-icon { background: #0f172a; border-color: #334155; }
html.dark-theme .btn-download { background: #0f172a; border-color: #334155; color: #38bdf8;}
html.dark-theme .btn-download:hover { background: #334155; }
html.dark-theme .btn-secondary { background: #334155; color: #cbd5e1; }
html.dark-theme .btn-secondary:hover { background: #475569; color: #f8fafc; }

/* Access Denied */
html.dark-theme .access-denied-container { background: #1e293b; border-color: #334155; }
html.dark-theme .permission-tag { background: #0f172a; border-color: #334155; color: #cbd5e1; }
html.dark-theme .access-denied-container h2 { color: #f8fafc; }


/* Additional Component Overrides for Better Dark UI */
html.dark-theme .click-box {
    background: #022c22;
    border: 1px solid #064e3b;
    color: #34d399;
}
html.dark-theme .click-box code {
    background: rgba(0,0,0,0.3);
    color: #6ee7b7;
}

html.dark-theme .error-box {
    background: #450a0a;
    border: 1px solid #7f1d1d;
}
html.dark-theme .error-message {
    color: #fca5a5;
}

html.dark-theme .idle-box { 
    background: #422006; 
    color: #fcd34d; 
    border: 1px solid #78350f;
}

html.dark-theme .tag.bg-blue { background: #0369a1; color: #e0f2fe; }
html.dark-theme .tag.bg-purple { background: #581c87; color: #f3e8ff; }
html.dark-theme .tag.bg-green { background: #065f46; color: #d1fae5; }
html.dark-theme .tag.bg-red { background: #7f1d1d; color: #fee2e2; }

html.dark-theme .role-super-admin { background: #064e3b; color: #6ee7b7; }
html.dark-theme .role-analyst { background: #78350f; color: #fcd34d; }
html.dark-theme .role-viewer { background: #075985; color: #bae6fd; }

html.dark-theme .btn-edit { background: #0c4a6e; color: #38bdf8; }
html.dark-theme .btn-edit:hover { background: #075985; color: #7dd3fc; }
html.dark-theme .btn-delete { background: #7f1d1d; color: #fca5a5; }
html.dark-theme .btn-delete:hover { background: #991b1b; color: #fecaca; }

html.dark-theme .json-cell {
    background-color: #0f172a;
    color: #cbd5e1;
    border: 1px solid #334155;
}

html.dark-theme #stack-trace-panel {
    background: #0f172a;
    color: #f8fafc;
    border: 1px solid #334155;
}

html.dark-theme .summary-card .value {
    color: #38bdf8;
    text-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
}


/* Make sure the logo is visible */
html.dark-theme .brand img {
    filter: invert(1) brightness(1.5);
}


.btn-delete-report { padding: 10px; background-color: #fee2e2; color: #dc2626; border: 1px solid #f87171; border-radius: 6px; cursor: pointer; font-weight: bold; transition: background-color 0.2s ease, transform 0.2s ease; }
.btn-delete-report:hover { background-color: #fecaca; transform: translateY(-1px); }

html.dark-theme .btn-delete-report { background-color: #7f1d1d; color: #fca5a5; border-color: #991b1b; }
html.dark-theme .btn-delete-report:hover { background-color: #991b1b; border-color: #b91c1c; }



html.dark-theme .btn-cancel { background-color: #334155; color: #cbd5e1; }
html.dark-theme .btn-cancel:hover { background-color: #475569; color: #f8fafc; }


html.dark-theme th.sortable:hover { background-color: #334155 !important; }
html.dark-theme th.sortable.sort-asc .sort-icon::after,
html.dark-theme th.sortable.sort-desc .sort-icon::after { color: #38bdf8; }


html.dark-theme .modal-content h2,
html.dark-theme .modal-content h3 {
    color: #f8fafc;
}


html.dark-theme .message-success { background: #064e3b; color: #6ee7b7; border-color: #047857; }
html.dark-theme .message-error { background: #7f1d1d; color: #fca5a5; border-color: #991b1b; }


html.dark-theme ::-webkit-scrollbar-track { background: #0f172a; }
html.dark-theme ::-webkit-scrollbar-thumb { background: #334155; }
html.dark-theme ::-webkit-scrollbar-thumb:hover { background: #475569; }



html.dark-theme table { background-color: #1e293b; }


