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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #0f0f1e;
    color: #e0e0e0;
    overflow: hidden;
}

/* Header */
.header {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    position: relative;
}

.header h1 {
    font-size: 1.5rem;
    color: #fff;
    margin: 0;
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Badges */
.status-badges {
    display: flex;
    gap: 0.5rem;
}

.badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

.badge-success {
    background: #00b894;
    color: #fff;
}

.badge-danger {
    background: #ff6b6b;
    color: #fff;
}

.badge-info {
    background: #74b9ff;
    color: #fff;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: #6c5ce7;
    color: #fff;
}

.btn-primary:hover {
    background: #5f4bd5;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #00b894;
    color: #fff;
}

.btn-secondary:hover {
    background: #00a281;
    transform: translateY(-2px);
}

.btn-info {
    background: #0984e3;
    color: #fff;
}

.btn-info:hover {
    background: #0773cc;
    transform: translateY(-2px);
}

.btn-close {
    background: transparent;
    border: none;
    color: #999;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s;
}

.btn-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

/* Main Container */
.main-container {
    position: relative;
    height: calc(100vh - 70px - 40px); /* Header height - Footer height */
    display: flex;
}

/* Map */
#map {
    flex: 1;
    height: 100%;
    background: #0a0a0a;
    position: relative;
    z-index: 1;
}

/* Side Panel */
.side-panel {
    position: fixed;
    top: 70px; /* Below header */
    right: -400px;
    width: 400px;
    height: calc(100vh - 70px - 40px); /* Full height minus header and footer */
    background: #1a1a2e;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
    transition: right 0.3s;
    z-index: 500;
    display: flex;
    flex-direction: column;
}

.side-panel.active {
    right: 0;
}

.panel-header {
    padding: 1.5rem;
    background: #16213e;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.panel-header h2 {
    font-size: 1.25rem;
    color: #fff;
    margin: 0;
}

.panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Search Box */
.search-box {
    margin-bottom: 1.5rem;
}

.search-box input {
    width: 100%;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #fff;
    font-size: 0.875rem;
}

.search-box input:focus {
    outline: none;
    border-color: #6c5ce7;
    background: rgba(255, 255, 255, 0.08);
}

/* Device List */
.device-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.device-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.3s;
}

.device-item:hover {
    background: rgba(255, 255, 255, 0.08);
    transform: translateX(-5px);
    border-color: #6c5ce7;
}

.device-item.online {
    border-left: 3px solid #00b894;
}

.device-item.offline {
    border-left: 3px solid #ff6b6b;
}

.device-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.device-name {
    font-weight: 600;
    color: #fff;
}

.device-status {
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
}

.device-status.online {
    background: rgba(0, 184, 148, 0.2);
    color: #00b894;
}

.device-status.offline {
    background: rgba(255, 107, 107, 0.2);
    color: #ff6b6b;
}

.device-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    font-size: 0.875rem;
    color: #999;
}

/* Stats Panel */
.stats-panel {
    position: fixed;
    bottom: -400px;
    left: 0;
    right: 0;
    height: 400px;
    background: #1a1a2e;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    transition: bottom 0.3s;
    z-index: 400;
}

.stats-panel.active {
    bottom: 40px; /* Above footer */
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 1rem;
    text-align: center;
}

.stat-card h3 {
    font-size: 0.875rem;
    color: #999;
    margin-bottom: 0.5rem;
    font-weight: 400;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: #6c5ce7;
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: #666;
    text-transform: uppercase;
}

/* Timeline Panel */
.timeline-panel {
    position: fixed;
    bottom: 40px; /* Above footer */
    left: 0;
    right: 0;
    background: #1a1a2e;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    z-index: 300;
}

.timeline-header {
    padding: 1rem 1.5rem;
    background: #16213e;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.timeline-header h3 {
    font-size: 1rem;
    color: #fff;
    margin: 0;
}

.timeline-filters {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.timeline-content {
    max-height: 200px;
    overflow-y: auto;
    padding: 1rem;
    display: none;
}

.timeline-content.active {
    display: block;
}

.event-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.event-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border-left: 3px solid transparent;
    transition: all 0.3s;
}

.event-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.event-item.lightning {
    border-left-color: #f39c12;
}

.event-item.disturber {
    border-left-color: #e74c3c;
}

.event-item.noise {
    border-left-color: #95a5a6;
}

.event-time {
    font-size: 0.875rem;
    color: #666;
    min-width: 60px;
}

.event-type {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
    font-weight: 600;
    min-width: 80px;
    text-align: center;
}

.event-type.lightning {
    background: rgba(243, 156, 18, 0.2);
    color: #f39c12;
}

.event-type.disturber {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
}

.event-type.noise {
    background: rgba(149, 165, 166, 0.2);
    color: #95a5a6;
}

.event-details {
    flex: 1;
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #999;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #1a1a2e;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-content.modal-lg {
    max-width: 800px;
}

