/* Modern ATS/NTS Locator Styles */

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

html, body {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f8f9fa;
    color: #333;
    margin: 0;
    padding: 0;
    overflow: visible;
}

#map {
    height: 100%;
    width: 100%;
    z-index: 1;
}

/* Search Panel */
#search-panel {
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    min-width: 320px;
    max-width: 400px;
}

.search-section {
    margin-bottom: 20px;
}

.search-section:last-child {
    margin-bottom: 0;
}

.search-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.search-section p {
    font-size: 13px;
    color: #6c757d;
    line-height: 1.4;
}

/* Form Styles */
form {
    margin: 0;
    padding: 0;
}

input, button {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

button {
    margin-bottom: 0;
    background: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

input:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

button {
    padding: 12px 24px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

button:hover {
    background: #0056b3;
}

button:active {
    transform: translateY(1px);
}

/* Results Panel */
#results-panel {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    min-width: 300px;
    max-width: 400px;
    display: none;
}

#results-content h3 {
    font-size: 16px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 15px;
}

#legal-display, #coord-display {
    margin-bottom: 10px;
}

.result-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e9ecef;
}

.result-item:last-child {
    border-bottom: none;
}

.result-label {
    font-weight: 500;
    color: #495057;
}

.result-value {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    color: #007bff;
    font-weight: 600;
}

.system-link {
    color: #6c757d;
    text-decoration: none;
    margin: 0 5px;
    font-weight: 500;
}

.system-link:hover {
    color: #007bff;
    text-decoration: underline;
}

.external-link {
    color: #28a745;
    text-decoration: none;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.external-link:hover {
    color: #218838;
    text-decoration: underline;
}

.system-link.active {
    color: #007bff;
    font-weight: 600;
}

#close-results {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 24px;
    color: #6c757d;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#close-results:hover {
    color: #495057;
}

/* Loading Spinner */
#loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
    background: rgba(255, 255, 255, 0.9);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e9ecef;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Leaflet Overrides */
.leaflet-control-container .leaflet-routing-container-hide {
    display: none;
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.leaflet-popup-content {
    margin: 15px;
    font-family: inherit;
}

/* Responsive Design */
@media (max-width: 768px) {
    #search-panel {
        left: 10px;
        right: 10px;
        top: 10px;
        min-width: auto;
        max-width: none;
    }

    #results-panel {
        left: 10px;
        right: 10px;
        top: auto;
        bottom: 10px;
        max-width: none;
    }

    .coord-inputs {
        flex-direction: column;
    }
}

/* Error States */
input.error {
    border-color: #dc3545;
    background-color: #fff5f5;
}

input.error:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.1);
}

.error-message {
    color: #dc3545;
    font-size: 12px;
    margin-top: 5px;
    display: none;
    font-weight: 500;
    line-height: 1.3;
}

/* Notification Styles */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 3000;
    padding: 12px 16px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    transform: translateX(400px);
    transition: transform 0.3s ease;
    max-width: 300px;
    line-height: 1.4;
}

.notification.show {
    transform: translateX(0);
}

.notification.error {
    background: #dc3545;
}

.notification.warning {
    background: #ffc107;
    color: #212529;
}

.notification.success {
    background: #28a745;
}

.notification.info {
    background: #17a2b8;
}

.notification-content small {
    opacity: 0.9;
    font-weight: 400;
}

/* History Button */
#history-button {
    transition: background-color 0.2s ease;
}

#history-button:hover {
    background: rgba(255, 255, 255, 1) !important;
    transform: scale(1.05);
}

/* Enhanced Loading Indicator */
#loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

#loading .spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e9ecef;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

#loading .loading-text {
    color: #495057;
    font-weight: 500;
    font-size: 14px;
}

/* Enhanced Mobile Responsiveness */
@media (max-width: 768px) {
    #search-panel {
        left: 10px;
        right: 10px;
        top: 10px;
        min-width: auto;
        max-width: none;
        padding: 16px;
    }

    #results-panel {
        left: 10px;
        right: 10px;
        top: auto;
        bottom: 10px;
        max-width: none;
        padding: 16px;
    }

    .coord-inputs {
        flex-direction: column;
        gap: 12px;
    }

    .coord-inputs input {
        width: 100%;
    }

    /* Touch-friendly buttons */
    button, input[type="submit"] {
        min-height: 48px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 20px;
    }

    input {
        min-height: 48px;
        font-size: 16px;
        padding: 12px 16px;
    }

    /* Larger touch targets */
    #close-results {
        width: 44px;
        height: 44px;
        font-size: 28px;
    }

    #history-button {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }

    /* Improved map interaction on mobile */
    #map {
        height: 100vh;
        width: 100vw;
        cursor: default;
    }

    /* Better modal on mobile */
    .notification {
        left: 10px;
        right: 10px;
        max-width: none;
        margin: 0 auto;
    }
}

/* Keyboard shortcut hints */
@media (min-width: 769px) {
    .search-section h3::after {
        content: attr(data-shortcut);
        float: right;
        font-size: 11px;
        color: #6c757d;
        font-weight: 400;
        text-transform: none;
    }

    .search-section:nth-child(1) h3::after {
        content: "Ctrl+K";
    }

    .search-section:nth-child(2) h3::after {
        content: "Ctrl+L";
    }
}

/* Focus management for accessibility */
input:focus, button:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .notification {
        transition: none;
    }

    .spinner {
        animation: none;
    }

    #history-button {
        transition: none;
    }
}