/* Edge Config Portal - Luxury Modern Theme */

:root {
    --gradient-primary: linear-gradient(135deg, #1976D2 0%, #1565C0 100%);
    --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.12);
    --shadow-strong: 0 8px 32px rgba(0, 0, 0, 0.16);
    --border-radius: 12px;
    --transition-fast: 0.2s ease;
    --transition-medium: 0.3s ease;
    /* Theme-aware colors */
    --bg-main: #F5F5F5;
    --bg-surface: #FFFFFF;
    --bg-surface-alt: #FAFAFA;
    --text-secondary: #666666;
    --text-primary: #333333;
    --border-light: rgba(0, 0, 0, 0.06);
    --border-medium: rgba(0, 0, 0, 0.08);
    --border-strong: rgba(0, 0, 0, 0.12);
}

/* Dark mode overrides */
.mud-theme-dark {
    --gradient-primary: linear-gradient(135deg, #90CAF9 0%, #64B5F6 100%);
    --shadow-soft: 0 2px 8px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 4px 16px rgba(0, 0, 0, 0.4);
    --shadow-strong: 0 8px 32px rgba(0, 0, 0, 0.5);
    --bg-main: #121212;
    --bg-surface: #1E1E1E;
    --bg-surface-alt: #2D2D2D;
    --text-secondary: #B0B0B0;
    --text-primary: #E0E0E0;
    --border-light: rgba(255, 255, 255, 0.06);
    --border-medium: rgba(255, 255, 255, 0.08);
    --border-strong: rgba(255, 255, 255, 0.12);
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Bar Styling */
.app-bar {
    backdrop-filter: blur(10px);
    background: var(--gradient-primary) !important;
}

/* Drawer Styling */
.drawer {
    border-right: 1px solid var(--border-medium);
}

.mud-drawer-content .mud-navlink {
    border-radius: 8px;
    margin: 4px 8px;
    transition: var(--transition-fast);
}

.mud-drawer-content .mud-navlink:hover {
    background: rgba(25, 118, 210, 0.08);
}

.mud-drawer-content .mud-navlink.active {
    background: rgba(25, 118, 210, 0.12);
    color: #1976D2;
}

/* Main Content */
.main-content {
    background: var(--bg-main);
    min-height: 100vh;
}

/* Card Enhancements */
.mud-card {
    border-radius: var(--border-radius) !important;
    transition: var(--transition-medium);
}

.mud-card:hover {
    box-shadow: var(--shadow-medium);
}

/* Stat Card Styling */
.stat-card {
    background: var(--bg-surface);
    border-radius: var(--border-radius);
    padding: 24px;
    transition: var(--transition-medium);
    border: 1px solid var(--border-light);
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-strong);
}

.stat-card .stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-card .stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Table Styling */
.mud-table {
    border-radius: var(--border-radius) !important;
    overflow: hidden;
}

.mud-table .mud-table-head {
    background: var(--bg-surface-alt);
}

.mud-table .mud-table-row:hover {
    background: rgba(25, 118, 210, 0.04) !important;
}

/* Button Enhancements */
.mud-button {
    border-radius: 8px !important;
    text-transform: none !important;
    font-weight: 500 !important;
    letter-spacing: 0 !important;
}

.mud-button-filled.mud-button-primary {
    background: var(--gradient-primary) !important;
}

/* Input Fields */
.mud-input-control {
    border-radius: 8px !important;
}

/* Chip Styling */
.mud-chip {
    border-radius: 8px !important;
}

/* Status Indicators */
.status-online {
    color: #4CAF50;
}

.status-offline {
    color: #F44336;
}

.status-pending {
    color: #FF9800;
}

/* Login Page */
.login-container {
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #FFFFFF;
    border-radius: 24px;
    padding: 48px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-strong);
}

.login-logo {
    width: 80px;
    height: 80px;
    background: var(--gradient-primary);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 24px;
}

