/*
  Theme colours for light and dark mode.
  Everything else in this file uses these variables, so switching the
  .dark-mode class on the body changes the whole look at once.
*/
:root {
    --surface: #ffffff;
    --surface-2: #f1f4f9;
    --text: #1f2733;
    --muted: #6c7a89;
    --border: #e4e9f0;
    --accent: #000000;
    --page: #dfe6ef;
    --shadow: 0 10px 30px rgba(18, 38, 63, 0.18);
    --shadow-sm: 0 4px 14px rgba(18, 38, 63, 0.12);
    --radius: 16px;
}

body.dark-mode {
    --surface: #1d2531;
    --surface-2: #283142;
    --text: #e8edf4;
    --muted: #9aa7b6;
    --border: #344052;
    --accent: #ffffff;
    --page: #11161f;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
    --shadow-sm: 0 4px 14px rgba(0, 0, 0, 0.45);
}

/*
  This makes the page use the full browser height.
  It also removes the default space around the page.
*/
html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    background-color: var(--page);
}

/*
  These elements change colour with the theme, so a gentle transition
  keeps the switch between light and dark mode smooth.
*/
.modal-content,
.list-group-item,
.form-control,
.input-group-text,
.table,
#selectContainer,
#themeToggle,
.leaflet-bar button {
    transition:
        background-color 0.25s ease,
        color 0.25s ease,
        border-color 0.25s ease,
        box-shadow 0.25s ease;
}

/*
  This makes the Leaflet map fill all the screen.
*/
#map {
    bottom: 0;
    height: 100vh;
    left: 0;
    position: fixed;
    right: 0;
    top: 0;
    width: 100vw;
    background-color: var(--page);
}

/*
  In dark mode the light map tiles are recoloured to a dark style.
  Only the tile layer is filtered, so markers and labels stay correct.
*/
body.dark-mode .leaflet-tile-pane {
    filter: invert(1) hue-rotate(180deg) brightness(0.95) contrast(0.9)
        grayscale(0.15);
}

/*
  This puts the country select box at the top centre of the map.
  It stays above the map because of the z-index.
*/
#selectContainer {
    left: 50%;
    max-width: 550px;
    position: absolute;
    top: 12px;
    transform: translateX(-50%);
    z-index: 1000;
    background-color: var(--surface) !important;
    border: 1px solid var(--border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    padding: 5px 12px !important;
    display: flex;
    align-items: center;
    gap: 8px;
}

#countrySelect {
    border: none;
    background-color: transparent;
    color: var(--text);
    font-weight: 600;
    cursor: pointer;
    flex: 1 1 auto;
    min-width: 0;
    appearance: none;
    padding-right: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%231f2733' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 5px center;
}

body.dark-mode #countrySelect {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23e8edf4' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
}

#countrySelect:focus {
    box-shadow: none;
}

body.dark-mode #countrySelect option {
    background-color: var(--surface);
    color: var(--text);
}

/*
  This is the round button that switches between light and dark mode.
  It sits in the top right corner, clear of the other map controls.
*/
#themeToggle {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    border-radius: 20%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    font-size: 1.15rem;
    border: 1px solid var(--border);
    background-color: var(--surface);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

#themeToggle:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/*
  This is the full screen loader.
  It covers the page while the first country data is loading.
*/
#preloader {
    height: 100%;
    left: 0;
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 2000;
    background-color: var(--surface) !important;
    color: var(--text);
}

/*
  This makes sure the loader is really hidden when d-none is added.
*/
#preloader.d-none {
    display: none !important;
}

/*
  This is the small warning message at the bottom of the screen.
*/
#statusBox {
    bottom: 20px;
    left: 50%;
    max-width: 420px;
    position: absolute;
    transform: translateX(-50%);
    width: 90%;
    z-index: 1000;
    border: none;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

/* 
   Modals: rounded, soft shadow, and theme aware bodies.
*/
.modal-content {
    border: none;
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    background-color: var(--surface);
    color: var(--text);
}

.modal-header {
    border-bottom: none;
    padding: 1rem 1.25rem;
}

.modal-title {
    font-weight: 700;
    letter-spacing: 0.2px;
}

.modal-body {
    background-color: var(--surface);
    color: var(--text);
}

/* Dark mode modal enhancements */
body.dark-mode .modal-content {
    background-color: var(--surface);
    border: 1px solid var(--border);
}