.modal-header {
    padding: 1.5rem;
    background: #16213e;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
    font-size: 1.25rem;
    color: #fff;
    margin: 0;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

/* Settings */
.settings-group {
    margin-bottom: 2rem;
}

.settings-group h3 {
    font-size: 1rem;
    color: #fff;
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.checkbox-label span {
    font-size: 0.875rem;
    color: #ccc;
}

label {
    display: block;
    margin-bottom: 0.75rem;
}

label span {
    display: block;
    font-size: 0.875rem;
    color: #ccc;
    margin-bottom: 0.5rem;
}

input[type="number"] {
    width: 100%;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #fff;
    font-size: 0.875rem;
}

select {
    padding: 0.5rem;
    background: #2c3e50;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    color: #fff;
    font-size: 0.875rem;
}

select option {
    background: #2c3e50;
    color: #fff;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 200px;
}

.chart-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 15px;
}

.chart-box h4 {
    margin: 0 0 15px 0;
    color: #fff;
    font-size: 0.9rem;
    text-align: center;
}

.chart-box canvas {
    max-height: 200px;
}

/* Lightning Strike Animation */
.lightning-strike {
    pointer-events: none;
    z-index: 1000;
}

.strike-container {
    position: relative;
    width: 60px;
    height: 60px;
}

.strike-bolt {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 30px;
    color: #fff700;
    text-shadow: 0 0 10px #fff700, 0 0 20px #ffa500, 0 0 30px #ff6600;
    animation: bolt-flash 0.5s ease-out;
    z-index: 3;
}

.strike-pulse {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    background: radial-gradient(circle, rgba(255,247,0,0.8) 0%, rgba(255,165,0,0.4) 50%, transparent 70%);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: pulse-expand 2s ease-out;
    z-index: 2;
}

.strike-wave {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 40px;
    height: 40px;
    border: 2px solid rgba(255,247,0,0.6);
    border-radius: 50%;
    transform: translate(-50%, -50%);
    animation: wave-expand 3s ease-out;
    z-index: 1;
}

@keyframes bolt-flash {
    0% {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
    50% {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1.5);
    }
    100% {
        opacity: 0.8;
        transform: translate(-50%, -50%) scale(1);
    }
}

@keyframes pulse-expand {
    0% {
        width: 20px;
        height: 20px;
        opacity: 0.8;
    }
    100% {
        width: 100px;
        height: 100px;
        opacity: 0;
    }
}

@keyframes wave-expand {
    0% {
        width: 40px;
        height: 40px;
        opacity: 0.6;
        border-width: 3px;
    }
    100% {
        width: 150px;
        height: 150px;
        opacity: 0;
        border-width: 1px;
    }
}

/* Lightning Animation (old) */
@keyframes lightning-pulse {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    100% {
        transform: scale(3);
        opacity: 0;
    }
}

.lightning-pulse {
    animation: lightning-pulse 2s ease-out;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Footer */
.footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.75rem 2rem;
    z-index: 100;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: #999;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.footer-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.footer-link {
    color: #6c5ce7;
    text-decoration: none;
    transition: color 0.3s;
}

.footer-link:hover {
    color: #74b9ff;
}

.separator {
    color: #666;
}


/* Language Selector */
.language-selector {
    position: relative;
}

.btn-lang {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s;
    min-width: 50px;
}

.btn-lang:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.language-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: #1a1a2e;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: none;
    z-index: 1000;
    min-width: 180px;
}

.language-dropdown.active {
    display: block;
}

.language-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.2s;
    color: #e0e0e0;
    text-decoration: none;
}

.language-option:hover {
    background: rgba(255, 255, 255, 0.1);
}

.language-option.active {
    background: rgba(108, 92, 231, 0.2);
    color: #6c5ce7;
}

.language-option:first-child {
    border-radius: 8px 8px 0 0;
}

.language-option:last-child {
    border-radius: 0 0 8px 8px;
}

.language-flag {
    font-size: 1.2rem;
}

.language-name {
    font-size: 0.875rem;
}

/* RTL Support for Arabic */
html[dir="rtl"] .header {
    flex-direction: row-reverse;
}

html[dir="rtl"] .header-left,
html[dir="rtl"] .header-right {
    flex-direction: row-reverse;
}

html[dir="rtl"] .side-panel {
    right: auto;
    left: -400px;
}

html[dir="rtl"] .side-panel.active {
    left: 0;
}

html[dir="rtl"] .device-item {
    border-left: none;
    border-right: 3px solid transparent;
}

html[dir="rtl"] .device-item.online {
    border-right-color: #00b894;
}

html[dir="rtl"] .device-item.offline {
    border-right-color: #ff6b6b;
}

html[dir="rtl"] .event-item {
    border-left: none;
    border-right: 3px solid transparent;
}

html[dir="rtl"] .event-item.lightning {
    border-right-color: #f39c12;
}

html[dir="rtl"] .event-item.disturber {
    border-right-color: #e74c3c;
}

html[dir="rtl"] .event-item.noise {
    border-right-color: #95a5a6;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        flex-direction: column;
        gap: 1rem;
        padding: 1rem;
    }
    
    .side-panel {
        width: 100%;
        right: -100%;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    html[dir="rtl"] .side-panel {
        left: -100%;
        right: auto;
    }
    
    .footer-content {
        flex-direction: column;
        gap: 0.5rem;
        text-align: center;
    }
    
    .footer {
        padding: 0.5rem 1rem;
    }
}