/* Device Config Editor */
.config-editor {
    background: var(--bg-surface);
    border-radius: var(--border-radius);
    padding: 24px;
}

.config-item {
    background: var(--bg-surface-alt);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border-light);
    transition: var(--transition-fast);
}

.config-item:hover {
    border-color: rgba(25, 118, 210, 0.3);
    box-shadow: var(--shadow-soft);
}

/* Module Toggle */
.module-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-surface);
    border-radius: 8px;
    margin-bottom: 8px;
    border: 1px solid var(--border-medium);
}

.module-toggle:hover {
    background: var(--bg-surface-alt);
}

/* JSON Editor */
.json-editor {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
    background: #1E1E1E;
    color: #D4D4D4;
    border-radius: 8px;
    padding: 16px;
}

/* Activity List */
.activity-item {
    display: flex;
    align-items: flex-start;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-light);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    flex-shrink: 0;
}

/* Page Header */
.page-header {
    margin-bottom: 32px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
}

.page-header .subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 4px;
}

/* Search Bar */
.search-bar {
    background: var(--bg-surface);
    border-radius: 12px;
    padding: 8px 16px;
    box-shadow: var(--shadow-soft);
}

/* Blazor Error UI */
#blazor-error-ui {
    background: #F44336;
    color: white;
    padding: 0.5rem;
    text-align: center;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 9999;
    display: none;
}

#blazor-error-ui .reload, #blazor-error-ui .dismiss {
    margin: 0 0.5rem;
    color: white;
}

/* Responsive */
@media (max-width: 960px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .login-card {
        margin: 16px;
        padding: 32px;
    }
}

@media (max-width: 600px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .stat-card .stat-value {
        font-size: 1.5rem;
    }
}

/* Dialog Styling */
.mud-dialog {
    border-radius: 16px !important;
}

.mud-dialog .mud-dialog-title {
    padding: 20px 24px 16px;
    border-bottom: 1px solid var(--border-medium);
}

.mud-dialog .mud-dialog-content {
    padding: 24px !important;
}

.mud-dialog .mud-dialog-actions {
    padding: 16px 24px 20px;
    border-top: 1px solid var(--border-medium);
    gap: 12px;
}

/* Form Spacing Improvements */
.mud-input-control {
    margin-bottom: 4px;
}

.mud-select .mud-input-slot {
    min-height: 56px;
}

/* Expansion Panels */
.mud-expand-panel {
    border-radius: 8px !important;
    margin-bottom: 8px;
}

.mud-expand-panel-header {
    min-height: 48px !important;
}

.mud-expand-panel-content {
    padding: 16px !important;
}

/* Tab Panel Improvements */
.mud-tabs .mud-tab {
    min-width: 100px;
    font-weight: 500;
    text-transform: none;
}

.mud-tabs .mud-tabs-panels {
    padding: 16px 0;
}

/* Activity Log Tab Panel */
.activity-tab-panel {
    padding: 20px;
}

/* Activity Log Tabs Header */
.activity-log-tabs .mud-tabs-toolbar {
    min-height: 54px;
    padding: 0 12px;
    border-bottom: 1px solid var(--border-light);
}

.activity-log-tabs .mud-tab {
    min-height: 54px;
    padding: 14px 24px;
    gap: 10px;
    font-size: 0.9rem;
    white-space: nowrap;
}

.activity-log-tabs .mud-tab .mud-icon-root {
    margin-right: 6px;
    flex-shrink: 0;
}

/* Device Card Hover */
.device-card:hover, .site-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-medium);
}

.device-card, .site-card {
    transition: var(--transition-medium);
}

/* Device Config Tabs */
.device-config-tabs .mud-tabs-toolbar {
    min-height: 56px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border-light);
    overflow-x: auto;
    overflow-y: hidden;
}