body.dark-mode .modal-header {
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

body.dark-mode .modal-title {
    color: #fff;
}

.mh-yellow-green .modal-title,
.mh-amber-gold .modal-title,
.mh-amber-glow .modal-title {
    color: #1a1a1a !important;
}

body.dark-mode .modal-body {
    background-color: var(--surface);
    color: var(--text);
}

body.dark-mode .modal-footer {
    border-top: 1px solid var(--border);
    color: var(--text);
}

body.dark-mode .btn-close {
    filter: invert(1);
}

body.dark-mode .badge.text-bg-primary {
    background-color: #0d6efd !important;
    color: white !important;
}

body.dark-mode .badge.text-bg-success {
    background-color: #198754 !important;
    color: white !important;
}

body.dark-mode .badge.text-bg-info {
    background-color: #0dcaf0 !important;
    color: white !important;
}

body.dark-mode .badge.text-bg-warning {
    background-color: #ffc107 !important;
    color: #000 !important;
}

body.dark-mode .badge.text-bg-danger {
    background-color: #dc3545 !important;
    color: white !important;
}

/*
  Tables, lists, badges and inputs follow the theme colours.
*/
.table {
    color: var(--text);
}

.table th,
.table td {
    border-color: var(--border);
    color: var(--text);
    padding: 0.75rem;
    background-color: transparent;
}

.table-sm th,
.table-sm td {
    border-color: var(--border);
    color: var(--text);
    padding: 0.5rem;
    background-color: transparent;
}

body.dark-mode .table {
    color: var(--text);
    border-color: var(--border);
    background-color: transparent;
}

body.dark-mode .table thead {
    background-color: transparent;
}

body.dark-mode .table tbody {
    background-color: transparent;
}

body.dark-mode .table tbody td {
    color: var(--text);
    border-color: var(--border);
    background-color: transparent;
}

body.dark-mode .table-borderless tbody td {
    color: var(--text);
    border-color: var(--border);
    padding: 0.75rem 0;
    background-color: transparent;
}

.list-group-item {
    background-color: transparent;
    color: var(--text);
    border-color: var(--border);
}

.list-group-item-action:hover {
    background-color: var(--surface-2);
}

.text-bg-light {
    background-color: var(--surface-2);
    color: var(--text);
    border: 1px solid var(--border);
}

.form-control {
    background-color: var(--surface);
    color: var(--text);
    border-color: var(--border);
    border-radius: 10px;
}

.form-control:focus {
    background-color: var(--surface);
    color: var(--text);
    border-color: var(--accent);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.18);
}

.form-control::placeholder {
    color: var(--muted);
}

.input-group-text {
    background-color: var(--surface-2);
    color: var(--muted);
    border-color: var(--border);
}

body.dark-mode .text-muted {
    color: var(--muted) !important;
}

body.dark-mode .border-top {
    border-color: var(--border) !important;
}

body.dark-mode textarea[readonly],
body.dark-mode input[readonly] {
    background-color: var(--surface-2);
}

/* 
  Buttons get a small lift on hover for a more tactile feel. 
*/
.btn {
    border-radius: 10px;
    transition:
        transform 0.15s ease,
        box-shadow 0.15s ease,
        filter 0.15s ease;
}

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

/*
  This keeps the flag image from becoming too tall inside the modal.
  Centers the flag image both horizontally and vertically.
*/
.flagImage {
    max-height: 130px;
    border-radius: 10px;
    display: block;
    margin: 0 auto;
    width: auto;
}

/*
  Leaflet ExtraMarkers.
*/
.extra-marker i.fa-solid,
.extra-marker i.fa-regular,
.extra-marker i.fa-brands {
    position: absolute;
    left:51%;
    top:20%;
    width: 100%;
    height: 100%;
    font-size: 10px;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.leaflet-bar {
    border: none !important;
    border-radius: 20%;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.leaflet-bar button,
.leaflet-bar button:hover,
.leaflet-bar a,
.leaflet-touch .leaflet-bar button,
.leaflet-touch .leaflet-bar a {
    height: 44px;
    width: 44px;
    line-height: 44px;
    border-radius: 20%;
    background-color: var(--surface);
    color: var(--text);
    border: 1px solid var(--border) !important;
    font-size: 1rem;
}

.leaflet-bar button:hover,
.leaflet-bar a:hover {
    background-color: var(--surface-2);
    color: var(--accent);
}


.leaflet-control-layers,
.leaflet-control-attribution {
    border-radius: 10px;
    background-color: var(--surface) !important;
    color: var(--text);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border) !important;
}

/*
  The layers control sits in the top right, the same corner as the theme
  toggle, so it is pushed down to sit just below the toggle button.
*/
.leaflet-right .leaflet-control-layers {
    margin-top: 62px;
}

/* 
   Polished layers menu: heading, hover rows, coloured checkboxes,
   sliding unit switches with the active unit highlighted.
*/
.leaflet-control-layers-expanded {
    padding: 12px 14px !important;
    min-width: 216px;
}

/* Little uppercase heading above the extra options. */
.layers-heading {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.7px;
    text-transform: uppercase;
    color: var(--muted);
    padding: 2px 6px 8px;
}

.layers-heading i {
    margin-right: 6px;
    opacity: 0.8;
}

/* Each option is a rounded row that highlights on hover. */
.leaflet-control-layers-overlays label {
    display: flex;
    align-items: center;
    margin: 2px 0;
    padding: 7px 9px;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.leaflet-control-layers-overlays label:hover {
    background-color: var(--surface-2);
}

/* The native Cities / Airports / Show all cities checkboxes. */
.leaflet-control-layers-selector {
    width: 17px;
    height: 17px;
    margin-right: 9px;
    accent-color: #0d6efd;
    cursor: pointer;
}

.leaflet-control-layers-separator {
    margin: 9px 2px;
    border-top: 1px solid var(--border);
}

/* Sliding on/off switch built from a hidden checkbox. */
.layer-switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    flex: 0 0 auto;
}

.layer-switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.layer-slider {
    position: absolute;
    inset: 0;
    background-color: var(--muted);
    border-radius: 999px;
    transition: background-color 0.25s ease;
}

.layer-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background-color: var(--surface);
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
    transition: transform 0.25s ease;
}

