/**
 * Layout CSS - Consolidated layout styles
 * Extracted from nav-side.css and other layout-related styles
 */

/* Import variables */
@import 'variables.css';

/* ===== LAYOUT COMPONENTS ===== */

/* Body layout adjustments for relative navbar */
body.navbar-relative-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

body.navbar-relative-layout main {
    flex: 1;
    position: relative;
    z-index: 1;
}

/* Stats Panel Layout */
.stats-panel {
    position: fixed;
    top: var(--navbar-height); /* Push down by navbar height */
    right: -100%;
    width: 100%;
    height: calc(100vh - var(--navbar-height)); /* Account for navbar height */
    transition: right var(--transition-speed) cubic-bezier(0.19, 1, 0.22, 1);
    z-index: var(--z-modal);
    display: flex;
    flex-direction: column;
    border-radius: 0;
    box-shadow: var(--shadow);
    overflow-y: auto;
    overflow-x: hidden;
    background-color: var(--dark-panel);
}

.stats-panel.open {
    right: 0;
}

.stats-panel ul {
    list-style: none;
    padding: 0;
}

.stats-panel li {
    padding: var(--spacing-sm) var(--spacing-md);
}

/* Top Right Panel */
#top-right-panel {
    position: absolute;
    top: var(--navbar-height); /* Push down by navbar height */
    padding: var(--spacing-lg);
    z-index: var(--z-modal);
    display: flex;
    flex-direction: column;
    flex: 1;
    align-items: flex-start;
    min-width: 200px;
    overflow-y: auto;
    max-height: calc(95vh - var(--navbar-height)); /* Account for navbar height */
    background-color: var(--dark-panel);
    border-width: 0 0 0 4px;
    border-style: solid;
    border-color: var(--primary-color);
    width: 100%;
    border-radius: 0 0 0 var(--border-radius);
    box-shadow: var(--shadow);
    transition: all var(--transition-speed);
    gap: var(--spacing-md);
}

#top-right-panel h2 {
    font-weight: 500;
    margin-bottom: var(--spacing-md);
    font-size: var(--font-size-lg);
    color: var(--text-light);
}

#top-right-panel p {
    margin-bottom: var(--spacing-sm);
    line-height: 1.5;
    color: var(--text-light);
}

#top-right-panel .button-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: auto;
}

#top-right-panel .table-container {
    overflow-x: auto;
    border-radius: var(--border-radius);
    margin: var(--spacing-sm) 0;
    background-color: var(--dark-overlay);
}

#top-right-panel table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: var(--border-radius);
    overflow: hidden;
}

#top-right-panel th, #top-right-panel td {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    color: var(--text-light);
}

#top-right-panel th {
    background-color: var(--dark-overlay);
    font-weight: 600;
}

#top-right-panel tr:nth-child(even) {
    background-color: var(--dark-overlay);
}

/* Button Layout */
.top-right-button-set {
    position: fixed;
    top: calc(var(--navbar-height) + 10px); /* Push down by navbar height + margin */
    right: 25px;
    display: flex;
    flex-direction: column;
    z-index: 1002;
    height: auto; /* Changed from 100% for better mobile compatibility */
    justify-content: flex-start; /* Changed from center */
    gap: 16px;
}

/* Navigation Layout */
.navbar-top {
    position: relative; /* Changed from fixed to push content down */
    top: 0;
    left: 0;
    right: 0;
    background-color: var(--dark-panel);
    border-bottom: 4px solid var(--primary-color) !important;
    z-index: var(--z-navbar) !important; /* Ensure navbar stays on top */
    box-shadow: var(--shadow);
    width: 100%; /* Ensure full width */
    display: block !important; /* Defensive: prevent accidental hiding */
    visibility: visible !important; /* Defensive: ensure always visible */
    transform: none !important; /* Prevent transform interference */
}

/* Defensive: Ensure navbar is never accidentally hidden */
.navbar-top,
.navbar-top.navbar,
.navbar-top.navbar-expand-lg {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    height: auto !important;
    overflow: visible !important;
}

/* Extra protection for navbar during map operations */
.navbar-top.force-visible {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    z-index: var(--z-navbar) !important;
    position: relative !important;
    transform: none !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
}

