/**
 * APRS-IS Live Map Styles
 */

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    overflow: hidden;
}

#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* Map container */
#map {
    flex: 1;
    height: 100%;
    z-index: 1;
}

/* Sidebar */
#sidebar {
    width: 300px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

/* Header */
#header {
    padding: 20px;
    background: #34495e;
    border-bottom: 2px solid #1abc9c;
}

#header h1 {
    margin-bottom: 15px;
    font-size: 24px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#status {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

#connection-status {
    padding: 3px 10px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 11px;
    text-transform: uppercase;
}

#connection-status.connected {
    background: #27ae60;
    color: white;
}

#connection-status.connecting {
    background: #f39c12;
    color: white;
}

#connection-status.disconnected {
    background: #e74c3c;
    color: white;
}

#connection-status.error {
    background: #c0392b;
    color: white;
}

#station-count {
    color: #ecf0f1;
}

/* Station list */
#station-list-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#station-list-header {
    padding: 15px;
    background: #34495e;
    border-bottom: 1px solid #2c3e50;
}

#search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #1abc9c;
    border-radius: 4px;
    background: #2c3e50;
    color: white;
    font-size: 13px;
}

#search-input:focus {
    outline: none;
    border-color: #16a085;
    background: #34495e;
}

#search-input::placeholder {
    color: #95a5a6;
}

#station-list {
    flex: 1;
    overflow-y: auto;
}

.empty-message {
    padding: 40px 20px;
    text-align: center;
    color: #95a5a6;
}

.empty-message i {
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-message p {
    font-size: 14px;
}

.station-item {
    padding: 12px 20px;
    border-bottom: 1px solid #34495e;
    cursor: pointer;
    transition: background 0.2s;
}

.station-item:hover {
    background: #34495e;
}

.station-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.station-callsign {
    font-weight: bold;
    font-size: 14px;
    color: #1abc9c;
}

.station-time {
    font-size: 11px;
    color: #95a5a6;
}

.station-item-details {
    font-size: 12px;
    color: #bdc3c7;
}

.station-comment {
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.station-speed {
    color: #95a5a6;
}

/* Station list scrollbar */
#station-list::-webkit-scrollbar {
    width: 8px;
}

#station-list::-webkit-scrollbar-track {
    background: #2c3e50;
}

#station-list::-webkit-scrollbar-thumb {
    background: #1abc9c;
    border-radius: 4px;
}

#station-list::-webkit-scrollbar-thumb:hover {
    background: #16a085;
}

/* Control buttons */
#controls {
    position: absolute;
    top: 20px;
    left: 320px;
    z-index: 1000;
    display: flex;
    gap: 10px;
    transition: left 0.3s;
}

#controls button {
    width: 40px;
    height: 40px;
    background: white;
    border: 2px solid #ddd;
    border-radius: 5px;
    cursor: pointer;
    font-size: 18px;
    color: #34495e;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

#controls button:hover {
    background: #ecf0f1;
    border-color: #1abc9c;
    color: #1abc9c;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

#controls button.active {
    background: #1abc9c;
    border-color: #1abc9c;
    color: white;
}

#controls button.active:hover {
    background: #16a085;
    border-color: #16a085;
}

/* Info panel (shown when sidebar hidden) */
#info-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: white;
    padding: 12px 16px;
    border-radius: 5px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

#info-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 13px;
}

#connection-status-mini {
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 11px;
    text-transform: uppercase;
    display: inline-block;
}

#station-count-mini {
    font-weight: bold;
    color: #34495e;
}

/* Station markers on map */
.station-icon-wrapper {
    background: transparent;
    border: none;
}

.station-marker {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3);
    font-size: 16px;
    transition: transform 0.2s;
}

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

/* Station labels (tooltips) */
.station-label {
    background: rgba(0, 0, 0, 0.8) !important;
    color: white !important;
    border: none !important;
    padding: 3px 8px !important;
    font-size: 11px !important;
    font-weight: bold !important;
    border-radius: 3px !important;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.3) !important;
}

.station-label::before {
    border-top-color: rgba(0, 0, 0, 0.8) !important;
}

/* Popup styling */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 3px 14px rgba(0, 0, 0, 0.4);
}