.device-config-tabs .mud-tab {
    min-height: 56px;
    min-width: 140px;
    padding: 14px 28px;
    gap: 10px;
    font-size: 0.9rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.device-config-tabs .mud-tab .mud-icon-root {
    margin-right: 6px;
    flex-shrink: 0;
}

/* Table Row Clickable */
.device-row {
    cursor: pointer;
    transition: var(--transition-fast);
}

.device-row:hover td {
    background: rgba(25, 118, 210, 0.06) !important;
}

/* Grid Spacing Helper */
.mud-grid.spacing-4 {
    margin: -16px;
}

.mud-grid.spacing-4 > .mud-item {
    padding: 16px;
}

/* Section Headers */
.section-header {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #1976D2;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    background: var(--bg-surface-alt);
    border-radius: 12px;
}

.empty-state .mud-icon-root {
    font-size: 64px;
    color: #BDBDBD;
    margin-bottom: 16px;
}

/* Sticky Save Bar */
.sticky-save-bar {
    position: sticky;
    bottom: 0;
    background: var(--bg-surface);
    padding: 16px 24px;
    border-top: 1px solid var(--border-strong);
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    margin: 24px -24px -24px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    z-index: 10;
}

.mud-theme-dark .sticky-save-bar {
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.4);
}

/* Autocomplete Dropdown */
.mud-autocomplete .mud-popover-paper {
    max-height: 300px;
    overflow-y: auto;
}

/* Loading Overlay */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.mud-theme-dark .loading-overlay {
    background: rgba(18, 18, 18, 0.8);
}

/* ====================================================================
   DARK MODE CONTRAST IMPROVEMENTS
   Ensure all labels, inputs, chips, tabs, tables, and accordion headers
   maintain strong contrast and readability in dark mode.
   ==================================================================== */

/* Input labels: ensure visibility against dark backgrounds */
.mud-theme-dark .mud-input-label {
    color: rgba(255, 255, 255, 0.7) !important;
}

.mud-theme-dark .mud-input-label-inputcontrol {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* Input text readability */
.mud-theme-dark .mud-input > input,
.mud-theme-dark .mud-input textarea,
.mud-theme-dark .mud-input .mud-input-slot {
    color: rgba(255, 255, 255, 0.87) !important;
}

/* Outlined input borders: more visible in dark mode */
.mud-theme-dark .mud-input-outlined .mud-input-outlined-border {
    border-color: rgba(255, 255, 255, 0.23) !important;
}

.mud-theme-dark .mud-input-outlined:hover .mud-input-outlined-border {
    border-color: rgba(255, 255, 255, 0.4) !important;
}

/* Filled input background contrast */
.mud-theme-dark .mud-input.mud-input-filled {
    background: rgba(255, 255, 255, 0.06);
}

/* Select dropdown text */
.mud-theme-dark .mud-select .mud-select-input {
    color: rgba(255, 255, 255, 0.87) !important;
}

/* Chip readability in dark mode */
.mud-theme-dark .mud-chip {
    color: rgba(255, 255, 255, 0.87);
}

.mud-theme-dark .mud-chip.mud-chip-outlined {
    border-color: rgba(255, 255, 255, 0.3);
}

.mud-theme-dark .mud-chip.mud-chip-filled.mud-chip-color-default {
    background-color: rgba(255, 255, 255, 0.12);
    color: rgba(255, 255, 255, 0.87);
}

/* Expansion panel / accordion header readability */
.mud-theme-dark .mud-expand-panel {
    background-color: var(--bg-surface);
    border-color: var(--border-medium);
}

.mud-theme-dark .mud-expand-panel-header .mud-expand-panel-text {
    color: rgba(255, 255, 255, 0.87) !important;
}

.mud-theme-dark .mud-expand-panel-content {
    color: rgba(255, 255, 255, 0.7);
}

/* Tab labels: ensure inactive tabs are readable, active tabs are bright */
.mud-theme-dark .mud-tabs .mud-tab {
    color: rgba(255, 255, 255, 0.6) !important;
}

.mud-theme-dark .mud-tabs .mud-tab:hover {
    color: rgba(255, 255, 255, 0.8) !important;
}

.mud-theme-dark .mud-tabs .mud-tab.mud-tab-active {
    color: #90CAF9 !important;
}

/* Table header contrast */
.mud-theme-dark .mud-table .mud-table-head {
    background: #2D2D2D;
}

.mud-theme-dark .mud-table .mud-table-head .mud-table-cell {
    color: rgba(255, 255, 255, 0.87) !important;
    font-weight: 600;
}

/* Table cell text and borders */
.mud-theme-dark .mud-table .mud-table-body .mud-table-cell {
    color: rgba(255, 255, 255, 0.7);
    border-bottom-color: rgba(255, 255, 255, 0.08);
}

/* Table row hover in dark mode */
.mud-theme-dark .mud-table .mud-table-row:hover {
    background: rgba(144, 202, 249, 0.08) !important;
}

/* Popover / dropdown menu dark mode */
.mud-theme-dark .mud-popover .mud-list {
    background-color: #2D2D2D;
}

.mud-theme-dark .mud-list-item {
    color: rgba(255, 255, 255, 0.87);
}

.mud-theme-dark .mud-list-item:hover {
    background-color: rgba(255, 255, 255, 0.08) !important;
}

/* Dialog title and content */
.mud-theme-dark .mud-dialog .mud-dialog-title {
    color: rgba(255, 255, 255, 0.87);
}

.mud-theme-dark .mud-dialog .mud-dialog-content {
    color: rgba(255, 255, 255, 0.7);
}

/* Section header border */
.mud-theme-dark .section-header {
    border-bottom-color: #64B5F6;
}

/* Popup close button in dark mode */
.mud-theme-dark .maplibregl-popup-close-button {
    color: #b0b0b0;
}

.mud-theme-dark .maplibregl-popup-close-button:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #e0e0e0;
}

