/* Petrel Monitoring System - Styles */

:root {
    --primary-blue: #0ea5e9;
    --primary-blue-light: #38bdf8;
    --primary-blue-dark: #0284c7;
    --dark-bg: #0f172a;
    --dark-bg-secondary: #1e293b;
    --text-light: #f1f5f9;
    --text-gray: #cbd5e1;
    --success-green: #10b981;
    --danger-red: #ef4444;
    --warning-yellow: #f59e0b;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--dark-bg);
    color: var(--text-light);
    overflow: hidden;
}

/* Navigation Bar */
.navbar {
    background: linear-gradient(135deg, var(--dark-bg) 0%, var(--dark-bg-secondary) 100%);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    position: relative;
    z-index: 1001;
}

.nav-left, .nav-center, .nav-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    flex-direction: column;
}

.logo-text {
    font-size: 28px;
    font-weight: bold;
    background: linear-gradient(135deg, var(--primary-blue-light), var(--primary-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.logo-subtitle {
    font-size: 11px;
    color: var(--text-gray);
    margin-top: -4px;
}

/* Stats Cards */
.stat-card {
    background: rgba(15, 23, 42, 0.6);
    padding: 8px 16px;
    border-radius: 8px;
    border: 1px solid rgba(56, 189, 248, 0.2);
    transition: all 0.3s ease;
}

.stat-card:hover {
    border-color: rgba(56, 189, 248, 0.4);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.2);
}

.stat-label {
    font-size: 11px;
    color: var(--text-gray);
    margin-bottom: 2px;
}

.stat-value {
    font-size: 24px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}

.stat-sos .stat-value {
    color: var(--danger-red);
}

/* Filter Toggle */
.filter-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    font-size: 13px;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(107, 114, 128, 0.5);
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-blue-light);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(20px);
}

.toggle-label {
    font-size: 12px;
    opacity: 0.9;
    white-space: nowrap;
}

/* Live Indicator */
.live-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--success-green);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background: var(--success-green);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

.last-update {
    font-size: 12px;
    color: var(--text-gray);
}

/* SOS Panel */
.sos-panel {
    position: fixed;
    left: -420px;
    top: 70px;
    width: 400px;
    height: calc(100vh - 70px);
    background: var(--dark-bg-secondary);
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.5);
    transition: left 0.3s ease;
    z-index: 999;
    overflow-y: auto;
}

.sos-panel.active {
    left: 0;
}

.sos-panel-header{
  display: flex;
  align-items: center;
  justify-content: center;
}

.sos-header{
  background: linear-gradient(180deg, #ff5a5a 0%, #ef4444 60%, #e23b3b 100%);
  border-bottom: 1px solid rgba(255,255,255,0.12);

  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 14px;

  box-shadow: 0 10px 18px rgba(0,0,0,0.25);

  padding: 16px 18px;

  position: sticky;
  top: 0;
  z-index: 2;
}

.sos-title {
    display: block;
    line-height: 1.2;
    padding-top: 2px;       /* tolak turun sikit supaya tak clip */
    white-space: nowrap;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.sos-devices {
    padding: 16px;
}

.sos-device-card {
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid var(--danger-red);
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.sos-device-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
}

.sos-device-id {
    font-weight: bold;
    font-size: 18px;
}

.sos-time {
    color: var(--text-gray);
    font-size: 12px;
}

.sos-device-info {
    margin-bottom: 12px;
    font-size: 14px;
    line-height: 1.6;
}

.sos-location, .sos-receiver {
    margin-bottom: 4px;
}

.sos-actions {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 6px;
}

.sos-actions .btn {
    font-size: 11px;
    padding: 8px 4px;
}

/* Map Container */
.map-container {
    height: calc(100vh - 70px);
    position: relative;
}

#map {
    height: 100%;
    width: 100%;
}

/* Remove Leaflet attribution */
.leaflet-control-attribution {
    display: none !important;
}

/* Ship Markers - Clean and Simple */
.ship-marker {
    background: transparent !important;
    border: none !important;
    cursor: pointer;
}

.ship-marker svg {
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
    transition: all 0.2s ease;
}

.ship-marker:hover svg {
    filter: drop-shadow(0 5px 10px rgba(0, 0, 0, 0.5));
    transform: scale(1.1);
}

/* SOS ship glow effect */
.ship-sos svg {
    filter: drop-shadow(0 0 12px rgba(239, 68, 68, 0.8)) 
            drop-shadow(0 3px 6px rgba(0, 0, 0, 0.4));
}

.ship-sos:hover svg {
    filter: drop-shadow(0 0 16px rgba(239, 68, 68, 1)) 
            drop-shadow(0 5px 10px rgba(0, 0, 0, 0.5));
}

/* Normal ship */
.ship-normal svg {
    filter: drop-shadow(0 2px 4px rgba(16, 185, 129, 0.3))
            drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
}

/* Offline ship */
.ship-offline svg {
    filter: drop-shadow(0 2px 4px rgba(107, 114, 128, 0.3))
            drop-shadow(0 3px 6px rgba(0, 0, 0, 0.3));
    opacity: 0.7;
}

/* Map Controls */
.map-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 900;
}