/* Debug helper - uncomment to highlight navbar boundaries */
/*
.navbar-top {
    outline: 2px solid red !important;
    background-color: rgba(255, 0, 0, 0.1) !important;
}
.navbar-container {
    outline: 2px solid blue !important;
    background-color: rgba(0, 0, 255, 0.1) !important;
}
*/

.navbar-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--dark-panel);
    border-top: 1px solid var(--border-color);
    z-index: var(--z-fixed);
}

.navbar-container {
    display: flex !important; /* Defensive: ensure flex layout */
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-sm) var(--spacing-md);
    max-width: 1200px;
    margin: 0 auto;
    position: relative; /* Ensure proper positioning context */
    width: 100%; /* Ensure full width */
    opacity: 1 !important; /* Defensive: prevent opacity issues */
}

.brand-container {
    display: flex !important; /* Defensive: ensure flex layout */
    align-items: center;
    gap: var(--spacing-sm);
    position: relative; /* Ensure proper positioning */
    opacity: 1 !important; /* Defensive: prevent opacity issues */
}

.brand-text {
    font-size: var(--font-size-lg);
    font-weight: 600;
    color: var(--text-light);
}

.brand-link {
    color: var(--text-light);
    text-decoration: none;
    transition: color var(--transition-speed);
}

.brand-link:hover {
    color: var(--primary-color);
}

.navbar-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    color: var(--text-muted);
    font-size: var(--font-size-sm);
}

.welcome-text {
    color: var(--text-light);
}

/* Panel Sections */
.panel-section {
    background-color: var(--dark-overlay);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    border-left: 4px solid var(--primary-color);
}

.welcome-heading {
    font-size: var(--font-size-lg);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-light);
}

.section-title {
    font-size: var(--font-size-md);
    font-weight: 600;
    margin-bottom: var(--spacing-sm);
    color: var(--text-light);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.section-title i {
    color: var(--primary-color);
}

/* Search Components */
.search-container {
    background-color: var(--dark-overlay);
    border-radius: var(--border-radius);
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.search-box {
    display: flex;
    align-items: center;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: var(--spacing-sm);
    transition: border-color var(--transition-speed);
}

.search-box:focus-within {
    border-color: var(--primary-color);
}

.search-box i {
    color: var(--text-muted);
    margin-right: var(--spacing-sm);
    font-size: var(--font-size-sm);
}

.search-box input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-light);
    font-size: var(--font-size-sm);
    outline: none;
}

.search-box input::placeholder {
    color: var(--text-muted);
}

/* Floating Search - Compact Dropdown Style */
#floating-search-wrapper {
    position: fixed;
    top: calc(var(--navbar-height) + 10px);
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--dark-panel);
    border-radius: 25px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    padding: 8px 16px;
    z-index: var(--z-fixed);
    transition: all 0.3s ease;
    max-width: 400px;
    width: 90%;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

#floating-search-wrapper h2 {
    display: none; /* Hide the title for compact dropdown */
}

#floating-search-wrapper #alert-count {
    display: none; /* Hide alert count for compact dropdown by default */
}

/* Show alert-count when it contains search results */
#floating-search-wrapper #alert-count.has-results {
    display: block;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--dark-panel);
    border-radius: 12px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    margin-top: 8px;
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 8px;
}

/* Style search results within the alert-count container */
#floating-search-wrapper #alert-count.has-results .search-results {
    background: none;
    border: none;
    box-shadow: none;
    margin: 0;
    padding: 0;
    max-height: none;
    overflow: visible;
}

#floating-search-wrapper #alert-count.has-results .alert-search-result {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
}

#floating-search-wrapper #alert-count.has-results .alert-search-result:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

#floating-search-wrapper #alert-count.has-results .alert-search-result .alert-title {
    font-weight: 600;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 4px;
    line-height: 1.3;
}

#floating-search-wrapper #alert-count.has-results .alert-search-result .alert-description {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 4px;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

#floating-search-wrapper #alert-count.has-results .alert-search-result .alert-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 10px;
    color: rgba(255, 255, 255, 0.6);
}

#floating-search-wrapper #alert-count.has-results .no-search-results {
    text-align: center;
    padding: 16px;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    font-size: 12px;
}

/* Recent Searches Styling */
#floating-search-wrapper #alert-count.has-results .recent-searches {
    background: none;
    border: none;
    box-shadow: none;
    margin: 0;
    padding: 0;
    max-height: none;
    overflow: visible;
}