/* MapLibre popup border in dark mode */
.mud-theme-dark .maplibregl-popup-content {
    border-color: rgba(255, 255, 255, 0.1) !important;
    background: #1e1e1e;
}

.mud-theme-dark .maplibregl-popup-tip {
    border-top-color: #1e1e1e !important;
}

/* Table Pager Alignment Fix */
.mud-table-pagination {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 16px;
    padding: 8px 16px;
}

.mud-table-pagination .mud-select {
    min-width: 70px;
    margin: 0 !important;
}

.mud-table-pagination .mud-input-control {
    margin-bottom: 0 !important;
    margin-top: 0 !important;
}

/* Fix baseline alignment between label and select */
.mud-table-pagination > * {
    display: flex;
    align-items: center;
}

.mud-table-pagination .mud-typography {
    white-space: nowrap;
    line-height: 1;
}

/* Ensure select input is compact and aligned */
.mud-table-pagination .mud-select .mud-input-slot {
    min-height: 32px !important;
    height: 32px !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

.mud-table-pagination .mud-select .mud-input {
    margin-top: 0 !important;
}

.mud-table-pagination .mud-select .mud-input-label {
    display: none;
}

/* Table Pager Row Height Consistency */
.mud-table tfoot td {
    padding: 0 !important;
    border-top: 1px solid var(--border-medium);
}

.mud-table-pager-actions {
    display: flex;
    align-items: center;
    gap: 4px;
}

/* Pager info text alignment */
.mud-table-pagination .mud-table-pagination-information {
    display: flex;
    align-items: center;
    height: 32px;
}

/* Pager wrapper for consistent styling */
.pager-wrapper {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 8px 16px;
    border-top: 1px solid var(--border-medium);
    background: var(--bg-surface);
}

/* Filter Row Alignment */
.filter-row {
    display: flex;
    align-items: stretch;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-row .mud-input-control,
.filter-row .mud-select,
.filter-row .mud-autocomplete {
    margin-bottom: 0 !important;
}

/* Invalid Module Indicator */
.module-toggle.invalid-module {
    border-color: #FF9800 !important;
    background: rgba(255, 152, 0, 0.05) !important;
}

/* Smooth Transitions */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =====================================================================
   MAP VIEW STYLES
   ===================================================================== */

/* Map Container */
.map-page-container {
    display: flex;
    height: calc(100vh - 180px);
    margin: 0 -24px -24px -24px;
    overflow: hidden;
    position: relative;
    border-radius: var(--border-radius) var(--border-radius) 0 0;
    box-shadow: var(--shadow-soft);
}

.map-sidebar {
    width: 360px;
    min-width: 360px;
    max-width: 360px;
    background: var(--bg-surface);
    border-right: 1px solid var(--border-medium);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 10;
    box-shadow: 2px 0 8px rgba(0,0,0,0.08);
    transition: width 150ms ease-out, min-width 150ms ease-out, max-width 150ms ease-out;
}

.map-sidebar.expanded {
    width: 360px;
    min-width: 360px;
    max-width: 360px;
}

.map-sidebar.collapsed {
    width: 56px;
    min-width: 56px;
    max-width: 56px;
}

.map-sidebar.collapsed .map-sidebar-header {
    padding: 12px 8px;
    justify-content: center;
}

.map-sidebar.collapsed .sidebar-header-row {
    justify-content: center;
}

.map-sidebar.collapsed .sidebar-toggle-btn {
    margin: 0 auto;
}

.mud-theme-dark .map-sidebar {
    box-shadow: 2px 0 8px rgba(0,0,0,0.3);
}

.map-sidebar-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-medium);
    background: var(--bg-surface-alt);
    flex-shrink: 0;
}

