/**
 * Trail Finder Plugin Styles
 *
 * @package Trail_Finder
 */

/* Main Container */
.trail-finder-container {
    display: flex;
    gap: 20px;
    max-width: 1400px;
    margin: 20px auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

/* Sidebar Filters */
.trail-finder-sidebar {
    flex: 0 0 320px;
    background: #f5f5f5;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.trail-finder-sidebar h3 {
    margin: 0 0 15px 0;
    color: #048400;
    font-size: 1.5em;
    font-weight: 600;
}

/* Filter Groups */
.filter-group {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #ddd;
}

.filter-group:last-of-type {
    border-bottom: none;
}

.filter-group > label {
    display: block;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
    font-size: 0.95em;
}

/* Checkbox Labels */
.checkbox-label {
    display: block;
    font-weight: normal;
    margin: 8px 0;
    cursor: pointer;
    color: #555;
    transition: color 0.2s;
    font-size: 0.9em;
}

.checkbox-label:hover {
    color: #048400;
}

.checkbox-label input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

/* Text Inputs */
.filter-group input[type="text"],
.filter-group input[type="number"],
.filter-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 14px;
    transition: border-color 0.2s;
}

.filter-group input[type="text"]:focus,
.filter-group input[type="number"]:focus,
.filter-group select:focus {
    outline: none;
    border-color: #048400;
    box-shadow: 0 0 0 2px rgba(4,132,0,0.1);
}

/* Range Inputs */
.range-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.range-inputs input[type="number"] {
    flex: 1;
    width: auto;
}

.range-separator {
    color: #999;
    font-size: 0.9em;
}

/* Tags Grid */
.tags-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 10px;
    margin-top: 8px;
}

.tags-grid .checkbox-label {
    margin: 0;
}

/* Difficulty Grid */
.difficulty-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 10px;
    margin-top: 8px;
}

.difficulty-grid .checkbox-label {
    margin: 0;
}

/* Usage Level Grid */
.usage-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 4px 10px;
    margin-top: 8px;
}

.usage-grid .checkbox-label {
    margin: 0;
}

/* Action Buttons */
.filter-actions {
    margin: 20px 0 15px;
}

.btn-primary,
.btn-secondary {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1em;
    font-weight: 600;
    margin-bottom: 10px;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-primary {
    background: #048400;
    color: white;
}

.btn-primary:hover {
    background: #036600;
}

.btn-primary:active {
    transform: translateY(1px);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-secondary:active {
    transform: translateY(1px);
}

/* Results Summary */
.results-summary {
    background: white;
    padding: 12px;
    border-radius: 4px;
    text-align: center;
    font-weight: 600;
    color: #048400;
    border: 1px solid #e4fbea;
}

.results-summary .loading {
    color: #666;
}

.results-summary .error {
    color: #dc3545;
}

.results-summary .no-results {
    color: #666;
    font-weight: normal;
}

.results-summary .warning {
    color: #ff8800;
    font-size: 0.9em;
    font-weight: normal;
}

/* Map Container */
.trail-finder-map-wrapper {
    flex: 1;
    min-width: 0;
    position: relative;
}

#trail-finder-map {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    z-index: 1;
}

/* Hide unwanted map controls */
#trail-finder-map .leaflet-control-layers,
#trail-finder-map .leaflet-control-geocoder,
#trail-finder-map .leaflet-bar-part-single,
#trail-finder-map .leaflet-control-rotate,
#trail-finder-map .leaflet-control-fullscreen,
#trail-finder-map .leaflet-control-search,
#trail-finder-map .gm-style-cc,
#trail-finder-map .gmnoprint,
#trail-finder-map .gm-svpc,
#trail-finder-map .leaflet-control-minimap,
#trail-finder-map .leaflet-bottom-left > *:not(.leaflet-control-attribution) {
    display: none !important;
}

/* Keep only zoom and attribution */
#trail-finder-map .leaflet-control-zoom,
#trail-finder-map .leaflet-control-attribution {
    display: block !important;
}

/* Clickable trail cursor */
#trail-finder-map path {
    cursor: pointer;
}

/* Results Table */
.results-table-container {
    background: white;
    padding: 15px;
    margin-bottom: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.results-table-container h4 {
    margin: 0 0 15px 0;
    color: #048400;
    font-size: 1.2em;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95em;
}

.results-table th {
    background: #048400;
    color: white;
    padding: 10px;
    text-align: left;
    font-weight: 600;
}

.results-table th.sortable {
    user-select: none;
    position: relative;
    padding-right: 25px;
}

.results-table th.sortable:hover {
    background: #05a500;
}

.results-table th .sort-indicator {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 0.8em;
}

.results-table td {
    padding: 10px;
    border-bottom: 1px solid #e0e0e0;
}

.results-table tr:hover {
    background: #f5f5f5;
}

.results-table tr:last-child td {
    border-bottom: none;
}

.results-table td.calc-difficulty {
    font-style: italic;
    color: #666;
}

.results-table .trail-name-link {
    text-decoration: none;
    color: #048400;
    transition: color 0.2s;
    white-space: normal;
}

.results-table .trail-name-link:hover {
    color: #05a500;
    text-decoration: underline;
}

.results-table .trail-name-link .nowrap {
    white-space: nowrap;
}

.results-table .trail-name-link .chevron {
    font-size: 1.2em;
    color: #999;
    transition: color 0.2s, transform 0.2s;
    display: inline-block;
}

.results-table .trail-name-link:hover .chevron {
    color: #048400;
    transform: translateX(3px);
}

.view-details-btn {
    padding: 6px 12px;
    background: #048400;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
}

.view-details-btn:hover {
    background: #036600;
}

/* Map Loading Indicator */
.map-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    text-align: center;
    z-index: 1000;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 15px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #048400;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.map-loading p {
    margin: 0;
    color: #666;
    font-weight: 600;
}

