/* ========== General Styles ========== */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

img {
    max-width: 350px;
    border-radius: 5px;
}

b, p {
    white-space: break-spaces;
}
body.loading {
    overflow: hidden;
}
body.loading #map {
    visibility: hidden;
}

body.loading {
    overflow: hidden;
    height: 100vh;
}

body.loading #map,
body.loading .sidebar,
body.loading .position-absolute { /* This targets the country select dropdown */
    visibility: hidden;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease-out;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}
/* ========== Map ========== */
#map {
    height: 100vh;
    width: 100%;
    z-index: 1;
}

/* ========== Leaflet Extra Markers ========== */
.extra-marker {
    background: #fff;
    border: 2px solid #333;
    border-radius: 0;
    box-shadow: 0 3px 14px rgba(0,0,0,0.4);
    color: #333;
    font-size: 14px;
    font-weight: bold;
    text-align: center;
    width: 35px;
    height: 45px;
    line-height: 30px;
    position: relative;
}

.extra-marker i {
    color: #333;
    margin-top: 10px;
    display: inline-block;
    font-size: 14px;
}

.extra-marker.extra-marker-square {
    border-radius: 0;
    width: 30px;
    height: 30px;
    line-height: 30px;
    position: relative;
    border: none;
}

.extra-marker.extra-marker-square::after {
    content: '';
    position: absolute;
    bottom: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 12px solid currentColor;
    z-index: 1;
}

.extra-marker.extra-marker-square i {
    margin-top: 5px;
    position: relative;
    z-index: 2;
}

/* Marker Colors */
.extra-marker.extra-marker-blue {
    background: #00f;
    border-color: #00d;
    color: #fff;
}

.extra-marker.extra-marker-blue i {
    color: #fff;
}

.extra-marker.extra-marker-green {
    background: #0a0;
    border-color: #080;
    color: #fff;
}

.extra-marker.extra-marker-green i {
    color: #fff;
}

.extra-marker.extra-marker-purple {
    background: #808;
    border-color: #606;
    color: #fff;
}

.extra-marker.extra-marker-purple i {
    color: #fff;
}

.extra-marker.extra-marker-orange {
    background: #f80;
    border-color: #d60;
    color: #fff;
}

.extra-marker.extra-marker-orange i {
    color: #fff;
}

.extra-marker.extra-marker-red {
    background: #d00;
    border-color: #a00;
    color: #fff;
}

.extra-marker.extra-marker-red i {
    color: #fff;
}

/* ========== Marker Clusters ========== */
.marker-cluster {
    background-clip: padding-box;
    border-radius: 20px;
}

.marker-cluster div {
    width: 30px;
    height: 30px;
    margin-left: 5px;
    margin-top: 5px;
    text-align: center;
    border-radius: 15px;
    font: 12px "Helvetica Neue", Arial, Helvetica, sans-serif;
    font-weight: bold;
    color: #fff;
}

.marker-cluster span {
    line-height: 30px;
}

.marker-cluster-small {
    background-color: rgba(181, 226, 140, 0.6);
}

.marker-cluster-small div {
    background-color: rgba(110, 204, 57, 0.6);
}

.marker-cluster-medium {
    background-color: rgba(241, 211, 87, 0.6);
}

.marker-cluster-medium div {
    background-color: rgba(240, 194, 12, 0.6);
}

.marker-cluster-large {
    background-color: rgba(253, 156, 115, 0.6);
}

.marker-cluster-large div {
    background-color: rgba(241, 128, 23, 0.6);
}

/* ========== Sidebar Buttons ========== */

/* Add to style.css */
.container-fluid, .sidebar {
    opacity: 0;
    transition: opacity 0.5s ease-in;
}

body:not(.loading) .container-fluid,
body:not(.loading) .sidebar {
    opacity: 1;
}
.sidebar {
    position: fixed;
    top: 20%;
    left: 12px;
    z-index: 9999;
}