.sidebar-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 32px;
}

.sidebar-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-toggle-btn {
    flex-shrink: 0;
}

.sidebar-search {
    transition: opacity 150ms ease;
}

.map-sidebar.collapsed .sidebar-search {
    opacity: 0;
    pointer-events: none;
}

.map-sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.map-main {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
}

.map-toolbar {
    background: var(--bg-surface);
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-medium);
    display: flex;
    align-items: center;
    gap: 12px;
    z-index: 5;
}

.map-container {
    flex: 1;
    position: relative;
    background: var(--bg-surface-alt);
}

#edgeBoxMap {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Device List Items */
.device-list-item {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-light);
    cursor: pointer;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 12px;
}

.device-list-item:hover {
    background: rgba(25, 118, 210, 0.06);
}

.device-list-item.active {
    background: rgba(25, 118, 210, 0.12);
    border-left: 3px solid #1976D2;
}

.device-list-item .status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.device-list-item .status-dot.online {
    background: #4CAF50;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.6);
}

.device-list-item .status-dot.offline {
    background: #F44336;
}

.device-list-item .device-info {
    flex: 1;
    min-width: 0;
}

.device-list-item .device-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-list-item .device-meta {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.device-list-item .location-badge {
    font-size: 16px;
    opacity: 0.6;
}

.device-list-item .location-badge.has-location {
    opacity: 1;
    color: #4CAF50;
}

/* Map Placeholder (for errors/disabled) */
.map-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 48px;
    text-align: center;
    background: var(--bg-surface-alt);
}

.map-placeholder .placeholder-icon {
    font-size: 80px;
    color: #BDBDBD;
    margin-bottom: 24px;
}

.map-placeholder .placeholder-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.map-placeholder .placeholder-text {
    color: var(--text-secondary);
    max-width: 400px;
}

/* Device Details Panel */
.device-details-panel {
    position: absolute;
    right: 20px;
    top: 80px;
    width: 340px;
    background: var(--bg-surface);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-strong);
    z-index: 20;
    overflow: hidden;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