#floating-search-wrapper #alert-count.has-results .recent-searches-header {
    font-weight: 600;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 8px;
    padding: 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#floating-search-wrapper #alert-count.has-results .recent-search-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    margin-bottom: 6px;
    transition: all 0.2s ease;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

#floating-search-wrapper #alert-count.has-results .recent-search-item:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

#floating-search-wrapper #alert-count.has-results .recent-search-item i.fa-history {
    color: rgba(255, 255, 255, 0.6);
    font-size: 10px;
    flex-shrink: 0;
}

#floating-search-wrapper #alert-count.has-results .recent-search-text {
    flex: 1;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.3;
}

#floating-search-wrapper #alert-count.has-results .remove-recent-search {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
}

#floating-search-wrapper #alert-count.has-results .remove-recent-search:hover {
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.8);
}

#floating-search-wrapper #alert-count.has-results .remove-recent-search i {
    font-size: 10px;
}

#floating-search-wrapper .search-container:focus-within ~ #alert-count {
    color: var(--primary-color);
}

/* Light theme support for alert-count */
body.light-theme #floating-search-wrapper #alert-count {
    color: var(--text-dark);
}

body.light-theme #floating-search-wrapper .search-container:focus-within ~ #alert-count {
    color: var(--primary-color);
}

/* Compact search styling for floating search wrapper */
#floating-search-wrapper .search-container {
    background: none;
    padding: 0;
    margin: 0;
}

#floating-search-wrapper .search-box {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 20px;
    padding: 8px 12px;
    transition: all 0.3s ease;
}

#floating-search-wrapper .search-box:focus-within {
    background: rgba(255, 255, 255, 0.15);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.3);
}

#floating-search-wrapper .search-box i {
    color: rgba(255, 255, 255, 0.7);
    margin-right: 8px;
    font-size: 14px;
}

#floating-search-wrapper .search-box input {
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
}

#floating-search-wrapper .search-box input::placeholder {
    color: rgba(255, 255, 255, 0.6);
}

/* Search results styling for compact floating search wrapper - REMOVED DUPLICATE */

/* Search Results Styling */
.search-results {
    max-height: 350px;
    overflow-y: auto;
    margin-top: var(--spacing-xs);
    transition: opacity 0.3s ease, transform 0.3s ease;
    opacity: 1;
    transform: translateY(0);
}

/* Search results hiding animation */
.search-results.hiding {
    opacity: 0;
    transform: translateY(-10px);
    pointer-events: none;
}

.alert-search-result {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--border-radius);
    padding: var(--spacing-xs) var(--spacing-sm);
    margin-bottom: var(--spacing-xs);
    transition: var(--transition-base);
    cursor: pointer;
}

.alert-search-result:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.alert-search-result:active {
    transform: scale(0.98);
}

.alert-search-result.zooming {
    opacity: 0.7;
    pointer-events: none;
    background: rgba(33, 150, 243, 0.1) !important;
    border-color: var(--primary-color) !important;
}

.alert-search-result .alert-title {
    font-weight: 600;
    font-size: var(--font-size-xs);
    color: var(--text-light);
    margin-bottom: var(--spacing-xs);
    line-height: 1.3;
}

.alert-search-result .alert-description {
    font-size: var(--font-size-xs);
    color: var(--text-muted);
    margin-bottom: var(--spacing-xs);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.alert-search-result .alert-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
    font-size: var(--font-size-xs);
    color: var(--text-muted);
}