.station-popup {
    font-size: 13px;
    min-width: 250px;
}

.station-popup h3 {
    margin-bottom: 12px;
    color: #2c3e50;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 2px solid #1abc9c;
    padding-bottom: 8px;
}

.station-popup table {
    width: 100%;
    border-collapse: collapse;
}

.station-popup tr {
    border-bottom: 1px solid #ecf0f1;
}

.station-popup tr:last-child {
    border-bottom: none;
}

.station-popup td {
    padding: 6px 4px;
    vertical-align: top;
}

.station-popup td:first-child {
    color: #7f8c8d;
    width: 35%;
}

.station-popup td:last-child {
    color: #2c3e50;
    font-weight: 500;
}

/* Responsive design */
@media (max-width: 768px) {
    #sidebar {
        width: 100%;
        max-width: 300px;
        position: absolute;
        height: 100%;
        z-index: 2000;
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    #sidebar.visible {
        transform: translateX(0);
    }

    #controls {
        left: 20px;
    }
}

/* Loading animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 1.5s ease-in-out infinite;
}

/* Message panel */
#message-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 700px;
    height: 200px;
    background: #2c3e50;
    border-top: 2px solid #1abc9c;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.3);
    z-index: 999;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease, width 0.3s;
    min-height: 100px;
    max-height: calc(100vh - 100px);
}

.message-panel-resize-handle {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    cursor: ns-resize;
    background: transparent;
    z-index: 1001;
}

.message-panel-resize-handle:hover {
    background: #1abc9c;
}

.message-panel-resize-handle:active {
    background: #16a085;
}

#message-panel.resizing {
    transition: none;
    user-select: none;
}

#message-panel.message-panel-collapsed {
    transform: translateY(calc(100% - 40px));
}

#message-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #34495e;
    border-bottom: 1px solid #1abc9c;
    min-height: 40px;
    cursor: pointer;
    user-select: none;
}

.message-panel-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-size: 14px;
    font-weight: bold;
}

.message-badge {
    background: #1abc9c;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: bold;
}

.message-panel-toggle {
    background: transparent;
    border: none;
    color: #1abc9c;
    cursor: pointer;
    font-size: 16px;
    padding: 5px;
    transition: transform 0.3s, color 0.2s;
}

.message-panel-toggle:hover {
    color: #16a085;
}

#message-panel:not(.message-panel-collapsed) .message-panel-toggle i {
    transform: rotate(180deg);
}

#message-list-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#message-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px 15px;
    display: flex;
    flex-direction: column;
}

.empty-message-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: #95a5a6;
    gap: 10px;
}

.empty-message-panel i {
    opacity: 0.5;
}

.message-item {
    padding: 8px 12px;
    margin-bottom: 6px;
    background: #34495e;
    border-left: 3px solid #1abc9c;
    border-radius: 3px;
    font-size: 12px;
    color: #ecf0f1;
    line-height: 1.4;
}

.message-item-time {
    color: #95a5a6;
    font-weight: bold;
    margin-right: 8px;
}

.message-item-from {
    color: #1abc9c;
    font-weight: bold;
}

.message-item-to {
    color: #3498db;
    font-weight: bold;
}

.message-item-text {
    color: #ecf0f1;
    word-wrap: break-word;
}

/* Message list scrollbar */
#message-list::-webkit-scrollbar {
    width: 8px;
}

#message-list::-webkit-scrollbar-track {
    background: #2c3e50;
}

#message-list::-webkit-scrollbar-thumb {
    background: #1abc9c;
    border-radius: 4px;
}

#message-list::-webkit-scrollbar-thumb:hover {
    background: #16a085;
}

/* When sidebar is visible */
#message-panel.sidebar-visible {
    right: 1000px;
}

/* Responsive adjustments for message panel */
@media (max-width: 768px) {
    #message-panel {
        max-height: 30vh;
    }

    #message-panel.sidebar-visible {
        right: 700px;
    }

    #message-panel.message-panel-collapsed {
        transform: translateY(calc(100% - 40px));
    }
}

/* Print styles */
@media print {
    #sidebar,
    #controls,
    #info-panel,
    #message-panel {
        display: none;
    }

    #map {
        width: 100%;
    }
}