/* The switch keeps the same colour on and off; only the knob slides. */
.layer-switch input:checked + .layer-slider::before {
    transform: translateX(18px);
}

/* Unit switch with a label on each side: KM [ o] ML, °C [ o] °F. */
.unit-toggle {
    justify-content: center;
    gap: 10px;
}

.unit-label {
    font-weight: 600;
    color: var(--muted);
    min-width: 26px;
    text-align: center;
    transition:
        color 0.2s ease,
        font-weight 0.2s ease;
}

.unit-label.unit-active {
    color: #2f9e44;
    font-weight: 800;
}

/*
  When collapsed, the layers control is a round button like the theme toggle.
  The .leaflet-touch selectors keep it round on phones and tablets too.
*/
.leaflet-control-layers.leaflet-control-layers-collapsed,
.leaflet-touch .leaflet-control-layers.leaflet-control-layers-collapsed {
    width: 44px;
    height: 44px;
    border-radius: 20% !important;
}

.leaflet-control-layers-toggle,
.leaflet-touch .leaflet-control-layers-toggle {
    width: 44px;
    height: 44px;
    border-radius: 20%;
    background-color: var(--surface);
    background-size: 22px 22px;
}

body.dark-mode .leaflet-control-attribution a {
    color: var(--accent);
}

/* Currency modal. */
#currencyConverter {
    padding: 1.5rem;
    border-radius: 12px;
    background-color: var(--surface-2);
}

.form-row {
    display: flex;
    gap: 0.75rem;
}

#currencyAmount,
#currencyBase,
#currencyTarget {
    border-radius: 8px;
    border: 1px solid var(--border);
}

#currencyResult {
    background: #009688;
    color: white;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    text-align: center;
}


/* Breaking News modal. */
#newsList {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.news-item {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem;
    background-color: var(--surface-2);
    transition: all 0.2s ease;
}

.news-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}

.news-item-title {
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
    line-height: 1.3;
}

.news-item-description {
    color: var(--muted);
    font-size: 0.85rem;
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

.news-item-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.8rem;
}

.news-item-source {
    background-color: var(--surface);
    padding: 0.25rem 0.6rem;
    border-radius: 4px;
    color: var(--text);
    font-weight: 500;
}

.news-item-date {
    color: var(--muted);
}

.news-item-link {
    color: #dc3545;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.8rem;
    transition: color 0.2s ease;
}

.news-item-link:hover {
    color: #bb2d3b;
    text-decoration: underline;
}

body.dark-mode .news-item-link {
    color: #ff6b6b;
}

body.dark-mode .news-item-link:hover {
    color: #ff8787;
}

/* Weather modal.*/
.weather-modal-body {
    background-color: var(--surface);
    padding: 1rem;
}

.weather-today-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    background-color: var(--surface);
    margin-bottom: 1rem;
}

.weather-today-label {
    font-weight: bold;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    margin-bottom: 0.75rem;
}