.alert-search-result .alert-severity {
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 500;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.alert-search-result .alert-severity.minor {
    background: rgba(52, 168, 83, 0.2);
    color: #34a853;
}

.alert-search-result .alert-severity.moderate {
    background: rgba(255, 193, 7, 0.2);
    color: #ffc107;
}

.alert-search-result .alert-severity.severe {
    background: rgba(255, 87, 34, 0.2);
    color: #ff5722;
}

.alert-search-result .alert-severity.extreme {
    background: rgba(244, 67, 54, 0.2);
    color: #f44336;
}

.alert-search-result .alert-severity.unknown {
    background: rgba(158, 158, 158, 0.2);
    color: #9e9e9e;
}

.no-search-results {
    text-align: center;
    padding: var(--spacing-md);
    color: var(--text-muted);
    font-style: italic;
}

/* Search term highlighting */
.search-highlight {
    background: rgba(255, 235, 59, 0.4);
    color: #333;
    padding: 1px 2px;
    border-radius: 2px;
    font-weight: 600;
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

/* Light theme search results - Higher specificity to override any conflicting styles */
body.light-theme .search-results .alert-search-result {
    background: rgba(0, 0, 0, 0.03) !important;
    border-color: rgba(0, 0, 0, 0.1) !important;
    color: var(--text-dark) !important;
}

body.light-theme .search-results .alert-search-result:hover {
    background: rgba(0, 0, 0, 0.06) !important;
}

body.light-theme .search-results .alert-search-result .alert-title,
body.light-theme .alert-search-result .alert-title {
    color: var(--text-dark) !important;
}

body.light-theme .search-results .alert-search-result .alert-description,
body.light-theme .alert-search-result .alert-description {
    color: var(--text-muted-dark) !important;
}

body.light-theme .search-results .alert-search-result .alert-meta,
body.light-theme .alert-search-result .alert-meta {
    color: var(--text-muted-dark) !important;
}

body.light-theme .no-search-results {
    color: var(--text-muted-dark) !important;
}

body.light-theme .search-highlight {
    background: rgba(255, 193, 7, 0.3) !important;
    color: #1a1a1a !important;
}

/* Debug: Add a subtle indicator when light theme is active for search results */
body.light-theme .search-results {
    border-left: 2px solid #007bff !important;
}

/* Ensure all text in search results respects theme */
body.light-theme .search-results * {
    color: inherit !important;
}

body.light-theme .search-results .alert-title {
    color: #212529 !important;
    font-weight: 600 !important;
}

body.light-theme .search-results .alert-description {
    color: #6c757d !important;
}

body.light-theme .search-results .alert-meta {
    color: #6c757d !important;
}

/* ===== PROGRESSIVE RESPONSIVE SCALING ===== */

/* Large Mobile and Small Tablet (768px) */
@media (max-width: 768px) {
    .stats-panel {
        width: 100%;
        right: -100%;
        top: 0;
        height: 100vh;
    }

    .top-right-button-set {
        position: fixed;
        top: 8px;
        right: 8px;
        flex-direction: row;
        height: auto;
        justify-content: flex-end;
        gap: 10px;
        flex-wrap: wrap;
        max-width: calc(100vw - 16px);
        padding: 6px;
        background: rgba(0, 0, 0, 0.08);
        border-radius: 8px;
        backdrop-filter: blur(8px);
    }

    .navbar-info {
        display: none;
    }

    .welcome-text {
        font-size: 0.85rem;
    }

    .navbar-container {
        padding: 10px 12px;
    }
    
    /* Mobile navbar collapse adjustments */
    .navbar-collapse {
        max-height: calc(100vh - 60px);
        border-radius: 0 0 8px 8px;
    }
    
    .navbar-nav {
        padding: 8px;
    }
    
    .nav-item {
        margin-bottom: 4px;
    }
    
    .nav-link {
        padding: 8px 0;
        font-size: 14px;
    }
    
    .nav-link i {
        width: 18px;
        font-size: 12px;
    }
    
    /* Mobile navbar-toggler adjustments */
    .navbar-top .navbar-toggler {
        padding: 5px 8px;
        border-radius: 5px;
    }
    
    .navbar-top .navbar-toggler i {
        font-size: 12px;
    }

    .panel-section {
        padding: 12px;
        margin-bottom: 12px;
    }

    .welcome-heading {
        font-size: 1.1rem;
    }

    .section-title {
        font-size: 1rem;
    }

    .search-container {
        margin-bottom: 12px;
        padding: 12px;
    }

    .search-box {
        padding: 8px;
    }

    .search-box i {
        font-size: 0.85rem;
    }

    .search-box input {
        font-size: 0.85rem;
    }

    #floating-search-wrapper {
        padding: 6px 12px;
        max-width: 300px;
        border-radius: 20px;
    }
    
    #floating-search-wrapper .search-box {
        padding: 6px 10px;
    }
    
    #floating-search-wrapper .search-box i {
        font-size: 12px;
        margin-right: 6px;
    }
    
    #floating-search-wrapper .search-box input {
        font-size: 12px;
    }
    
    /* Mobile search results adjustments - REMOVED DUPLICATE */
    
    #floating-search-wrapper #alert-count.has-results {
        max-height: 250px;
        margin-top: 6px;
        padding: 6px;
    }
    
    /* Mobile recent searches adjustments */
    #floating-search-wrapper #alert-count.has-results .recent-searches-header {
        font-size: 11px;
        margin-bottom: 6px;
    }
    
    #floating-search-wrapper #alert-count.has-results .recent-search-item {
        padding: 6px 10px;
        margin-bottom: 4px;
        gap: 6px;
    }
    
    #floating-search-wrapper #alert-count.has-results .recent-search-text {
        font-size: 11px;
    }
    
    #floating-search-wrapper #alert-count.has-results .remove-recent-search {
        width: 18px;
        height: 18px;
    }
    
    /* Mobile alert search result adjustments - REMOVED DUPLICATE */

    #floating-search-wrapper h2 {
        font-size: var(--font-size-sm);
        margin-bottom: 6px;
    }

    #floating-search-wrapper #alert-count {
        font-size: 10px;
        margin-top: 4px;
    }

    /* Mobile search results adjustments - REMOVED DUPLICATE */

    #top-right-panel {
        padding: 12px;
        min-width: auto;
        width: 100%;
    }

    #top-right-panel h2 {
        font-size: 1.1rem;
        margin-bottom: 12px;
    }

    #top-right-panel th, 
    #top-right-panel td {
        padding: 8px 10px;
        font-size: 0.85rem;
    }
}

