:root {
    --primary: #667eea;
    --secondary: #2d3748;
    --bg: #f4f7f6;
    --card-bg: white;
    --text: #2d3748;
    --border: #e2e8f0;
    --online: #38a169;
    --offline: #a0aec0;
    --text-secondary: #718096;
}

body { margin: 0; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: var(--bg); color: var(--text); transition: 0.3s; overflow: hidden; }

.dark-theme { 
    --primary: #7f9cf5;
    --secondary: #171923;
    --bg: #1a202c;
    --card-bg: #2d3748;
    --text: #edf2f7;
    --border: #4a5568;
    --text-secondary: #a0aec0;
}

/* Auth & Modals */
.auth-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.8); z-index: 20000; display: flex; align-items: center; justify-content: center; }
.auth-card { background: var(--card-bg); padding: 2rem; border-radius: 8px; width: 320px; box-shadow: 0 4px 15px rgba(0,0,0,0.3); }
.auth-card h2 { margin-top: 0; }
.auth-card input, .auth-card select, .auth-card textarea { width: 100%; margin-bottom: 1rem; padding: 12px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg); color: var(--text); box-sizing: border-box; }

/* Ensure select dropdowns work in dark mode */
select, input[type="color"] { 
    background: var(--bg); 
    color: var(--text); 
    border: 1px solid var(--border); 
}

/* Ensure all text inputs inherit theme colors */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="search"],
input[type="number"] {
    color: var(--text);
}

select option {
    background: var(--card-bg);
    color: var(--text);
}

textarea {
    font-family: inherit;
    resize: vertical;
}