.device-details-header {
    padding: 16px 20px;
    background: var(--bg-surface-alt);
    border-bottom: 1px solid var(--border-medium);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-details-content {
    padding: 20px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
}

.detail-row:last-child {
    border-bottom: none;
}

.detail-label {
    color: var(--text-secondary);
    font-size: 13px;
}

.detail-value {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 13px;
    text-align: right;
}

/* Location Edit Dialog */
.location-edit-map {
    height: 300px;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid var(--border-medium);
    margin-bottom: 16px;
}

.location-pick-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(25, 118, 210, 0.08);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
    color: #1976D2;
}

.coordinate-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}

/* Location Dialog with Embedded Map */
.location-dialog-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 24px;
    min-height: 450px;
}

.location-dialog-map-section {
    display: flex;
    flex-direction: column;
}

.location-dialog-fields-section {
    display: flex;
    flex-direction: column;
}

.location-picker-map {
    flex: 1;
    min-height: 400px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--border-medium);
    background: var(--bg-surface-alt);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.05);
    /* Ensure map is interactive in dialog */
    position: relative;
    z-index: 1;
}

/* Ensure MapLibre canvas is interactive */
.location-picker-map .maplibregl-canvas-container,
.location-picker-map .maplibregl-canvas {
    pointer-events: auto !important;
}

/* Ensure markers are interactive above map */
.location-picker-map .maplibregl-marker {
    pointer-events: auto !important;
    z-index: 10 !important;
}

.location-picker-map canvas {
    border-radius: 10px;
}

/* Responsive layout for smaller screens */
@media (max-width: 900px) {
    .location-dialog-layout {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .location-picker-map {
        min-height: 300px;
    }

    .location-dialog-fields-section {
        order: -1;
    }
}

/* Map Marker Pulse Animation */
@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.6); }
    70% { box-shadow: 0 0 0 12px rgba(33, 150, 243, 0); }
    100% { box-shadow: 0 0 0 0 rgba(33, 150, 243, 0); }
}

/* Pick Mode Button Animation */
.pick-mode-btn {
    position: relative;
    overflow: hidden;
}

.pick-mode-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(circle, rgba(255,255,255,0.3) 0%, transparent 60%);
    transform: translate(-50%, -50%) scale(0);
    transition: transform 0.5s ease;
}

.pick-mode-btn:hover::after {
    transform: translate(-50%, -50%) scale(1);
}

/* ====================================================================
   LUXURY MAP MARKER & POPUP STYLING
   ==================================================================== */

/* Custom Map Marker - Circle Style */
.map-marker-custom {
    transition: filter 0.15s ease-out;
}

.map-marker-custom.marker-hover {
    filter: brightness(1.2) drop-shadow(0 4px 8px rgba(0,0,0,0.4));
}

/* Map Pin Marker - SVG drop-pin style */
.map-pin-marker {
    filter: drop-shadow(0 3px 4px rgba(0,0,0,0.3));
    transition: filter 0.15s ease-out;
}

.map-pin-marker.marker-hover {
    filter: brightness(1.1) drop-shadow(0 6px 8px rgba(0,0,0,0.4));
}

/* ====================================================================
   MAP MARKER POSITIONING PROTECTION
   MapLibre uses inline transform on marker elements for positioning.
   CSS must never transition or override transform on these elements.
   ==================================================================== */
.maplibregl-marker,
.leaflet-marker-icon,
.leaflet-marker-shadow {
    transition: filter 0.15s ease-out !important;
}

/* Leaflet-specific: ensure absolute positioning and no hover transforms */
.leaflet-marker-icon,
.leaflet-marker-shadow {
    position: absolute !important;
}

.leaflet-marker-icon:hover,
.leaflet-marker-shadow:hover {
    transform: none !important;
}

/* Marker pulse animation for pick/selection */
.marker-pulse svg path:first-child {
    animation: marker-pulse 1.5s infinite;
}