/* Small Mobile (480px) */
@media (max-width: 480px) {
    .top-right-button-set {
        top: 6px;
        right: 6px;
        gap: 8px;
        max-width: calc(100vw - 12px);
        padding: 4px;
        border-radius: 6px;
    }

    .navbar-container {
        padding: 8px 10px;
    }
    
    /* Small mobile navbar collapse adjustments */
    .navbar-collapse {
        max-height: calc(100vh - 50px);
        border-radius: 0 0 6px 6px;
    }
    
    .navbar-nav {
        padding: 6px;
    }
    
    .nav-item {
        margin-bottom: 3px;
    }
    
    .nav-link {
        padding: 6px 0;
        font-size: 13px;
    }
    
    .nav-link i {
        width: 16px;
        font-size: 11px;
    }
    
    /* Small mobile navbar-toggler adjustments */
    .navbar-top .navbar-toggler {
        padding: 4px 6px;
        border-radius: 4px;
    }
    
    .navbar-top .navbar-toggler i {
        font-size: 11px;
    }

    .brand-text {
        font-size: 1rem;
    }

    .panel-section {
        padding: 10px;
        margin-bottom: 10px;
    }

    .welcome-heading {
        font-size: 1rem;
    }

    .section-title {
        font-size: 0.9rem;
    }

    #top-right-panel {
        padding: 10px;
    }

    #top-right-panel h2 {
        font-size: 1rem;
    }

    #top-right-panel th, 
    #top-right-panel td {
        padding: 6px 8px;
        font-size: 0.8rem;
    }

    .search-box {
        padding: 6px;
    }

    .search-box input {
        font-size: 0.8rem;
    }

    #floating-search-wrapper {
        padding: 4px 10px;
        max-width: 260px;
        border-radius: 18px;
    }
    
    #floating-search-wrapper .search-box {
        padding: 4px 8px;
    }
    
    #floating-search-wrapper .search-box i {
        font-size: 11px;
        margin-right: 5px;
    }
    
    #floating-search-wrapper .search-box input {
        font-size: 11px;
    }
    
    /* Small mobile search results adjustments - REMOVED DUPLICATE */
    
    #floating-search-wrapper #alert-count.has-results {
        max-height: 200px;
        margin-top: 4px;
        padding: 4px;
    }
    
    /* Small mobile recent searches adjustments */
    #floating-search-wrapper #alert-count.has-results .recent-searches-header {
        font-size: 10px;
        margin-bottom: 4px;
    }
    
    #floating-search-wrapper #alert-count.has-results .recent-search-item {
        padding: 4px 8px;
        margin-bottom: 3px;
        gap: 4px;
    }
    
    #floating-search-wrapper #alert-count.has-results .recent-search-text {
        font-size: 10px;
    }
    
    #floating-search-wrapper #alert-count.has-results .remove-recent-search {
        width: 16px;
        height: 16px;
    }
    
    /* Small mobile alert search result adjustments - REMOVED DUPLICATE */

    #floating-search-wrapper h2 {
        font-size: 11px;
        margin-bottom: 4px;
    }

    #floating-search-wrapper #alert-count {
        font-size: 9px;
        margin-top: 3px;
    }

    /* Small mobile search results adjustments - REMOVED DUPLICATE */
}

