/* ═══════════════════════════════════════════════
   Rwanda Interactive Map — Frontend Styles
   Lyonsforth Ventures Limited (www.lyonsforth.com)
   ═══════════════════════════════════════════════ */

/* ── Variables ── */
:root {
    --rim-green-dark:    #1b4332;
    --rim-green-mid:     #2d6a4f;
    --rim-green-bright:  #52b788;
    --rim-green-light:   #d8f3dc;
    --rim-green-pale:    #f0faf5;
    --rim-white:         #ffffff;
    --rim-gray-100:      #f8f9fa;
    --rim-gray-200:      #e9ecef;
    --rim-gray-400:      #ced4da;
    --rim-gray-600:      #6c757d;
    --rim-gray-800:      #343a40;
    --rim-shadow-sm:     0 1px 4px rgba(0,0,0,.08);
    --rim-shadow-md:     0 4px 16px rgba(0,0,0,.10);
    --rim-shadow-lg:     0 8px 32px rgba(0,0,0,.12);
    --rim-radius:        12px;
    --rim-radius-sm:     8px;
    --rim-transition:    all .22s cubic-bezier(.4,0,.2,1);
}

/* ── Wrapper ── */
.rim-wrapper {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto 40px;
    color: var(--rim-gray-800);
    line-height: 1.5;
}

/* ── Header ── */
.rim-header {
    background: linear-gradient(135deg, var(--rim-green-dark) 0%, var(--rim-green-mid) 100%);
    border-radius: var(--rim-radius) var(--rim-radius) 0 0;
    padding: 24px 28px 20px;
    color: var(--rim-white);
}

.rim-header-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
}

.rim-logo-area {
    display: flex;
    align-items: center;
    gap: 14px;
}

.rim-flag {
    font-size: 2.2rem;
    line-height: 1;
}

.rim-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -.3px;
    color: var(--rim-white);
}

.rim-subtitle {
    margin: 3px 0 0;
    font-size: .85rem;
    opacity: .75;
}

/* Province legend */
.rim-province-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: flex-end;
}

.rim-prov-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(255,255,255,.15);
    border-radius: 20px;
    padding: 4px 10px;
    font-size: .75rem;
    font-weight: 500;
    cursor: default;
    backdrop-filter: blur(4px);
    transition: var(--rim-transition);
}

.rim-prov-chip:hover {
    background: rgba(255,255,255,.28);
}

.rim-prov-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

/* ── Body layout ── */
.rim-body {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 0;
    background: var(--rim-gray-100);
    border-left: 1px solid var(--rim-gray-200);
    border-right: 1px solid var(--rim-gray-200);
}

@media (max-width: 768px) {
    .rim-body { grid-template-columns: 1fr; }
}

/* ── Map ── */
.rim-map-container {
    position: relative;
}

#rim-map {
    width: 100%;
    border-radius: 0;
    z-index: 1;
    background: #e8f4f0;
}

#rim-map .leaflet-container {
    background: #e8f4f0 !important;
}

/* Hide Leaflet attribution for clean look (keep if required by license) */
.rim-map-container .leaflet-control-attribution {
    font-size: 10px;
    opacity: .6;
}

/* Loading overlay */
.rim-map-loading {
    position: absolute;
    inset: 0;
    background: rgba(232, 244, 240, .9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: .9rem;
    color: var(--rim-green-dark);
    font-weight: 500;
    z-index: 999;
    border-radius: 0;
    transition: opacity .4s ease;
}

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

.rim-spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--rim-green-light);
    border-top-color: var(--rim-green-mid);
    border-radius: 50%;
    animation: rim-spin .7s linear infinite;
}

@keyframes rim-spin {
    to { transform: rotate(360deg); }
}

/* ── Sidebar ── */
.rim-sidebar {
    background: var(--rim-white);
    border-left: 1px solid var(--rim-gray-200);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    min-height: 320px;
}

/* Default state */
.rim-sidebar-default {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-top: 20px;
}

.rim-sidebar-icon {
    font-size: 2.5rem;
    opacity: .6;
}

.rim-sidebar-default h3 {
    margin: 0;
    font-size: 1.05rem;
    color: var(--rim-green-dark);
    font-weight: 700;
}

.rim-sidebar-default p {
    margin: 0;
    font-size: .83rem;
    color: var(--rim-gray-600);
    line-height: 1.5;
}

.rim-stats {
    display: flex;
    gap: 12px;
    margin-top: 16px;
}

.rim-stat {
    background: var(--rim-green-pale);
    border-radius: var(--rim-radius-sm);
    padding: 10px 14px;
    text-align: center;
    flex: 1;
}

.rim-stat-num {
    display: block;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--rim-green-dark);
    line-height: 1;
}

.rim-stat-label {
    display: block;
    font-size: .7rem;
    color: var(--rim-gray-600);
    margin-top: 3px;
    text-transform: uppercase;
    letter-spacing: .5px;
}

/* Detail state */
.rim-sidebar-detail {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.rim-back-btn {
    font-size: .8rem;
    color: var(--rim-green-bright);
    cursor: pointer;
    font-weight: 600;
    width: fit-content;
    padding: 4px 0;
    transition: var(--rim-transition);
    user-select: none;
}

.rim-back-btn:hover { color: var(--rim-green-dark); }

.rim-district-badge {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--rim-green-mid), var(--rim-green-dark));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-top: 4px;
}

