/* Terra SWARM Map Styles */

.terra-swarm-map-container {
    position: relative;
    width: 100%;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

#terra-swarm-map {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    z-index: 1;
}

/* Custom Markers */
.rig-marker {
    background: transparent;
    border: none;
}

.rig-icon {
    background: #fff;
    border: 3px solid #2563eb;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    transition: transform 0.2s;
}

.rig-marker.swarm-active .rig-icon {
    border-color: #10b981;
    animation: pulse 2s infinite;
}

.rig-marker.alert .rig-icon {
    border-color: #ef4444;
    animation: alert-pulse 1s infinite;
}

.rig-marker:hover .rig-icon {
    transform: scale(1.2);
}

.vessel-marker {
    background: transparent;
    border: none;
}

.vessel-icon {
    font-size: 20px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes alert-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

/* Control Panel (Pilot Mode) */
.terra-control-panel {
    background: #1f2937;
    color: #fff;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid #374151;
}

.connection-status {
    color: #10b981;
    font-weight: 600;
}

.last-update {
    color: #9ca3af;
    font-size: 14px;
}

.active-alerts {
    margin-top: 10px;
}

.alert-item {
    background: #7c2d12;
    border-left: 4px solid #ef4444;
    padding: 10px;
    margin: 5px 0;
    border-radius: 4px;
}

/* Rig Detail Panel */
.rig-detail-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 380px;
    max-height: 85%;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
    overflow-y: auto;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

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

.rig-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 2px solid #e5e7eb;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #fff;
    border-radius: 12px 12px 0 0;
}

.rig-header h2 {
    margin: 0;
    font-size: 20px;
}

.close-panel {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    font-size: 24px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s;
}

.close-panel:hover {
    background: rgba(255,255,255,0.3);
}

.rig-info {
    padding: 20px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid #f3f4f6;
}

.info-row label {
    font-weight: 600;
    color: #6b7280;
}

.info-row span {
    color: #1f2937;
    text-align: right;
}

/* Weather Section */
.weather-section,
.swarm-section,
.vessels-section {
    padding: 20px;
    border-top: 2px solid #e5e7eb;
}

.weather-section h3,
.swarm-section h3,
.vessels-section h3 {
    margin: 0 0 15px 0;
    font-size: 18px;
    color: #1f2937;
}

.weather-grid,
.swarm-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.weather-item,
.swarm-item {
    text-align: center;
    padding: 10px;
    background: #f9fafb;
    border-radius: 8px;
}

.weather-item label,
.swarm-item label {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 5px;
}

.weather-item .value,
.swarm-item .value {
    display: block;
    font-size: 24px;
    font-weight: 700;
    color: #1f2937;
}

.weather-item .sub {
    display: block;
    font-size: 11px;
    color: #9ca3af;
    margin-top: 3px;
}

/* SWARM Status */
.status-badge {
    display: inline-block;
    padding: 6px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 12px;
    margin-bottom: 15px;
}

.status-ok {
    background: #d1fae5;
    color: #065f46;
}

.status-warn {
    background: #fef3c7;
    color: #92400e;
}

.status-error {
    background: #fee2e2;
    color: #991b1b;
}

/* Battery Levels */
.battery-levels {
    margin-top: 15px;
}

.battery-levels h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #6b7280;
}

.batteries {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.battery {
    position: relative;
    height: 40px;
    background: #e5e7eb;
    border-radius: 6px;
    overflow: hidden;
}

.battery-fill {
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    transition: width 0.3s;
}

.battery-good .battery-fill {
    background: linear-gradient(90deg, #10b981, #059669);
}

.battery-medium .battery-fill {
    background: linear-gradient(90deg, #f59e0b, #d97706);
}

.battery-low .battery-fill {
    background: linear-gradient(90deg, #ef4444, #dc2626);
}

.battery-label {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    font-size: 11px;
    font-weight: 700;
    color: #1f2937;
    z-index: 1;
}

/* System Health */
.system-health {
    margin-top: 15px;
}

.system-health h4 {
    margin: 0 0 10px 0;
    font-size: 14px;
    color: #6b7280;
}

.health-item {
    display: flex;
    align-items: center;
    padding: 8px;
    margin: 5px 0;
    border-radius: 6px;
    font-size: 14px;
}

.health-ok {
    background: #d1fae5;
    color: #065f46;
}

.health-error {
    background: #fee2e2;
    color: #991b1b;
}

.health-icon {
    margin-right: 8px;
    font-weight: 700;
}

/* Vessels Section */
.vessels-list {
    max-height: 300px;
    overflow-y: auto;
}

.vessel-item {
    padding: 12px;
    margin: 8px 0;
    background: #f9fafb;
    border-radius: 8px;
    border-left: 4px solid #3b82f6;
}

.vessel-name {
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 4px;
}

.vessel-details {
    font-size: 12px;
    color: #6b7280;
}

/* Loading and Error States */
.loading {
    text-align: center;
    padding: 40px;
    color: #6b7280;
}

.error {
    color: #dc2626;
    padding: 20px;
    text-align: center;
}

.sub {
    font-size: 12px;
    color: #9ca3af;
}

/* Popup Styles */
.leaflet-popup-content {
    margin: 15px;
    line-height: 1.6;
}

.leaflet-popup-content strong {
    display: block;
    margin-bottom: 5px;
    color: #1f2937;
}

.view-details {
    display: inline-block;
    margin-top: 8px;
    color: #2563eb;
    text-decoration: none;
    font-weight: 600;
}

.view-details:hover {
    text-decoration: underline;
}

/* Responsive Design */
@media (max-width: 768px) {
    .rig-detail-panel {
        position: fixed;
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        max-height: 70%;
        border-radius: 12px 12px 0 0;
    }
    
    .weather-grid,
    .swarm-grid {
        grid-template-columns: 1fr;
    }
    
    .batteries {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Scrollbar Styling */
.rig-detail-panel::-webkit-scrollbar,
.vessels-list::-webkit-scrollbar {
    width: 8px;
}

.rig-detail-panel::-webkit-scrollbar-track,
.vessels-list::-webkit-scrollbar-track {
    background: #f3f4f6;
}

.rig-detail-panel::-webkit-scrollbar-thumb,
.vessels-list::-webkit-scrollbar-thumb {
    background: #9ca3af;
    border-radius: 4px;
}

.rig-detail-panel::-webkit-scrollbar-thumb:hover,
.vessels-list::-webkit-scrollbar-thumb:hover {
    background: #6b7280;
}