@keyframes marker-pulse {
    0%, 100% {
        filter: drop-shadow(0 0 0 rgba(33, 150, 243, 0.6));
    }
    50% {
        filter: drop-shadow(0 0 12px rgba(33, 150, 243, 0.8));
    }
}

/* MapLibre Popup - Luxury Styling */
.maplibregl-popup-content {
    border-radius: 12px !important;
    padding: 0 !important;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.1) !important;
    border: 1px solid rgba(255,255,255,0.8) !important;
    overflow: hidden;
}

.luxury-popup .maplibregl-popup-content {
    border-radius: 14px !important;
}

.maplibregl-popup-tip {
    border-top-color: white !important;
}

.maplibregl-popup-close-button {
    font-size: 20px;
    padding: 6px 10px;
    color: #888;
    border-radius: 0 12px 0 8px;
    transition: all 0.15s ease;
}

.maplibregl-popup-close-button:hover {
    background: #f5f5f5;
    color: #333;
}

/* Popup Card Content */
.map-popup-card {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    padding: 18px 20px;
    min-width: 260px;
}

.map-popup-header {
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eef0f2;
}

.map-popup-title {
    font-weight: 600;
    font-size: 16px;
    color: #1565C0;
    display: block;
}

.map-popup-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.map-popup-status .status-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--status-color);
    box-shadow: 0 0 8px var(--status-color);
}

.map-popup-status .status-text {
    font-size: 13px;
    font-weight: 600;
    color: var(--status-color);
}

.map-popup-detail {
    font-size: 13px;
    color: #555;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.map-popup-detail strong {
    color: #333;
}

.map-popup-timestamp {
    font-size: 11px;
    color: #999;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eef0f2;
    margin-bottom: 14px;
}

.map-popup-actions {
    display: flex;
    gap: 10px;
}

.map-popup-btn {
    flex: 1;
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.map-popup-btn-outline {
    background: white;
    color: #1976D2;
    border: 1.5px solid #1976D2;
}

.map-popup-btn-outline:hover {
    background: #E3F2FD;
    border-color: #1565C0;
}

.map-popup-btn-primary {
    background: linear-gradient(135deg, #1976D2 0%, #1565C0 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.3);
}

.map-popup-btn-primary:hover {
    background: linear-gradient(135deg, #1565C0 0%, #0D47A1 100%);
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.4);
    transform: translateY(-1px);
}

/* Legacy map-popup class (backwards compat) */
.map-popup {
    padding: 12px 16px;
}

/* Stats Row in Map Sidebar */
.map-stats-row {
    display: flex;
    gap: 8px;
    padding: 12px 20px;
    background: var(--bg-surface-alt);
    border-bottom: 1px solid var(--border-medium);
}

.map-stat {
    flex: 1;
    text-align: center;
    padding: 8px;
    border-radius: 8px;
    background: var(--bg-surface);
}

.map-stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.map-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.map-stat.online .map-stat-value { color: #4CAF50; }
.map-stat.offline .map-stat-value { color: #F44336; }

/* Responsive Map */
@media (max-width: 960px) {
    .map-sidebar.expanded {
        width: 280px;
        min-width: 280px;
        max-width: 280px;
    }

    .map-sidebar.collapsed {
        width: 56px;
        min-width: 56px;
        max-width: 56px;
    }

    .device-details-panel {
        width: 300px;
        right: 10px;
    }
}

@media (max-width: 768px) {
    .map-page-container {
        flex-direction: column;
    }

    .map-sidebar,
    .map-sidebar.expanded,
    .map-sidebar.collapsed {
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        height: auto;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-medium);
    }

    .map-sidebar.collapsed {
        max-height: 56px;
    }

    .map-sidebar-content {
        display: flex;
        overflow-x: auto;
    }

    .device-list-item {
        flex-direction: column;
        min-width: 160px;
        text-align: center;
    }

    .device-details-panel {
        position: fixed;
        left: 10px;
        right: 10px;
        bottom: 10px;
        top: auto;
        width: auto;
    }
}