/* Extra Small Mobile (360px) */
@media (max-width: 360px) {
    .top-right-button-set {
        top: 4px;
        right: 4px;
        gap: 6px;
        max-width: calc(100vw - 8px);
        padding: 3px;
        border-radius: 5px;
    }

    .navbar-container {
        padding: 6px 8px;
    }
    
    /* Extra small mobile navbar collapse adjustments */
    .navbar-collapse {
        max-height: calc(100vh - 45px);
        border-radius: 0 0 4px 4px;
    }
    
    .navbar-nav {
        padding: 4px;
    }
    
    .nav-item {
        margin-bottom: 2px;
    }
    
    .nav-link {
        padding: 4px 0;
        font-size: 12px;
    }
    
    .nav-link i {
        width: 14px;
        font-size: 10px;
    }
    
    /* Extra small mobile navbar-toggler adjustments */
    .navbar-top .navbar-toggler {
        padding: 3px 5px;
        border-radius: 3px;
    }
    
    .navbar-top .navbar-toggler i {
        font-size: 10px;
    }

    .brand-text {
        font-size: 0.9rem;
    }

    .panel-section {
        padding: 8px;
        margin-bottom: 8px;
    }

    .welcome-heading {
        font-size: 0.9rem;
    }

    .section-title {
        font-size: 0.85rem;
    }

    #top-right-panel {
        padding: 8px;
    }

    #top-right-panel h2 {
        font-size: 0.9rem;
    }

    #top-right-panel th, 
    #top-right-panel td {
        padding: 4px 6px;
        font-size: 0.75rem;
    }

    .search-box {
        padding: 5px;
    }

    .search-box input {
        font-size: 0.75rem;
    }

    #floating-search-wrapper {
        padding: 3px 8px;
        max-width: 220px;
        border-radius: 16px;
    }
    
    #floating-search-wrapper .search-box {
        padding: 3px 6px;
    }
    
    #floating-search-wrapper .search-box i {
        font-size: 10px;
        margin-right: 4px;
    }
    
    #floating-search-wrapper .search-box input {
        font-size: 10px;
    }
    
    /* Extra small mobile search results adjustments - REMOVED DUPLICATE */
    
    #floating-search-wrapper #alert-count.has-results {
        max-height: 180px;
        margin-top: 3px;
        padding: 3px;
    }
    
    /* Extra small mobile recent searches adjustments */
    #floating-search-wrapper #alert-count.has-results .recent-searches-header {
        font-size: 9px;
        margin-bottom: 3px;
    }
    
    #floating-search-wrapper #alert-count.has-results .recent-search-item {
        padding: 3px 6px;
        margin-bottom: 2px;
        gap: 3px;
    }
    
    #floating-search-wrapper #alert-count.has-results .recent-search-text {
        font-size: 9px;
    }
    
    #floating-search-wrapper #alert-count.has-results .remove-recent-search {
        width: 14px;
        height: 14px;
    }
    
    /* Extra small mobile alert search result adjustments - REMOVED DUPLICATE */

    #floating-search-wrapper h2 {
        font-size: 10px;
        margin-bottom: 3px;
    }

    #floating-search-wrapper #alert-count {
        font-size: 8px;
        margin-top: 2px;
    }

    /* Extra small mobile search results adjustments - REMOVED DUPLICATE */
}

/* Landscape Mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .top-right-button-set {
        top: 5px;
        right: 5px;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .navbar-container {
        padding: var(--spacing-xs);
    }

    .stats-panel {
        top: 0;
        height: 100vh;
    }
}

/* Tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .top-right-button-set {
        right: 15px;
        gap: 12px;
    }

    .navbar-container {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .panel-section {
        padding: var(--spacing-sm);
    }

    #top-right-panel {
        padding: var(--spacing-md);
        min-width: 180px;
    }
}

/* ===== EXISTING MEDIA QUERIES ===== */

