/* =============================================================================
   MODAL COMPONENT
   ============================================================================= */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal--location {
    align-items: flex-start;
    padding-top: max(2vh, 1rem);
}

.modal__content {
    background: white;
    border-radius: 1rem;
    max-width: 600px;
    width: 100%;
    max-height: 95vh;
    display: flex;
    flex-direction: column;
    position: relative;
    animation: modalSlideIn 0.3s ease;
    overflow: hidden;
}

.modal--location .modal__content {
    height: min(85vh, 700px);
    max-height: 95vh;
}

.modal__close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: rgba(0, 0, 0, 0.1);
    border: none;
    font-size: 1.5rem;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    transition: background-color 0.2s ease;
}

.modal__close:hover {
    background: rgba(0, 0, 0, 0.2);
}

.modal__body {
    padding: 2rem;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.modal--location .modal__body {
    gap: 1rem;
    overflow-y: auto;
}

/* Ensure location search input is always visible */
.modal--location #location-search {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.modal__title {
    margin-bottom: 1rem;
    color: #333;
}

/* Search Results Component */
.search-results {
    max-height: 400px;
    overflow-y: auto;
    transition: opacity 0.2s ease;
}

.search-results--location {
    max-height: 120px;
    flex-shrink: 0;
}

.search-results__item {
    padding: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.search-results__item:hover {
    background: rgba(46, 125, 50, 0.05);
    border-color: #2E7D32;
}

.search-results__item--taxon {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.search-results__names {
    flex: 1;
}

.search-results__primary-name {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    color: #333;
}

.search-results__secondary-name {
    font-size: 0.9rem;
    color: #666;
    font-style: italic;
}

.search-results__coords {
    font-size: 0.9rem;
    color: #666;
    margin: 0;
}

.search-results__rank {
    font-size: 0.8rem;
    color: #888;
    background: #f5f5f5;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    text-transform: capitalize;
}

/* Search State Component */
.search-state {
    text-align: center;
    padding: 1.5rem 1rem;
    color: #666;
    font-style: italic;
}

.search-state__text {
    margin: 0;
    font-size: 0.9rem;
}

.search-state--prompt .search-state__text {
    color: #888;
}

.search-state--loading .search-state__text {
    color: #2E7D32;
}

.search-state--loading .search-state__spinner {
    margin: 0 auto 0.75rem auto;
    width: 24px;
    height: 24px;
    border: 3px solid #e0e0e0;
    border-top: 3px solid #2E7D32;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.search-state--error .search-state__text {
    color: #d32f2f;
}

.search-state--no-results .search-state__text {
    color: #888;
}

/* Map Component */
.map {
    width: 100%;
    height: max(300px, min(40vh, 400px));
    border: 2px solid #e0e0e0;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    overflow: hidden;
    position: relative;
    flex: 1;
    min-height: 250px;
}

.modal--location .map {
    height: calc(100% - 180px);
    flex: 1;
    min-height: 200px;
}

.map__container {
    height: 100%;
    width: 100%;
    border-radius: 0.5rem;
}

.map__loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.9);
    padding: 1rem;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    color: #666;
    z-index: 1000;
    pointer-events: none;
}

.map.is-loaded .map__loading {
    display: none;
}

/* Leaflet overrides */
.map .leaflet-control-attribution {
    font-size: 0.7rem;
    background: rgba(255, 255, 255, 0.8);
    margin: 0;
}

.map .leaflet-control-zoom {
    margin-left: 10px;
    margin-top: 10px;
}

.leaflet-popup-content-wrapper {
    border-radius: 0.5rem;
    font-family: inherit;
}

.leaflet-popup-content {
    margin: 0.5rem;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Location Confirmation Component */
.location-confirm {
    margin-top: 1rem;
    padding: 1rem;
    background: rgba(46, 125, 50, 0.05);
    border: 1px solid rgba(46, 125, 50, 0.2);
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.location-confirm__selection {
    margin-bottom: 0.75rem;
}

.location-confirm__name {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.25rem;
}

.location-confirm__coords {
    display: block;
    font-size: 0.85rem;
    color: #666;
    font-family: 'Courier New', monospace;
}

/* Share Component */
.share__qr {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

.share__url {
    background: #f5f5f5;
    padding: 1rem;
    border-radius: 0.5rem;
    font-family: monospace;
    word-break: break-all;
    margin: 1rem 0;
}

/* Help Component */
.help__title {
    font-size: 1.3rem;
    margin-bottom: 1rem;
    color: #2E7D32;
    font-weight: 600;
}

.help__content {
    line-height: 1.6;
}

.help__content p {
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

.help__content p:last-of-type {
    margin-bottom: 1rem;
}

.help__content a {
    color: #2E7D32;
    text-decoration: none;
    font-weight: 600;
}

.help__content a:hover {
    text-decoration: underline;
}

.help__links {
    margin-top: 0.5rem;
    text-align: center;
}

.help__links a {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background: #2E7D32;
    color: white !important;
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    transition: background 0.2s;
    border: none;
    cursor: pointer;
}

.help__links a:hover {
    background: #1B5E20;
}

.help__links a:visited,
.help__links a:link,
.help__links a:active {
    color: white !important;
}

.help__update-section {
    margin-top: 1rem;
    padding: 0.5rem 0 0 0;
    border-top: 1px solid rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.help__version {
    color: #666;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.help__version-number {
    font-weight: 500;
    color: #2E7D32;
}

.help__check-time {
    font-size: 0.75rem;
    color: #999;
}

.help__update-btn {
    background: transparent;
    color: #2E7D32;
    border: 1px solid #2E7D32;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.75rem;
    transition: all 0.2s;
}

.help__update-btn:hover {
    background: #2E7D32;
    color: white;
}

.help__update-btn:disabled {
    background: transparent;
    color: #ccc;
    border-color: #ccc;
    cursor: not-allowed;
}