.map-control-btn {
    width: 40px;
    height: 40px;
    background: var(--dark-bg-secondary);
    border: 2px solid var(--primary-blue);
    border-radius: 8px;
    color: var(--text-light);
    font-size: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-control-btn:hover {
    background: var(--primary-blue);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.5);
}

/* Popup Styles */
.device-popup {
    min-width: 250px;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(203, 213, 225, 0.2);
}

.status-badge {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
}

.status-normal {
    background: var(--success-green);
    color: white;
}

.status-sos {
    background: var(--danger-red);
    color: white;
    animation: pulse 1s infinite;
}

.status-offline {
    background: #6b7280;
    color: white;
}

.popup-body {
    margin-bottom: 12px;
}

.popup-field {
    margin-bottom: 8px;
    font-size: 13px;
}

.field-label {
    color: #94a3b8;
    margin-right: 8px;
}

.field-value {
    color: white;
    font-weight: 500;
}

.popup-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.popup-actions .btn {
    font-size: 11px;
    padding: 8px 6px;
}

.popup-actions .btn:last-child {
    grid-column: 1 / -1;
}

/* Buttons */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
    font-size: 14px;
}

.btn-primary {
    background: var(--primary-blue);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-blue-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(14, 165, 233, 0.3);
}

.btn-secondary {
    background: var(--dark-bg-secondary);
    color: var(--text-light);
    border: 1px solid var(--primary-blue);
}

.btn-secondary:hover {
    background: var(--primary-blue);
}

/* Toast Notifications */
#toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--dark-bg-secondary);
    border-left: 4px solid var(--primary-blue);
    padding: 16px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 300px;
    max-width: 400px;
    animation: slideIn 0.3s ease;
}

.toast-success {
    border-left-color: var(--success-green);
}

.toast-error {
    border-left-color: var(--danger-red);
}

.toast-warning {
    border-left-color: var(--warning-yellow);
}

.toast-info {
    border-left-color: var(--primary-blue);
}

.toast-title {
    font-weight: bold;
    margin-bottom: 4px;
}

.toast-message {
    font-size: 14px;
    color: var(--text-gray);
}

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

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

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

/* Mobile Responsive */
@media (max-width: 768px) {
    .navbar {
        flex-direction: column;
        padding: 12px;
        gap: 12px;
    }
    
    .nav-left, .nav-center, .nav-right {
        gap: 10px;
    }
    
    .stat-card {
        padding: 6px 12px;
    }
    
    .stat-value {
        font-size: 20px;
    }
    
    .sos-panel {
        width: 100%;
        left: -100%;
    }
    
    #toast-container {
        right: 10px;
        left: 10px;
    }
    
    .toast {
        min-width: auto;
        max-width: 100%;
    }
}