@media (max-width: 991px) {
    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: var(--dark-panel);
        border-top: 1px solid var(--border-color);
        box-shadow: var(--shadow);
        transform: translateY(-100%);
        transition: transform var(--transition-speed);
        z-index: var(--z-navbar);
        max-height: calc(100vh - var(--navbar-height));
        overflow-y: auto;
        border-radius: 0 0 12px 12px;
    }

    .navbar-collapse.show {
        transform: translateY(0);
    }

    .navbar-nav {
        flex-direction: column;
        padding: var(--spacing-md);
    }

    .nav-item {
        margin-bottom: var(--spacing-sm);
    }

    .nav-link {
        padding: var(--spacing-sm) 0;
        border-bottom: 1px solid var(--border-color);
        color: var(--text-light);
        transition: color var(--transition-speed);
        display: flex;
        align-items: center;
        gap: var(--spacing-sm);
    }

    .nav-link:hover {
        color: var(--primary-color);
        background-color: transparent;
    }
    
    .nav-link i {
        width: 20px;
        text-align: center;
        flex-shrink: 0;
    }
}

/* ===== LIGHT THEME LAYOUT ===== */

body.light-theme #top-right-panel {
    background-color: var(--light-panel);
}

body.light-theme #top-right-panel h2,
body.light-theme #top-right-panel p {
    color: var(--text-dark);
}

body.light-theme #top-right-panel th,
body.light-theme #top-right-panel td {
    color: var(--text-dark);
}

body.light-theme #top-right-panel th {
    background-color: var(--light-overlay);
}

body.light-theme #top-right-panel tr:nth-child(even) {
    background-color: var(--light-overlay);
}

body.light-theme #top-right-panel .table-container {
    background-color: var(--light-overlay);
}

body.light-theme .navbar-top {
    background-color: var(--light-panel);
    border-bottom-color: var(--border-color-light);
}

/* Light theme navbar elements */
body.light-theme .navbar-top .brand-text {
    color: var(--text-dark);
}

body.light-theme .navbar-top .brand-link {
    color: var(--text-dark);
}

body.light-theme .navbar-top .brand-link:hover {
    color: var(--primary-color);
}

body.light-theme .navbar-top .nav-link {
    color: var(--text-dark);
}

body.light-theme .navbar-top .nav-link:hover {
    color: var(--primary-color);
}

body.light-theme .navbar-top .nav-link i {
    color: var(--text-dark);
}

body.light-theme .navbar-top .nav-link:hover i {
    color: var(--primary-color);
}

body.light-theme .navbar-top .navbar-toggler {
    color: var(--text-dark);
    border-color: var(--border-color-light);
    background: rgba(0, 0, 0, 0.05);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

body.light-theme .navbar-top .navbar-toggler:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.1);
}

body.light-theme .navbar-top .navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem var(--primary-color-alpha);
}

/* Dark theme navbar-toggler styling */
.navbar-top .navbar-toggler {
    color: var(--text-light);
    border-color: var(--border-color);
    transition: all var(--transition-speed);
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.navbar-top .navbar-toggler:hover {
    color: var(--primary-color);
    border-color: var(--primary-color);
    background: rgba(255, 255, 255, 0.1);
}

.navbar-top .navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem var(--primary-color-alpha);
    outline: none;
}

.navbar-top .navbar-toggler i {
    font-size: 14px;
}

/* Light theme mobile navbar collapse */
body.light-theme .navbar-top .navbar-collapse {
    background-color: var(--light-panel);
    border-top-color: var(--border-color-light);
}

body.light-theme .navbar-top .navbar-nav .nav-link {
    border-bottom-color: var(--border-color-light);
}

body.light-theme .navbar-top .navbar-nav .nav-link:hover {
    background-color: var(--light-overlay);
}

/* Dark theme nav links styling */
.navbar-top .nav-link {
    color: var(--text-light);
    transition: color var(--transition-speed);
}

.navbar-top .nav-link:hover {
    color: var(--primary-color);
}

.navbar-top .nav-link i {
    color: var(--text-light);
    transition: color var(--transition-speed);
}

.navbar-top .nav-link:hover i {
    color: var(--primary-color);
}

body.light-theme .navbar-bottom {
    background-color: var(--light-panel);
    border-top-color: var(--border-color-light);
}

body.light-theme .navbar-text-container {
    color: var(--text-dark);
}

body.light-theme .panel-section {
    background-color: var(--light-overlay);
}

body.light-theme .welcome-heading {
    color: var(--text-dark);
}

body.light-theme .section-title {
    color: var(--text-dark);
}

body.light-theme .search-container {
    background-color: var(--light-overlay);
}