.sidebar button {
    background-color: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 14px;
    margin-bottom: 5px;
    width: 34px;
    height: 34px;
    text-align: center;
    line-height: 1;
    color: #000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar button:hover {
    background-color: #f0f0f0;
}

/* ========== Country Select ========== */
.position-relative {
    position: relative;
}

.position-absolute {
    position: absolute;
}

.top-0 {
    top: 0;
}

.start-50 {
    left: 50%;
}

.translate-middle-x {
    transform: translateX(-50%);
}

.mt-3 {
    margin-top: 1rem;
}

/* Geolocation button styles */
#detectLocation {
    width: 40px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    transition: all 0.2s ease;
}

#detectLocation:hover {
    background-color: #0d6efd;
    color: white;
    border-color: #0d6efd;
}

#detectLocation:active {
    transform: scale(0.95);
}

/* ========== Modal Styles ========== */
.modal-content {
    border-radius: 10px;
    overflow: hidden;
}

/* Vertically center all modals */
.modal-dialog-centered {
    display: flex;
    align-items: center;
    min-height: calc(100% - 1rem);
}

/* Scrollable modal body if content overflows */
.modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

/* Info Modal Content */
.info-item {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}

.info-item i {
    font-size: 1.5rem;
    color: #0d6efd;
    margin-right: 1rem;
    width: 30px;
    text-align: center;
}

.info-item .label {
    font-weight: 600;
    color: #555;
    font-size: 0.9rem;
    display: block;
}

.info-item .value {
    font-size: 1.1rem;
}

/* Country Flag */
#countryFlag img {
    max-width: 150px;
    height: auto;
    border: 1px solid #ccc;
    border-radius: 3px;
}

/* Weather Modal */
#countryWeatherModal h1 span {
    font-size: 4rem;
}

#countryWeatherModal .row.text-center .col-md-4 {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: start;
    padding-top: 1rem;
}

#countryWeatherModal img {
    width: 48px;
    height: 48px;
    object-fit: contain;
    margin: 8px 0;
}

#countryWeatherModal .modal-footer {
    text-align: center;
    justify-content: center;
    width: 100%;
}

/* Wikipedia Modal */
.wikipedia-container {
    position: relative;
    overflow: hidden;
    background: #f8f9fa;
    border-radius: 5px;
    border: 1px solid #dee2e6;
    height: 70vh;
}

.wikipedia-container iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* News Modal */
#countryNewsModal .modal-dialog {
    max-width: 700px;
}

#countryNewsModal .modal-body {
    padding: 0;
}

#allNews {
    max-height: 60vh;
    overflow-y: auto;
    padding: 1rem;
}

.news-card {
    margin-bottom: 1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
}

.news-card:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.news-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.news-text {
    font-size: 0.95rem;
    color: #555;
}

.news-img-container img {
    max-height: 200px;
    width: 100%;
    object-fit: cover;
}

.news-meta {
    font-size: 0.85rem;
}

/* Card Styles */
.card {
    background: #ffffff;
    border: 1px solid #ddd;
    border-radius: 1rem;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    padding: 1.5rem;
    margin: 1rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.15);
}

.card b {
    font-size: 1.2rem;
    color: #333;
}

.card p {
    font-size: 0.95rem;
    color: #555;
    margin: 0.5rem 0;
}

.card img {
    width: 100%;
    height: auto;
    border-radius: 8px;
    object-fit: cover;
}

