/* Base Styles (Light Mode) */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f6;
    color: #333;
    padding: 20px;
    max-width: 900px;
    margin: auto;
    line-height: 1.6;
    transition: background-color 0.3s ease, color 0.3s ease;
}

h1 {
    text-align: center;
    color: #fc4c02;
    margin-bottom: 30px;
}

/* Toggle Button */
.theme-toggle {
    position: absolute;
    top: 20px;
    right: 20px;
    background: none;
    border: 2px solid #fc4c02;
    color: #fc4c02;
    padding: 8px 16px;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    z-index: 10;
}

.theme-toggle:hover {
    background: #fc4c02;
    color: white;
}

/* Dashboard & Activity Grid */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 40px;
}

.stat-card {
    background: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    text-align: center;
    transition: background-color 0.3s ease;
}

.stat-card h4 {
    margin: 0;
    color: #888;
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-card .value {
    font-size: 1.8em;
    font-weight: bold;
    color: #222;
    margin-top: 10px;
}

.activity-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 25px;
}

.activity {
    background: white;
    padding: 25px;
    border-radius: 16px;
    box-shadow: 0 10px 15px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease, background-color 0.3s ease;
    cursor: pointer;
}

.activity:hover {
    transform: translateY(-3px);
    box-shadow: 0 15px 25px rgba(0, 0, 0, 0.1);
}

.activity h3 {
    margin: 0 0 15px 0;
    color: #fc4c02;
    font-size: 1.4em;
    pointer-events: none;
}

.activity-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    font-size: 1.1em;
    pointer-events: none;
    color: #333;
}

.map-container {
    height: 300px;
    width: 100%;
    border-radius: 12px;
    z-index: 1;
    border: 1px solid #eee;
    pointer-events: none;
    transition: filter 0.3s ease;
}

/* Modal Styles */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, background 0.3s ease;
}

.modal-backdrop.show {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: white;
    width: 90vw;
    height: 90vh;
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.2);
    padding: 30px;
    position: relative;
    transform: scale(0.95);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), background-color 0.3s ease;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    box-sizing: border-box;
}

.modal-backdrop.show .modal-content {
    transform: scale(1);
}

#close-modal {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #eee;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #333;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    z-index: 10;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.3s ease;
}

#close-modal:hover {
    background: #ddd;
}

.modal-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.modal-stat {
    background: #f4f7f6;
    padding: 15px;
    border-radius: 10px;
    text-align: center;
    transition: background-color 0.3s ease;
}

.modal-stat h4 {
    margin: 0 0 5px 0;
    font-size: 0.8em;
    color: #666;
    text-transform: uppercase;
}

.modal-stat .val {
    font-size: 1.2em;
    font-weight: bold;
    color: #222;
}

.modal-map {
    flex-grow: 1;
    border-radius: 12px;
    min-height: 300px;
    z-index: 1;
    border: 1px solid #eee;
    transition: filter 0.3s ease;
}

/* --- DARK MODE OVERRIDES --- */
body.dark-mode {
    background-color: #121212;
    color: #e0e0e0;
}

body.dark-mode .stat-card,
body.dark-mode .activity,
body.dark-mode .modal-content {
    background: #1e1e1e;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

body.dark-mode .modal-stat {
    background: #2c2c2c;
}

body.dark-mode .stat-card .value,
body.dark-mode .modal-stat .val,
body.dark-mode .activity-stats {
    color: #fff;
}

body.dark-mode .stat-card h4,
body.dark-mode .modal-stat h4,
body.dark-mode p#last-updated,
body.dark-mode .modal-content p {
    color: #aaa !important;
}

body.dark-mode .map-container,
body.dark-mode .modal-map {
    border-color: #333;
    filter: invert(100%) hue-rotate(180deg) brightness(95%) contrast(90%);
}

/* Turns the map dark! */
body.dark-mode .modal-backdrop {
    background: rgba(0, 0, 0, 0.6);
}

body.dark-mode #close-modal {
    background: #333;
    color: #fff;
}

body.dark-mode #close-modal:hover {
    background: #444;
}