body.light-theme .search-box {
    background-color: var(--input-bg-light);
    border-color: var(--border-color-light);
}

body.light-theme .search-box input {
    color: var(--text-dark);
}

body.light-theme .search-box input::placeholder {
    color: var(--text-muted-light);
}

body.light-theme .search-box i {
    color: var(--text-muted-light);
}

body.light-theme #floating-search-wrapper {
    background-color: var(--light-panel);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Light theme support for compact search */
body.light-theme #floating-search-wrapper .search-box {
    background: rgba(0, 0, 0, 0.05);
}

body.light-theme #floating-search-wrapper .search-box:focus-within {
    background: rgba(0, 0, 0, 0.08);
    box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.3);
}

body.light-theme #floating-search-wrapper .search-box i {
    color: rgba(0, 0, 0, 0.6);
}

body.light-theme #floating-search-wrapper .search-box input {
    color: rgba(0, 0, 0, 0.8);
}

body.light-theme #floating-search-wrapper .search-box input::placeholder {
    color: rgba(0, 0, 0, 0.5);
}

/* Light theme support for search results in compact wrapper - REMOVED DUPLICATE */

/* Light theme support for has-results dropdown */
body.light-theme #floating-search-wrapper #alert-count.has-results {
    background: var(--light-panel);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Light theme support for search results within alert-count */
body.light-theme #floating-search-wrapper #alert-count.has-results .alert-search-result {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

body.light-theme #floating-search-wrapper #alert-count.has-results .alert-search-result:hover {
    background: rgba(0, 0, 0, 0.06);
}

body.light-theme #floating-search-wrapper #alert-count.has-results .alert-search-result .alert-title {
    color: rgba(0, 0, 0, 0.8);
}

body.light-theme #floating-search-wrapper #alert-count.has-results .alert-search-result .alert-description {
    color: rgba(0, 0, 0, 0.6);
}

body.light-theme #floating-search-wrapper #alert-count.has-results .alert-search-result .alert-meta {
    color: rgba(0, 0, 0, 0.5);
}

body.light-theme #floating-search-wrapper #alert-count.has-results .no-search-results {
    color: rgba(0, 0, 0, 0.5);
}

/* Light theme support for recent searches */
body.light-theme #floating-search-wrapper #alert-count.has-results .recent-searches-header {
    color: rgba(0, 0, 0, 0.7);
}

body.light-theme #floating-search-wrapper #alert-count.has-results .recent-search-item {
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid rgba(0, 0, 0, 0.1);
}

body.light-theme #floating-search-wrapper #alert-count.has-results .recent-search-item:hover {
    background: rgba(0, 0, 0, 0.06);
}

body.light-theme #floating-search-wrapper #alert-count.has-results .recent-search-item i.fa-history {
    color: rgba(0, 0, 0, 0.5);
}

body.light-theme #floating-search-wrapper #alert-count.has-results .recent-search-text {
    color: rgba(0, 0, 0, 0.8);
}

body.light-theme #floating-search-wrapper #alert-count.has-results .remove-recent-search {
    color: rgba(0, 0, 0, 0.4);
}

body.light-theme #floating-search-wrapper #alert-count.has-results .remove-recent-search:hover {
    background: rgba(0, 0, 0, 0.1);
    color: rgba(0, 0, 0, 0.7);
}

/* ===== UTILITY CLASSES ===== */

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn var(--transition-speed) ease-in;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ===== NAVBAR HEIGHT TRANSITION HELPER ===== */

/* Smooth transition when navbar height changes */
.left-sidebar,
.secondary-menu,
.stats-panel,
.top-right-button-set,
#floating-search-wrapper,
#top-right-panel {
    transition: top var(--transition-fast), height var(--transition-fast), 
                left var(--transition-speed), right var(--transition-speed), 
                transform var(--transition-speed) !important;
}

/* Prevent layout shifts during initial navbar height calculation */
body.calculating-navbar-height .left-sidebar,
body.calculating-navbar-height .secondary-menu,
body.calculating-navbar-height .stats-panel {
    opacity: 0.95;
    transform: translateY(-2px);
    transition: opacity var(--transition-fast), transform var(--transition-fast);
}

body.navbar-height-calculated .left-sidebar,
body.navbar-height-calculated .secondary-menu,
body.navbar-height-calculated .stats-panel {
    opacity: 1;
    /* Removed transform: translateY(0) - was overriding sliding animations */
}

 