.btn { padding: 8px 16px; border: none; border-radius: 4px; cursor: pointer; font-weight: bold; transition: 0.3s; font-size: 0.9rem; }
.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--online); color: white; }
.btn-danger { background: #e53e3e; color: white; }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn:hover { filter: brightness(1.1); }

/* Navigation */
.navbar { background: var(--secondary); color: white; padding: 0.8rem 1.5rem; display: flex; justify-content: space-between; align-items: center; height: 60px; box-sizing: border-box; }
.nav-brand { display: flex; align-items: center; gap: 10px; font-weight: bold; font-size: 1.2rem; }
.nav-links { display: flex; gap: 20px; }
.nav-item { cursor: pointer; opacity: 0.8; transition: 0.2s; padding: 5px 10px; border-radius: 4px; }
.nav-item:hover, .nav-item.active { opacity: 1; background: rgba(255,255,255,0.1); }

.status-bar { background: var(--border); padding: 0.4rem 1.5rem; display: flex; gap: 25px; font-size: 0.8rem; border-bottom: 1px solid var(--border); height: 40px; align-items: center; box-sizing: border-box; }

/* Layout */
.main-container { display: flex; height: calc(100vh - 100px); overflow: hidden; }
#map { flex: 1; margin: 10px; border-radius: 8px; box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.sidebar { width: 350px; background: var(--card-bg); margin: 10px 10px 10px 0; border-radius: 8px; padding: 20px; overflow-y: auto; box-shadow: 0 2px 10px rgba(0,0,0,0.1); display: flex; flex-direction: column; }

/* Dashboard Components */
.fleet-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 20px; }
.stat-card { background: var(--bg); padding: 10px; border-radius: 6px; text-align: center; border: 1px solid var(--border); }
.stat-value { font-size: 1.3rem; font-weight: bold; color: var(--primary); }
.stat-label { font-size: 0.65rem; color: #718096; text-transform: uppercase; }

.asset-item { padding: 15px; border-bottom: 1px solid var(--border); cursor: pointer; transition: 0.2s; }
.asset-item:hover { background: var(--bg); }
.asset-name { font-weight: bold; margin-bottom: 5px; }
.asset-details { font-size: 0.75rem; color: #718096; line-height: 1.5; }
.mileage-tag { font-weight: bold; color: var(--primary); }

/* Admin View classes */
.admin-sidebar { width: 240px; background: var(--secondary); color: white; display: flex; flex-direction: column; padding: 20px 0; }
.admin-nav-item { padding: 12px 25px; cursor: pointer; transition: 0.2s; border-left: 4px solid transparent; color: rgba(255,255,255,0.7); font-size: 0.9rem; }
.admin-nav-item:hover { background: rgba(255,255,255,0.05); color: white; }
.admin-nav-item.active { background: rgba(255,255,255,0.1); border-left-color: var(--primary); color: white; }
.admin-content { flex: 1; padding: 40px; overflow-y: auto; background: var(--bg); }

.data-table { width: 100%; border-collapse: collapse; background: var(--card-bg); border-radius: 8px; overflow: hidden; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
.data-table th { text-align: left; padding: 15px; background: var(--border); font-size: 0.85rem; color: #718096; }
.data-table td { padding: 15px; border-top: 1px solid var(--border); font-size: 0.9rem; }

.tag { padding: 3px 8px; border-radius: 12px; font-size: 0.7rem; font-weight: bold; text-transform: uppercase; }
.tag-active { background: #c6f6d5; color: #2f855a; }
.tag-suspended { background: #fed7d7; color: #c53030; }

/* Map Pins */
.marker-pin {
    width: 30px;
    height: 30px;
    border-radius: 50% 50% 50% 0;
    position: absolute;
    transform: rotate(-45deg);
    left: 50%;
    top: 50%;
    margin: -15px 0 0 -15px;
    border: 2px solid #fff;
    box-shadow: 0 0 4px rgba(0,0,0,0.5);
}
.pin-online { background: var(--online); }
.pin-offline { background: var(--offline); }

/* Admin Panel specific styles */
.admin-panel { }
.admin-panel.active { display: block; }

.panel-header { 
    display: flex; 
    justify-content: space-between; 
    align-items: center; 
    margin-bottom: 20px; 
}

.panel-header h2 { margin: 0; }

.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.filter-select {
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text);
}

.pagination-container {
    margin-top: 15px;
    text-align: center;
}

.pagination-info {
    margin-top: 10px;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Modal specific */
.modal-wide { width: 450px; }
.modal-extra-wide { width: 550px; max-height: 90vh; overflow-y: auto; }

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.form-label {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

.color-picker-group {
    display: flex;
    gap: 5px;
    align-items: center;
}

.color-picker-input {
    width: 50px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
}

.color-hex-input {
    flex: 1;
    padding: 8px;
}

/* Profile card */
.profile-card {
    width: 100%;
    max-width: none;
    box-shadow: none;
    border: 1px solid var(--border);
}

/* Profile grid layout for efficient screen utilization */
.profile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 24px;
}

.profile-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

@media (max-width: 900px) {
    .profile-grid-2 {
        grid-template-columns: 1fr;
    }
}

/* Profile section styling */
.profile-section {
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.profile-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.profile-section h3 {
    margin: 0 0 12px 0;
    font-size: 1rem;
    color: var(--primary);
    font-weight: 600;
}

.profile-field {
    display: flex;
    margin-bottom: 8px;
    align-items: baseline;
}

.profile-label {
    font-weight: 600;
    color: var(--text-secondary);
    min-width: 140px;
    flex-shrink: 0;
}

.profile-value {
    color: var(--text);
}

.json-display {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 10px;
    font-family: 'Courier New', monospace;
    font-size: 0.85rem;
    color: var(--text);
    overflow-x: auto;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
}

.form-group {
    margin-bottom: 15px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    box-sizing: border-box;
    font-family: inherit;
}

/* Nav link inherit */
.nav-link-inherit {
    color: inherit;
    text-decoration: none;
}

/* Button variants */
.btn-nav {
    padding: 4px 8px;
}

.btn-nav-theme {
    border-color: rgba(255,255,255,0.3);
    color: white;
}

.btn-nav-logout {
    background: rgba(255,255,255,0.2);
}

.btn-action-sm {
    padding: 4px 8px;
    font-size: 0.75rem;
    margin-right: 5px;
}

.btn-delete {
    color: #EF4444;
    border-color: #EF4444;
}

.btn-action-manage {
    padding: 4px 8px;
    font-size: 0.7rem;
}

/* Table column widths */
.col-icon { width: 30px; }

/* Reports & Metrics */
.reports-metrics {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border);
    transition: transform 0.2s, box-shadow 0.2s;
}

.metric-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.metric-value {
    font-size: 2.5rem;
    font-weight: bold;
    color: var(--primary);
}

.metric-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* Chart containers */
.chart-container {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.chart-title {
    margin: 0 0 15px 0;
    font-size: 1rem;
    font-weight: 600;
}

.chart-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

/* User management styles */
.user-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.user-badge-admin {
    background: #FED7E2;
    color: #97266D;
}

.user-badge-manager {
    background: #C6F6D5;
    color: #276749;
}

.user-badge-viewer {
    background: #E2E8F0;
    color: #4A5568;
}

/* Modal improvements */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

/* Status indicators */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot-active { background: #38a169; }
.status-dot-inactive { background: #a0aec0; }
.status-dot-suspended { background: #E53E3E; }

/* Button color variants */
.btn-purple {
    color: #805AD5;
    border-color: #805AD5;
}

.btn-purple:hover {
    background: #805AD5;
    color: white;
}

@media (max-width: 900px) {
    .sidebar { width: 100%; position: absolute; bottom: 0; height: 40%; z-index: 1000; margin: 0; border-radius: 20px 20px 0 0; }
    
    .reports-metrics {
        grid-template-columns: 1fr;
    }
}

/* Map Layer Switcher Styles */
.layer-switcher {
    background: transparent !important;
    box-shadow: none !important;
}

.layer-switcher-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.layer-switcher-btn:hover {
    background: var(--bg);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.layer-switcher-btn.active {
    background: var(--primary);
    color: white;
}

.layer-switcher-menu {
    position: absolute;
    top: 50px;
    right: 0;
    min-width: 180px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    padding: 8px 0;
    display: none;
    flex-direction: column;
    z-index: 1000;
    border: 1px solid var(--border);
}

.layer-switcher-menu.show {
    display: flex;
}

.layer-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background 0.15s ease;
    color: var(--text);
    font-size: 0.9rem;
}

.layer-option:hover {
    background: var(--bg);
}

.layer-option.active {
    background: var(--primary);
    color: white;
}

.layer-option.active:hover {
    background: var(--primary);
    filter: brightness(1.1);
}

.layer-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.layer-name {
    white-space: nowrap;
}

/* Mobile responsiveness for layer switcher */
@media (max-width: 768px) {
    .layer-switcher-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
    
    .layer-switcher-menu {
        min-width: 160px;
        right: -10px;
    }
    
    .layer-option {
        padding: 12px 16px;
        font-size: 0.95rem;
    }
}

/* Dark theme adjustments for layer switcher */
.dark-theme .layer-switcher-btn {
    background: var(--card-bg);
    border: 1px solid var(--border);
}

.dark-theme .layer-switcher-menu {
    background: var(--card-bg);
    border-color: var(--border);
}

.dark-theme .layer-option:hover {
    background: var(--bg);
}

/* Leaflet control positioning adjustment */
.leaflet-top.leaflet-right {
    top: 10px !important;
    right: 10px !important;
}

/* Ensure layer switcher appears above other controls */
.layer-switcher {
    z-index: 1000;
}

/* ==================== ALERT STYLES ==================== */

/* Alert Badge */
.alert-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e53e3e;
    color: white;
    font-size: 0.7rem;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

/* Alert Toast Notifications */
.alert-toast {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 350px;
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    border-left: 4px solid var(--primary);
    z-index: 10000;
    animation: slideIn 0.3s ease;
    overflow: hidden;
}

.alert-toast-info { border-left-color: #4299e1; }
.alert-toast-warning { border-left-color: #ed8936; }
.alert-toast-critical { border-left-color: #e53e3e; }

@keyframes slideIn {
    from { transform: translateX(400px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.alert-toast-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
}

.alert-toast-icon {
    font-size: 1.2rem;
}

.alert-toast-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.95rem;
}

.alert-toast-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}

.alert-toast-close:hover {
    color: var(--text);
}

.alert-toast-body {
    padding: 12px 15px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.alert-toast-actions {
    display: flex;
    gap: 10px;
    padding: 0 15px 15px;
}

/* Alert List Container */
.alerts-container {
    display: flex;
    height: calc(100vh - 200px);
    gap: 20px;
}

.alerts-list {
    width: 400px;
    background: var(--card-bg);
    border-radius: 8px;
    overflow-y: auto;
    border: 1px solid var(--border);
}

.alerts-detail {
    flex: 1;
    background: var(--card-bg);
    border-radius: 8px;
    padding: 20px;
    border: 1px solid var(--border);
    overflow-y: auto;
}

/* Alert Filters */
.alert-filters {
    display: flex;
    gap: 10px;
    padding: 15px;
    border-bottom: 1px solid var(--border);
    background: var(--bg);
}

.alert-filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--card-bg);
    color: var(--text);
    font-size: 0.85rem;
}

/* Alert Items */
.alert-item {
    padding: 15px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.alert-item:hover {
    background: var(--bg);
}

.alert-item-selected {
    background: rgba(102, 126, 234, 0.1);
    border-left: 3px solid var(--primary);
}

.alert-item-unread {
    background: rgba(102, 126, 234, 0.05);
}

.alert-item-unread::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
}

.alert-item-info { border-left: 3px solid #4299e1; }
.alert-item-warning { border-left: 3px solid #ed8936; }
.alert-item-critical { border-left: 3px solid #e53e3e; }

.alert-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 0.8rem;
}

.alert-item-icon {
    font-size: 1rem;
}

.alert-item-type {
    color: var(--text-secondary);
    text-transform: uppercase;
    font-weight: 600;
    flex: 1;
}

.alert-item-severity {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: bold;
    text-transform: uppercase;
}

.alert-severity-info { background: #bee3f8; color: #2b6cb0; }
.alert-severity-warning { background: #feebc8; color: #c05621; }
.alert-severity-critical { background: #fed7d7; color: #c53030; }

.alert-item-time {
    color: var(--text-secondary);
}

.alert-item-content {
    margin-bottom: 8px;
}

.alert-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.alert-item-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.alert-item-geofence {
    font-size: 0.8rem;
    color: var(--primary);
    margin-top: 4px;
}

.alert-item-location {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.alert-item-actions {
    display: flex;
    gap: 8px;
}

/* Alert Empty State */
.alerts-empty {
    text-align: center;
    padding: 60px 40px;
    color: var(--text-secondary);
}

.alerts-empty-icon {
    font-size: 4rem;
    margin-bottom: 20px;
}

/* Alert Detail View */
.alert-detail {
    max-width: 600px;
}

.alert-detail-header {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.alert-detail-icon {
    font-size: 2rem;
}

.alert-detail-title {
    flex: 1;
}

.alert-detail-title h3 {
    margin: 0 0 5px 0;
    font-size: 1.2rem;
}

.alert-detail-time {
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.alert-detail-section {
    margin-bottom: 25px;
}

.alert-detail-section h4 {
    margin: 0 0 12px 0;
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-transform: uppercase;
}

.alert-detail-field {
    display: flex;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.alert-detail-label {
    min-width: 120px;
    color: var(--text-secondary);
}

.alert-detail-value {
    font-weight: 500;
}

.alert-detail-map {
    height: 250px;
    border-radius: 8px;
    margin: 15px 0;
    border: 1px solid var(--border);
}

.alert-detail-actions {
    display: flex;
    gap: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

/* Alert Statistics */
.alert-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
    margin-bottom: 25px;
}

.alert-stat-card {
    background: var(--bg);
    padding: 20px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border);
}

.alert-stat-active {
    background: rgba(229, 62, 62, 0.1);
    border-color: #e53e3e;
}

.alert-stat-value {
    font-size: 2rem;
    font-weight: bold;
    color: var(--primary);
}

.alert-stat-active .alert-stat-value {
    color: #e53e3e;
}

.alert-stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

.alert-breakdown {
    background: var(--bg);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.alert-breakdown h4 {
    margin: 0 0 15px 0;
    font-size: 0.95rem;
}

.alert-breakdown-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

.alert-breakdown-type {
    color: var(--text-secondary);
}

.alert-breakdown-count {
    font-weight: 600;
}

/* Alert Markers on Map */
.alert-marker-icon {
    position: relative;
}

.alert-marker-pin {
    width: 36px;
    height: 36px;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    border: 2px solid white;
}

.alert-marker-symbol {
    transform: rotate(45deg);
    font-size: 1rem;
}

.alert-pulse-icon {
    position: relative;
}

.alert-pulse {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid;
    animation: pulse 2s infinite;
    opacity: 0.6;
}

@keyframes pulse {
    0% { transform: scale(0.5); opacity: 0.6; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Alert Popup */
.alert-popup {
    min-width: 200px;
}

.alert-popup-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    font-weight: 600;
}

.alert-popup-icon {
    font-size: 1.2rem;
}

.alert-popup-body {
    font-size: 0.9rem;
    margin-bottom: 10px;
}

.alert-popup-body p {
    margin: 4px 0;
}

.alert-popup-actions {
    display: flex;
    gap: 8px;
}

/* General Notifications */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 15px 25px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 10000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
}

.notification.show {
    transform: translateY(0);
    opacity: 1;
}

.notification-success { background: #38a169; }
.notification-error { background: #e53e3e; }
.notification-info { background: #4299e1; }

/* Small button variant */
.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

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

/* Display utilities */
.d-none { display: none !important; }
.d-flex { display: flex !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }
.d-grid { display: grid !important; }
.d-contents { display: contents !important; }

/* Width utilities */
.w-100 { width: 100% !important; }
.w-50 { width: 50% !important; }
.w-auto { width: auto !important; }
.w-50px { width: 50px !important; }
.w-150px { width: 150px !important; }
.w-320px { width: 320px !important; }
.w-450px { width: 450px !important; }
.w-550px { width: 550px !important; }

/* Height utilities */
.h-100 { height: 100% !important; }
.h-auto { height: auto !important; }
.h-38px { height: 38px !important; }

/* Margin utilities */
.m-0 { margin: 0 !important; }
.m-5 { margin: 5px !important; }
.m-10 { margin: 10px !important; }
.m-15 { margin: 15px !important; }
.m-20 { margin: 20px !important; }
.m-30 { margin: 30px !important; }

.mt-5 { margin-top: 5px !important; }
.mt-10 { margin-top: 10px !important; }
.mt-15 { margin-top: 15px !important; }
.mt-20 { margin-top: 20px !important; }

.mb-0 { margin-bottom: 0 !important; }
.mb-5 { margin-bottom: 5px !important; }
.mb-8 { margin-bottom: 8px !important; }
.mb-10 { margin-bottom: 10px !important; }
.mb-15 { margin-bottom: 15px !important; }
.mb-20 { margin-bottom: 20px !important; }
.mb-25 { margin-bottom: 25px !important; }
.mb-30 { margin-bottom: 30px !important; }

.mr-5 { margin-right: 5px !important; }
.mr-8 { margin-right: 8px !important; }

.ml-auto { margin-left: auto !important; }
.mr-auto { margin-right: auto !important; }
.mx-auto { margin-left: auto !important; margin-right: auto !important; }

/* Padding utilities */
.p-0 { padding: 0 !important; }
.p-4 { padding: 4px !important; }
.p-6 { padding: 6px !important; }
.p-8 { padding: 8px !important; }
.p-10 { padding: 10px !important; }
.p-12 { padding: 12px !important; }
.p-15 { padding: 15px !important; }
.p-20 { padding: 20px !important; }
.p-25 { padding: 25px !important; }
.p-40 { padding: 40px !important; }
.p-60 { padding: 60px !important; }

.px-8 { padding-left: 8px !important; padding-right: 8px !important; }
.px-10 { padding-left: 10px !important; padding-right: 10px !important; }
.px-15 { padding-left: 15px !important; padding-right: 15px !important; }
.px-25 { padding-left: 25px !important; padding-right: 25px !important; }
.px-40 { padding-left: 40px !important; padding-right: 40px !important; }

.py-8 { padding-top: 8px !important; padding-bottom: 8px !important; }
.py-10 { padding-top: 10px !important; padding-bottom: 10px !important; }
.py-12 { padding-top: 12px !important; padding-bottom: 12px !important; }
.py-15 { padding-top: 15px !important; padding-bottom: 15px !important; }
.py-20 { padding-top: 20px !important; padding-bottom: 20px !important; }

.pb-15 { padding-bottom: 15px !important; }
.pb-20 { padding-bottom: 20px !important; }
.pb-25 { padding-bottom: 25px !important; }

/* Flexbox utilities */
.flex-1 { flex: 1 !important; }
.flex-row { flex-direction: row !important; }
.flex-column { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }

.justify-start { justify-content: flex-start !important; }
.justify-end { justify-content: flex-end !important; }
.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }
.justify-around { justify-content: space-around !important; }

.align-start { align-items: flex-start !important; }
.align-end { align-items: flex-end !important; }
.align-center { align-items: center !important; }
.align-baseline { align-items: baseline !important; }
.align-stretch { align-items: stretch !important; }

.gap-5 { gap: 5px !important; }
.gap-6 { gap: 6px !important; }
.gap-8 { gap: 8px !important; }
.gap-10 { gap: 10px !important; }
.gap-15 { gap: 15px !important; }
.gap-20 { gap: 20px !important; }
.gap-25 { gap: 25px !important; }

/* Grid utilities */
.grid-2 { grid-template-columns: repeat(2, 1fr) !important; }
.grid-3 { grid-template-columns: repeat(3, 1fr) !important; }
.grid-4 { grid-template-columns: repeat(4, 1fr) !important; }

/* Text utilities */
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

.text-primary { color: var(--primary) !important; }
.text-secondary { color: var(--text-secondary) !important; }
.text-success { color: var(--online) !important; }
.text-danger { color: #e53e3e !important; }
.text-white { color: white !important; }
.text-inherit { color: inherit !important; }

.text-bold { font-weight: bold !important; }
.text-semibold { font-weight: 600 !important; }
.text-500 { font-weight: 500 !important; }
.text-normal { font-weight: normal !important; }

.text-xs { font-size: 0.7rem !important; }
.text-sm { font-size: 0.75rem !important; }
.text-sm2 { font-size: 0.8rem !important; }
.text-sm3 { font-size: 0.85rem !important; }
.text-base { font-size: 0.9rem !important; }
.text-md { font-size: 0.95rem !important; }
.text-lg { font-size: 1rem !important; }
.text-xl { font-size: 1.1rem !important; }
.text-2xl { font-size: 1.2rem !important; }
.text-4xl { font-size: 2rem !important; }

.text-uppercase { text-transform: uppercase !important; }
.text-capitalize { text-transform: capitalize !important; }
.text-none { text-transform: none !important; }

.text-no-decoration { text-decoration: none !important; }

/* Line height utilities */
.leading-1 { line-height: 1 !important; }
.leading-1-5 { line-height: 1.5 !important; }

/* Background utilities */
.bg-card { background: var(--card-bg) !important; }
.bg-primary { background: var(--primary) !important; }
.bg-secondary { background: var(--bg) !important; }
.bg-transparent { background: transparent !important; }

/* Border utilities */
.border { border: 1px solid var(--border) !important; }
.border-none { border: none !important; }
.border-left-primary { border-left: 3px solid var(--primary) !important; }
.border-left-4-primary { border-left: 4px solid var(--primary) !important; }

.rounded { border-radius: 4px !important; }
.rounded-6 { border-radius: 6px !important; }
.rounded-8 { border-radius: 8px !important; }
.rounded-full { border-radius: 50% !important; }

/* Cursor utilities */
.cursor-pointer { cursor: pointer !important; }
.cursor-default { cursor: default !important; }

/* Overflow utilities */
.overflow-hidden { overflow: hidden !important; }
.overflow-auto { overflow: auto !important; }
.overflow-y-auto { overflow-y: auto !important; }
.overflow-x-auto { overflow-x: auto !important; }

/* Position utilities */
.relative { position: relative !important; }
.absolute { position: absolute !important; }
.fixed { position: fixed !important; }

/* Resize utilities */
.resize-vertical { resize: vertical !important; }

/* Min/Max utilities */
.min-w-180 { min-width: 180px !important; }
.min-w-200 { min-width: 200px !important; }
.max-w-600 { max-width: 600px !important; }
.max-h-90vh { max-height: 90vh !important; }

/* Box sizing */
.box-border { box-sizing: border-box !important; }

/* Z-index utilities */
.z-100 { z-index: 100 !important; }
.z-1000 { z-index: 1000 !important; }

/* ==================== COMMON COMPONENT PATTERNS ==================== */

/* Form input standard */
.form-input {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    box-sizing: border-box;
}

.form-input-sm {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg);
    color: var(--text);
    box-sizing: border-box;
}

.form-input-secondary {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary, var(--bg));
    color: var(--text);
    box-sizing: border-box;
}

.form-input-secondary-sm {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-secondary, var(--bg));
    color: var(--text);
    box-sizing: border-box;
}

/* Form label standard */
.form-label-std {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

/* Section title standard */
.section-title {
    margin: 0 0 15px 0;
    color: var(--text-primary, var(--text));
}

/* Panel header standard */
.panel-header-std {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

/* Empty state standard */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-state-lg {
    text-align: center;
    padding: 60px 40px;
    color: var(--text-secondary);
}

/* Card container */
.card-container {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.card-container-lg {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 8px;
    border: 1px solid var(--border);
}

.card-metric {
    background: var(--card-bg);
    padding: 25px;
    border-radius: 8px;
    text-align: center;
    border: 1px solid var(--border);
}

/* Form grid layouts */
.form-grid-2-10 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.form-grid-2-15 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Selectable item */
.selectable-item {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.selectable-item-box {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    padding: 8px 12px;
    background: var(--bg);
    border-radius: 4px;
    border: 1px solid var(--border);
}

.selectable-item-box-sm {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    padding: 6px 10px;
    background: var(--bg);
    border-radius: 4px;
    border: 1px solid var(--border);
    font-size: 0.85rem;
}

/* Button group */
.btn-group {
    display: flex;
    gap: 10px;
}

.btn-group-sm {
    display: flex;
    gap: 5px;
}

/* Section divider */
.section-divider {
    margin-bottom: 30px;
    padding-bottom: 25px;
    border-bottom: 1px solid var(--border);
}

.section-divider-sm {
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

/* Help text */
.help-text {
    display: block;
    margin-top: 5px;
    color: var(--text-secondary);
}

/* Nav link */
.nav-link {
    color: inherit;
    text-decoration: none;
}

/* Color picker input */
.color-picker {
    width: 50px;
    height: 38px;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
}

/* Modal sizes */
.modal-width-450 {
    width: 450px;
}

.modal-width-550 {
    width: 550px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Form row */
.form-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Page subtitle */
.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-top: 5px;
}

/* Asset info row */
.asset-info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

/* List group */
.list-group-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    border-bottom: 1px solid var(--border);
}

/* Toast slide out animation */
@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(400px); opacity: 0; }
}

.slide-out {
    animation: slideOut 0.3s ease forwards;
}

/* ==================== ALERT CONFIGURATION STYLES ==================== */

/* Alert Config Tab Buttons */
.alert-tab-btn {
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.alert-tab-btn:hover {
    background: var(--bg);
    color: var(--text);
}

.alert-tab-btn.active {
    background: var(--primary);
    color: white;
}

/* Alert Config Tab Content */
.alert-config-tab {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form Sections */
.form-section {
    margin-bottom: 25px;
}

.form-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text);
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

/* Toggle Switch */
.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: relative;
    cursor: pointer;
    display: inline-block;
}

/* Alert Rule Cards */
.alert-rule-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    transition: box-shadow 0.2s ease;
}

.alert-rule-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.alert-rule-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.alert-rule-title {
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--text);
}

.alert-rule-meta {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Alert Category Cards */
.alert-category-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.alert-category-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.alert-category-icon {
    font-size: 2rem;
    margin-bottom: 12px;
}

.alert-category-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: inline-block;
}

/* Alert Types Grid */
.alert-type-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 15px;
    text-align: center;
    transition: all 0.2s ease;
}

.alert-type-item:hover {
    border-color: var(--primary);
    background: var(--card-bg);
}

.alert-type-icon {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

.alert-type-name {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 4px;
}

.alert-type-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Severity Tags */
.tag-severity-info {
    background: #DBEAFE;
    color: #1E40AF;
    border: 1px solid #3B82F6;
}

.tag-severity-warning {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #F59E0B;
}

.tag-severity-critical {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #EF4444;
}

/* Status Toggle in Tables */
.table-status-toggle {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
}

.table-status-toggle input {
    display: none;
}

.table-status-toggle .toggle-slider {
    width: 40px;
    height: 20px;
    background: var(--offline);
    border-radius: 10px;
    position: relative;
    transition: background 0.3s ease;
}

.table-status-toggle .toggle-slider::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.table-status-toggle input:checked + .toggle-slider {
    background: var(--online);
}

.table-status-toggle input:checked + .toggle-slider::after {
    transform: translateX(20px);
}

/* Dark Theme Adjustments for Alert Config */
.dark-theme .alert-rule-card,
.dark-theme .alert-category-card,
.dark-theme .alert-type-item {
    background: var(--bg);
}

.dark-theme .tag-severity-info {
    background: rgba(59, 130, 246, 0.2);
    color: #93C5FD;
    border-color: #3B82F6;
}

.dark-theme .tag-severity-warning {
    background: rgba(245, 158, 11, 0.2);
    color: #FCD34D;
    border-color: #F59E0B;
}

.dark-theme .tag-severity-critical {
    background: rgba(239, 68, 68, 0.2);
    color: #FCA5A5;
    border-color: #EF4444;
}

/* Additional utility classes for refactoring */

/* Margin utilities (additional) */
.mx-2 { margin-left: 2px !important; margin-right: 2px !important; }
.mt-30 { margin-top: 30px !important; }

/* Padding utilities (additional) */
.px-12 { padding-left: 12px !important; padding-right: 12px !important; }
.px-16 { padding-left: 16px !important; padding-right: 16px !important; }
.py-4 { padding-top: 4px !important; padding-bottom: 4px !important; }

/* Flex wrap */
.flex-wrap { flex-wrap: wrap !important; }
.flex-nowrap { flex-wrap: nowrap !important; }

/* Grid column span */
.col-span-full { grid-column: 1 / -1 !important; }

/* Text color utilities */
.text-purple { color: #805AD5 !important; }
.text-danger { color: #E53E3E !important; }
.text-warning { color: #D69E2E !important; }
.text-nowrap { white-space: nowrap !important; }

/* Margin auto */
.mr-auto { margin-right: auto !important; }

/* Overflow utilities */
.overflow-auto { overflow: auto !important; }

/* Status dots */
.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
}

.status-dot-lg {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-block;
    border: 2px solid white;
    box-shadow: 0 0 4px rgba(0,0,0,0.3);
}

/* Panel header small variant */
.panel-header-sm {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

/* Form label with weight */
.form-label-weight {
    display: block;
    margin-bottom: 5px;
    font-size: 0.9em;
    font-weight: 600;
}

/* Border top */
.border-top { border-top: 1px solid var(--border) !important; }
.pt-10 { padding-top: 10px !important; }

/* Modal with larger width */
.modal-width-lg {
    width: 700px;
    max-height: 90vh;
    overflow-y: auto;
}

/* Modal extra large */
.modal-width-xl {
    width: 900px;
    max-height: 95vh;
    overflow-y: auto;
}

/* Modal with no padding */
.modal-no-padding {
    padding: 0 !important;
}

/* Form panel (for geofence modal) */
.form-panel {
    width: 350px;
    padding: 20px;
    border-right: 1px solid var(--border);
    overflow-y: auto;
}

/* Map container */
.map-container {
    flex: 1;
    position: relative;
}

/* Map overlay info box */
.map-info-box {
    position: absolute;
    top: 10px;
    left: 10px;
    background: var(--card-bg);
    padding: 8px 12px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Modal header with border */
.modal-header-border {
    padding: 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Card with background */
.card-bg {
    padding: 20px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
    position: relative;
}

.card-bg-sm {
    padding: 15px;
    background: var(--bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Info section */
.info-section {
    margin-top: 30px;
    padding: 20px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Code/monospace input */
.input-code {
    font-family: monospace;
    font-size: 0.85rem;
}

/* Text area inherit font */
.textarea-inherit {
    font-family: inherit;
}

/* Title with primary color */
.title-primary {
    margin-top: 0;
    margin-bottom: 25px;
    color: var(--primary);
}

/* Icon large */
.icon-lg {
    font-size: 1.5rem;
    margin-bottom: 8px;
}

/* Top right actions */
.top-right-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
}

/* Alert category icon */
.alert-cat-icon {
    width: 20px;
    height: 20px;
    border-radius: 4px;
}

/* Toggle slider position */
.toggle-slider-pos {
    position: absolute;
    top: 2px;
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: 0.3s;
}

/* Error message */
.error-message {
    color: red;
    font-size: 0.8rem;
    margin-top: 1rem;
}

/* Alert position */
.alert-badge-pos {
    position: absolute;
    top: -5px;
    right: -5px;
}

/* Progress bar */
.progress-bar {
    height: 8px;
    border-radius: 4px;
    background: var(--bg);
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
}

/* Width utilities for dynamic content */
.w-20px { width: 20px !important; }
.h-20px { height: 20px !important; }