.mh-blue-energy  { background-color: #448aff; color: #fff; }
.mh-ocean-deep   { background-color: #ea714a; color: #fff; }
.mh-verdigris    { background-color: #009688; color: #fff; }
.mh-yellow-green { background-color: #dddddf; color: #1a1a1a; }
.mh-amber-gold   { background-color: #ffc107; color: #1a1a1a; }
.mh-amber-glow   { background-color: #ffffcc; color: #1a1a1a; }
.mh-cinnabar     { background-color: #f44336; color: #fff; }
.mh-cherry-rose  { background-color: #ad1457; color: #fff; }

.share-email-btn {
    background-color: #ad1457;
    color: #fff;
    border-color: #ad1457;
}

.share-email-btn:hover,
.share-email-btn:focus {
    background-color: #880e4f;
    color: #fff;
    border-color: #880e4f;
}

.weather-today-row {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 0.5rem;
}

.weather-condition-text {
    font-weight: bold;
    font-size: 0.9rem;
    flex: 1;
    margin-bottom: 0;
    color: var(--text);
}

.weather-icon-img {
    width: 64px;
    height: 64px;
    flex-shrink: 0;
}

.weather-temp-group {
    text-align: right;
    flex-shrink: 0;
}

.weather-temp-main {
    font-size: 2rem;
    font-weight: bold;
    line-height: 1.1;
    margin-bottom: 0;
    color: var(--text);
}

.weather-temp-low {
    font-size: 1rem;
    color: var(--muted);
    margin-bottom: 0;
}

.weather-forecast-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.weather-forecast-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.75rem;
    background-color: var(--surface);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.weather-forecast-day {
    font-weight: bold;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    color: var(--text);
}

.weather-forecast-icon-img {
    width: 48px;
    height: 48px;
    margin: 0.25rem 0;
}

.weather-forecast-max {
    font-size: 1.2rem;
    font-weight: bold;
    margin-bottom: 0;
    color: var(--text);
}

.weather-forecast-min {
    font-size: 0.85rem;
    color: var(--muted);
    margin-bottom: 0;
}

.weather-footer {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
    font-size: 0.75rem;
    color: var(--muted);
}

/* Dark mode alert and form styling */
body.dark-mode .alert {
    background-color: var(--surface-2);
    color: var(--text);
    border-color: var(--border);
}

body.dark-mode .alert-warning {
    background-color: rgba(255, 193, 7, 0.15);
    border-color: rgba(255, 193, 7, 0.3);
    color: #ffc107;
}

body.dark-mode .alert-info {
    background-color: rgba(13, 202, 240, 0.15);
    border-color: rgba(13, 202, 240, 0.3);
    color: #0dcaf0;
}

body.dark-mode .form-check-input {
    background-color: var(--surface);
    border-color: var(--border);
}

body.dark-mode .form-check-input:checked {
    background-color: #0d6efd;
    border-color: #0d6efd;
}

/* Info modal (country profile) */
body.dark-mode #infoModal .table-borderless td {
    color: var(--text);
    padding: 0.75rem 0;
    background-color: transparent;
}

body.dark-mode #infoModal .table-borderless td.fw-bold {
    color: var(--text);
    font-weight: 600;
}

body.dark-mode #infoModal .text-primary {
    color: #0d6efd !important;
}

body.dark-mode #infoModal .text-end {
    color: var(--text);
    font-weight: 500;
}

body.dark-mode #infoModal .modal-footer {
    background-color: var(--surface) !important;
    border-top: 1px solid var(--border) !important;
}

body.dark-mode #infoModal .form-check {
    background-color: transparent;
}

body.dark-mode #infoModal .form-check-label {
    color: var(--text) !important;
}

/* Holidays modal */
body.dark-mode #holidayModal .table {
    color: var(--text);
    background-color: transparent;
}

body.dark-mode #holidayModal .table thead {
    background-color: transparent;
}

body.dark-mode #holidayModal .table thead th {
    color: var(--text);
    border-color: var(--border);
    font-weight: 700;
    background-color: transparent;
    padding: 0.75rem;
}

body.dark-mode #holidayModal .table tbody td {
    color: var(--text);
    border-color: var(--border);
    background-color: transparent;
    padding: 0.75rem;
}

/* Ensure text visibility in all modals */
body.dark-mode #infoModal,
body.dark-mode #weatherModal,
body.dark-mode #currencyModal,
body.dark-mode #wikiModal,
body.dark-mode #holidayModal,
body.dark-mode #placesModal,
body.dark-mode #newsModal,
body.dark-mode #shareModal {
    color: var(--text);
}

/*
  On small screens the Leaflet controls need to move down.
  This stops them from sitting over the country select box.
*/
@media (max-width: 560px) {
    .leaflet-top {
        top: 70px;
    }

    #themeToggle {
        top: 80px;
    }

    #selectContainer {
        width: 94%;
    }

    .leaflet-bar button,
    .leaflet-bar button:hover,
    .leaflet-bar a,
    .leaflet-touch .leaflet-bar button,
    .leaflet-touch .leaflet-bar a {
        height: 34px;
        width: 34px;
        line-height: 34px;
        font-size: 0.9rem;
    }
}
