/* Custom CSS for Maps application */

.map-container {
    position: relative;
    height: 100%;
    width: 100%;
}

#map {
    border: 1px solid #ddd;
    border-radius: 0.375rem;
}

.coordinate-display {
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.map-controls {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 0.375rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Table styles for coordinate data */
.coordinate-table {
    max-height: 400px;
    overflow-y: auto;
}

.coordinate-table table {
    font-size: 0.875rem;
}

.coordinate-table .table-row-even {
    background-color: #f8f9fa;
}

.coordinate-table .table-row-odd {
    background-color: #ffffff;
}

/* Chart container */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Drawing tools */
.drawing-tools {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.drawing-tools .btn {
    min-width: 100px;
}

/* Export options */
.export-options {
    display: none;
}

.export-options.show {
    display: block;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .map-controls .row > div {
        margin-bottom: 1rem;
    }
    
    .drawing-tools {
        justify-content: center;
    }
    
    .drawing-tools .btn {
        min-width: 80px;
        font-size: 0.875rem;
    }
    
    /* Adjust toolbar for small screens */
    .btn-toolbar {
        justify-content: flex-start !important;
        flex-wrap: wrap;
    }
    
    .btn-toolbar .btn-group {
        margin-bottom: 0.5rem;
        margin-right: 0.5rem;
    }
    
    /* Ensure buttons align left on small screens */
    .col-md-5 .btn-toolbar,
    .col-md-3 .btn-group {
        justify-content: flex-start !important;
        text-align: left !important;
    }
    
    /* Add space between button rows */
    .card-body .row.align-items-center > div {
        margin-bottom: 0.5rem;
    }
    
    /* Stack columns vertically on small screens */
    .card-body .row.align-items-center {
        flex-direction: column;
        align-items: flex-start !important;
    }
    
    .card-body .row.align-items-center > div {
        width: 100%;
        max-width: 100%;
        flex: 0 0 100%;
    }
    
    /* Ensure search input and map mode buttons take full width */
    .col-md-4 .row > div {
        margin-bottom: 0.5rem;
    }
    
    .col-md-4 .row .col-8,
    .col-md-4 .row .col-4 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Remove text-end alignment on small screens */
    .col-md-3 {
        text-align: left !important;
    }

    .gropu-search {
        margin-bottom: 0!important;
    }    
}

/* Extra small screens adjustments */
@media (max-width: 576px) {
    /* Make buttons smaller on very small screens */
    .btn-group-sm .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    /* Reduce card padding */
    .card-body.p-2 {
        padding: 0.75rem !important;
    }
    
    /* Make button groups stack more efficiently */
    .btn-toolbar .btn-group {
        margin-bottom: 0.75rem;
        margin-right: 0.25rem;
    }
    
    /* Ensure buttons don't get too small */
    .btn-group .btn {
        min-width: 40px;
    }
    
    /* Better spacing for input groups */
    .input-group-sm {
        margin-bottom: 0.75rem;
    }

    .group-search {
        margin-bottom: 0!important;
    }
}

/* Custom marker styles */
.custom-marker {
    background: #4285F4;
    border: 2px solid #ffffff;
    border-radius: 50%;
    color: white;
    font-weight: bold;
    text-align: center;
    line-height: 1;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Info window custom styles */
.gm-style .gm-style-iw-c {
    border-radius: 0.375rem;
}

.gm-style .gm-style-iw-d {
    overflow: hidden !important;
}

/* Progress bars for elevation loading */
.elevation-progress {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 1rem;
    border-radius: 0.375rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    min-width: 250px;
}

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

.status-indicator.connected {
    background-color: #28a745;
}

.status-indicator.disconnected {
    background-color: #dc3545;
}

.status-indicator.loading {
    background-color: #ffc107;
    animation: pulse 1s infinite;
}

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

/* Card hover effects */
.card:hover {
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s ease;
}

/* Button group for tools */
.tool-group {
    display: flex;
    gap: 0.25rem;
}

.tool-group .btn {
    border-radius: 0;
}

.tool-group .btn:first-child {
    border-top-left-radius: 0.375rem;
    border-bottom-left-radius: 0.375rem;
}

.tool-group .btn:last-child {
    border-top-right-radius: 0.375rem;
    border-bottom-right-radius: 0.375rem;
}

/* Tooltip customization */
.tooltip-inner {
    max-width: 300px;
    text-align: left;
}

/* Feature icons */
.feature-icon {
    font-size: 1.2rem;
    margin-right: 0.5rem;
    color: #6c757d;
}

/* Advanced tools sidebar */
.tools-sidebar {
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    min-height: 600px;
    padding: 1rem;
}

.tools-sidebar .tool-section {
    margin-bottom: 2rem;
}

.tools-sidebar .tool-section h6 {
    color: #495057;
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
}

/* Map overlay panels */
.map-overlay {
    position: absolute;
    background: white;
    border-radius: 0.375rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    z-index: 100;
    padding: 1rem;
}

.map-overlay.top-left {
    top: 10px;
    left: 10px;
}

.map-overlay.top-right {
    top: 10px;
    right: 10px;
}

.map-overlay.bottom-left {
    bottom: 10px;
    left: 10px;
}

.map-overlay.bottom-right {
    bottom: 10px;
    right: 10px;
}

/* Custom mesh point tooltip styles */
.mesh-tooltip {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    padding: 0;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    min-width: 280px;
    max-width: 320px;
}

.mesh-tooltip-header {
    background: rgba(255, 255, 255, 0.1);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    border-radius: 12px 12px 0 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.mesh-tooltip-icon {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 16px;
}

.mesh-tooltip-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    letter-spacing: 0.5px;
}

.mesh-tooltip-body {
    padding: 16px;
}

.mesh-tooltip-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    border-left: 3px solid rgba(255, 255, 255, 0.3);
}

.mesh-tooltip-row:last-child {
    margin-bottom: 0;
}

.mesh-tooltip-label {
    font-size: 13px;
    font-weight: 500;
    opacity: 0.9;
    display: flex;
    align-items: center;
}

.mesh-tooltip-label i {
    margin-right: 6px;
    width: 14px;
    text-align: center;
}

.mesh-tooltip-value {
    font-size: 14px;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 8px;
    border-radius: 4px;
}

.mesh-tooltip-elevation {
    background: rgba(76, 175, 80, 0.2);
}

/* Override Google Maps InfoWindow styles for mesh tooltips */
.gm-style .gm-style-iw-c {
    padding: 0 !important;
    border-radius: 12px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
}

.gm-style .gm-style-iw-d {
    overflow: hidden !important;
    max-height: none !important;
}

.gm-style .gm-style-iw-chr {
    display: none; /* Hide the close button */
}

/* Custom close button for mesh tooltips */
.mesh-tooltip-close {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s ease;
}

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

/* Animation for tooltip appearance */
.mesh-tooltip {
    animation: meshTooltipFadeIn 0.3s ease-out;
    transform-origin: bottom center;
}

@keyframes meshTooltipFadeIn {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Equal height panels when both are visible */
#collapsiblePanelsRow {
    margin-bottom: 1.5rem !important;
}

/* When both panels are visible, use CSS Grid for equal heights */
#collapsiblePanelsRow.both-visible {
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: stretch;
    margin-bottom: 1.5rem !important;
}

#collapsiblePanelsRow.both-visible #toolsInfoContainer,
#collapsiblePanelsRow.both-visible #infoQuickContainer {
    display: flex !important;
    flex-direction: column;
}

#collapsiblePanelsRow.both-visible .collapse-panel.show {
    display: flex !important;
    flex-direction: column;
    height: 100%;
}

#collapsiblePanelsRow.both-visible .collapse-panel.show .card {
    display: flex !important;
    flex-direction: column;
    height: 100%;
    margin-bottom: 0;
}

#collapsiblePanelsRow.both-visible .collapse-panel.show .card-body {
    flex: 1;
    display: flex !important;
    flex-direction: column;
}

/* Reset Bootstrap col classes when using grid */
#collapsiblePanelsRow.both-visible .col-md-6,
#collapsiblePanelsRow.both-visible .col-12 {
    width: auto !important;
    flex: none !important;
    max-width: none !important;
}

/* Mobile responsiveness - disable grid on small screens */
@media (max-width: 767px) {
    #collapsiblePanelsRow.both-visible {
        display: block !important;
        grid-template-columns: none;
        gap: 0;
    }
    
    #collapsiblePanelsRow.both-visible #toolsInfoContainer,
    #collapsiblePanelsRow.both-visible #infoQuickContainer {
        margin-bottom: 1rem;
    }
}