.rim-district-name {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--rim-green-dark);
    line-height: 1.2;
}

.rim-district-province {
    margin: 0;
    font-size: .8rem;
    color: var(--rim-gray-600);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 5px;
}

.rim-district-province::before {
    content: '📍';
    font-size: .8rem;
}

.rim-district-link-wrap {
    margin-top: 8px;
}

.rim-visit-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: linear-gradient(135deg, var(--rim-green-mid), var(--rim-green-dark));
    color: var(--rim-white) !important;
    text-decoration: none !important;
    padding: 10px 18px;
    border-radius: var(--rim-radius-sm);
    font-size: .88rem;
    font-weight: 600;
    transition: var(--rim-transition);
    box-shadow: var(--rim-shadow-sm);
    width: 100%;
    justify-content: center;
}

.rim-visit-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--rim-shadow-md);
    background: linear-gradient(135deg, var(--rim-green-dark), #0f2d1f);
}

.rim-no-link {
    background: var(--rim-gray-100);
    border: 1px dashed var(--rim-gray-400);
    border-radius: var(--rim-radius-sm);
    padding: 10px 14px;
    font-size: .82rem;
    color: var(--rim-gray-600);
    text-align: center;
}

/* ── District grid ── */
.rim-districts-grid {
    background: var(--rim-white);
    border: 1px solid var(--rim-gray-200);
    border-top: none;
    border-radius: 0 0 var(--rim-radius) var(--rim-radius);
    padding: 24px 28px 28px;
}

.rim-grid-title {
    margin: 0 0 16px;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--rim-gray-600);
    font-weight: 600;
}

.rim-grid-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
}

.rim-grid-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 10px 12px;
    background: var(--rim-gray-100);
    border: 1px solid var(--rim-gray-200);
    border-radius: var(--rim-radius-sm);
    text-decoration: none !important;
    cursor: pointer;
    transition: var(--rim-transition);
    color: var(--rim-gray-800);
    position: relative;
    overflow: hidden;
}

.rim-grid-item::before {
    content: '';
    position: absolute;
    left: 0; top: 0; bottom: 0;
    width: 3px;
    background: var(--rim-green-bright);
    opacity: 0;
    transition: opacity .2s;
}

.rim-grid-item:hover {
    background: var(--rim-green-pale);
    border-color: var(--rim-green-bright);
    transform: translateY(-2px);
    box-shadow: var(--rim-shadow-sm);
    color: var(--rim-green-dark);
}

.rim-grid-item:hover::before { opacity: 1; }

.rim-grid-item.active {
    background: var(--rim-green-pale);
    border-color: var(--rim-green-dark);
    color: var(--rim-green-dark);
}

.rim-grid-item.active::before { opacity: 1; background: var(--rim-green-dark); }

.rim-grid-name {
    font-size: .88rem;
    font-weight: 600;
    line-height: 1.2;
}

.rim-grid-prov {
    font-size: .72rem;
    color: var(--rim-gray-600);
    font-weight: 400;
}

/* ── Leaflet popup customization ── */
.rim-popup .leaflet-popup-content-wrapper {
    border-radius: 10px;
    box-shadow: var(--rim-shadow-lg);
    padding: 0;
    overflow: hidden;
    border: none;
}

.rim-popup .leaflet-popup-content {
    margin: 0;
    padding: 0;
}

.rim-popup-inner {
    padding: 10px 14px;
    min-width: 130px;
}

.rim-popup-district {
    font-size: .92rem;
    font-weight: 700;
    color: var(--rim-green-dark);
}

.rim-popup-province {
    font-size: .75rem;
    color: var(--rim-gray-600);
    margin-top: 2px;
}

.rim-popup .leaflet-popup-tip {
    background: white;
}

/* ── Tooltip ── */
.rim-tooltip {
    background: var(--rim-green-dark);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 5px 10px;
    font-size: .8rem;
    font-weight: 600;
    box-shadow: var(--rim-shadow-md);
    white-space: nowrap;
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .rim-header { padding: 16px; }
    .rim-title { font-size: 1.2rem; }
    .rim-province-legend { display: none; }
    .rim-grid-items { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
    .rim-districts-grid { padding: 16px; }
}

/* ── District name labels (always visible on map) ── */
.rim-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    pointer-events: none;
}

.rim-label-text {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: #1b4332;
    text-align: center;
    white-space: nowrap;
    text-shadow:
        1px  1px 0 rgba(255,255,255,.95),
       -1px  1px 0 rgba(255,255,255,.95),
        1px -1px 0 rgba(255,255,255,.95),
       -1px -1px 0 rgba(255,255,255,.95),
        0    2px 0 rgba(255,255,255,.90),
        0   -2px 0 rgba(255,255,255,.90),
        2px  0   0 rgba(255,255,255,.90),
       -2px  0   0 rgba(255,255,255,.90);
    letter-spacing: .3px;
    line-height: 1.2;
    transform: translateX(-50%);
    pointer-events: none;
    user-select: none;
    cursor: default;
}