.card-header b {
    margin: 0 0 1rem 0;
    font-size: 1.5rem;
    color: #2c3e50;
    border-bottom: 2px solid #3498db;
    padding-bottom: 0.5rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    transition: opacity 0.3s ease-out;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

/* News separator style */
.news-separator {
    border: none;
    border-top: 1px solid #000;
    margin: 15px 20px;
    width: calc(100% - 40px);
}

/* ========== Responsive Styles ========== */
@media (max-width: 768px) {
    #countrySelect {
        width: 120px;
    }
    /* Move layers and zoom controls below the select bar */
    .leaflet-control-layers,
    .leaflet-control-zoom {
        top: 50px !important;
        right: 10px !important;
    }
    
    #detectLocation {
        width: 38px;
        height: 38px;
    }

    .sidebar {
        top: auto;
        bottom: 20px;
        left: 50%;
        transform: translateX(-50%);
        display: flex;
        gap: 5px;
    }

    .sidebar button {
        margin-bottom: 0;
    }

    .modal-dialog {
        margin: 0.5rem;
    }

    #allNews {
        max-height: 50vh;
    }

    .news-card {
        padding: 0.75rem;
    }

    .wikipedia-container {
        height: 50vh;
    }

    .leaflet-control-layers .layer-label-icon {
        display: inline !important;
    }
    .leaflet-control-layers .layer-label-text {
        display: none !important;
    }
    .leaflet-control-layers label {
        min-width: 36px;
        text-align: center;
        padding: 0.2rem 0.2rem;
    }
    .leaflet-control-layers i.fa {
        font-size: 1.2rem;
        vertical-align: middle;
    }
}
@media (max-width: 576px) {
    #countrySelect {
        width: 90vw !important;
        max-width: 220px !important;
        min-width: 100px !important;
        font-size: 0.95rem;
    }
    
    #detectLocation {
        width: 36px;
        height: 36px;
        font-size: 0.9rem;
    }

    .modal-lg,
    .modal-xl {
        margin: 0.5rem;
        width: calc(100% - 1rem);
    }
}


.news-item h5 {
    font-weight: 700;
    font-size: 1.1rem;
    line-height: 1.4;
}

.news-item .text-muted {
    font-size: 0.85rem;
    color: #6c757d;
}

#countryNewsModal .modal-content {
    border: none;
    background-color: #f8f9fa;
}

#countryNewsModal .modal-header {
    padding-bottom: 0;
}

/* News Modal Custom Styles */
.news-modal-content {
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0,0,0,0.12);
}
.news-modal-header {
    background: linear-gradient(90deg, #0d6efd 0%, #0d6efd 100%);
    color: #fff;
    border-bottom: none;
    align-items: center;
}
.news-item {
    display: flex;
    align-items: stretch;
    gap: 0;
    padding: 0;
    min-height: 140px;
    margin: 10px 0 10px 10px;
}
.news-item img {
    width: 40%;
    height: 100%;
    object-fit: cover;
    border-radius: 10px;
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
    flex-shrink: 0;
    display: block;
    margin: 0 0 10px 10px;
}
.news-item > div {
    width: 50%;
    padding: 20px 20px 12px 20px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.news-item .news-headline {
    font-weight: bold;
    font-size: 1.1rem;
    margin-bottom: 4px;
    color: #222;
    text-decoration: underline;
}
.news-item .news-source {
    font-size: 0.8em;
    color: #666;
    margin-top: 2px;
}
.news-item .news-date {
    font-size: 0.75em;
    color: #888;
    margin-top: 2px;
    font-style: italic;
}
.news-separator {
    border: none;
    border-top: 1px solid #000;
    margin: 15px 20px;
    width: calc(100% - 40px);
}

.modal-content {
    border-radius: 0.5rem;
    border: none;
}

.modal-header.bg-success {
    background-color: #198754 !important;
    background-image: linear-gradient(180deg, #198754, #157347);
    color: white;
}

.modal-header .btn-close-white {
    filter: invert(1) grayscale(100%) brightness(200%);
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(25, 135, 84, 0.05);
}

.table-striped tbody tr:hover {
    background-color: rgba(25, 135, 84, 0.1);
}

.table td {
    vertical-align: middle;
    padding: 0.75rem;
}

.fa-xl {
    font-size: 1.5em;
    line-height: 1.5em;
}

.text-success {
    color: #198754 !important;
}

.leaflet-control-layers .layer-label-icon {
    display: none;
}
.leaflet-control-layers .layer-label-text {
    display: inline;
}