/* Trail Popup Styles */
.trail-popup {
    min-width: 200px;
}

.trail-popup h4 {
    margin: 0 0 10px 0;
    color: #048400;
    font-size: 1.1em;
}

.trail-popup p {
    margin: 5px 0;
    font-size: 0.9em;
}

.trail-details-link {
    display: inline-block;
    margin-top: 10px;
    padding: 8px 14px;
    background: #048400;
    color: white !important;
    text-decoration: none;
    border-radius: 4px;
    font-size: 0.9em;
    transition: background-color 0.2s;
}

.trail-details-link:hover {
    background: #036600;
    text-decoration: none;
}

/* Trail Details Modal */
.trail-details-modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(2px);
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    color: #aaa;
    font-size: 32px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close-modal:hover,
.close-modal:focus {
    color: #000;
}

.modal-content h2 {
    margin: 0 0 20px 0;
    color: #048400;
    font-size: 1.8em;
}

.trail-image {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 15px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.trail-stats {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 6px;
    margin: 15px 0;
}

.trail-stats p {
    margin: 8px 0;
    font-size: 1em;
}

.trail-summary {
    margin: 20px 0;
}

.trail-summary h3 {
    color: #333;
    font-size: 1.2em;
    margin: 0 0 10px 0;
}

.trail-summary p {
    line-height: 1.6;
    color: #555;
}

.trail-alert {
    background: #fff3cd;
    border-left: 4px solid #ffc107;
    padding: 15px;
    border-radius: 4px;
    margin: 15px 0;
}

.trail-links {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.trail-links a {
    padding: 10px 20px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 600;
    transition: background-color 0.2s;
}

.trail-links .btn-primary {
    width: auto;
    margin: 0;
    background: #048400;
    color: white;
}

.trail-links .btn-primary:hover {
    background: #05a500;
    color: white !important;
    text-decoration: none;
}

.trail-links .btn-secondary {
    width: auto;
    margin: 0;
    background: #6c757d;
    color: white;
}

.trail-links .btn-secondary:hover {
    background: #545b62;
    color: white !important;
    text-decoration: none;
}

/* Responsive Design */
@media (max-width: 900px) {
    .trail-finder-container {
        flex-direction: column;
    }

    .trail-finder-sidebar {
        flex: 1;
        max-height: none;
        max-width: 100%;
    }

    .trail-finder-map-wrapper {
        min-height: 500px;
    }

    .modal-content {
        width: 95%;
        margin: 10% auto;
        padding: 20px;
    }

    .close-modal {
        top: 10px;
        right: 15px;
    }

    /* Hide calculated difficulty on tablets too */
    .results-table th:nth-child(3),
    .results-table td:nth-child(3) {
        display: none;
    }

    /* Reduce table padding on tablets */
    .results-table th,
    .results-table td {
        padding: 8px;
    }
}

@media (max-width: 600px) {
    .trail-finder-sidebar {
        padding: 15px;
    }

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

    .range-separator {
        display: none;
    }

    .trail-links {
        flex-direction: column;
    }

    .trail-links a {
        width: 100%;
        text-align: center;
    }

    /* Hide calculated difficulty and actions columns on mobile */
    .results-table th:nth-child(3),
    .results-table td:nth-child(3),
    .results-table th:nth-child(6),
    .results-table td:nth-child(6) {
        display: none;
    }

    /* Make trail name links more prominent on mobile */
    .results-table .trail-name-link {
        font-weight: 600;
        color: #048400;
    }

    /* Reduce table font size on mobile */
    .results-table {
        font-size: 0.85em;
    }

    .results-table th,
    .results-table td {
        padding: 8px 5px;
    }

    /* Make trail info modal narrower on mobile */
    .modal-content {
        width: 98%;
        margin: 2% auto;
        padding: 15px;
        max-height: 95vh;
    }

    .modal-content h2 {
        font-size: 1.3em;
    }

    .trail-image {
        max-width: 100%;
    }
}

/* Accessibility */
.filter-group input:focus,
.filter-group select:focus,
button:focus {
    outline: 2px solid #048400;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .trail-finder-sidebar,
    .trail-details-modal {
        display: none;
    }

    .trail-finder-container {
        flex-direction: column;
    }
}
