/* Color variables */
:root {
    --mountain-dark: #37474F;
    --mountain-medium: #546E7A;
    --sky-light: #C9D6DF;
    --sky-mid: #DCE3E7;
    --sky-base: #F8F9FA;
    --heather-accent: #8B3B8F;
    --trail-green: #3B7A3A;
    --link-blue: #6BAED6;
    
    /* Additional semantic variables */
    --text-primary: var(--mountain-dark);
    --text-secondary: var(--mountain-medium);
    --background-primary: var(--sky-base);
    --background-secondary: var(--sky-mid);
    --accent-primary: var(--heather-accent);
    --accent-secondary: var(--trail-green);
    --link-color: var(--link-blue);

    --white: #FFFFFF;
    --youtube-red: #fc0303;

    /* Mapped variables for easier use */
    --text: var(--mountain-dark);
    --muted-text: var(--mountain-medium);
    --card-bg: var(--sky-base);
    --input-bg: var(--white);
    --input-border: var(--mountain-medium);
    --accent: var(--heather-accent);
    --primary-btn-bg: var(--trail-green);
    --link-color: var(--link-blue);
    --result-panel-bg: rgba(139, 59, 143, 0.05);
    --shadow: 0 10px 30px rgba(0,0,0,.15);
    --radius: 20px;
}

/* Base styles to ensure the app fills the iframe and doesn't scroll at the body level */
body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: 'Inter', sans-serif;
    box-sizing: border-box; /* Important for flexbox layout */
}

/* A more targeted CSS rule to remove focus outlines from map elements, including GPX layers */
.leaflet-container g:focus,
.leaflet-container path:focus,
.leaflet-container a:focus {
  outline: none;
}

/* Custom styles for the Awesome Markers using new color palette */
.awesome-marker-icon-blue {
    background-color: #1E3A8A !important; /* Blue background for visibility */
    border: 2px solid white !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3) !important;
    color: white !important; /* White icon color */
}
.awesome-marker-icon-green {
    background-color: #16A34A !important; /* Green background for completed */
    border: 2px solid white !important;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3) !important;
    color: white !important; /* White icon color */
}
/* Ensure the icon itself is colored */
.awesome-marker-icon-blue .fa {
    color: white !important;
}
.awesome-marker-icon-green .fa {
    color: white !important;
}

.badge { font-size: 0.75rem; padding: 0.25rem 0.75rem; border-radius: 9999px; font-weight: 600; }
.badge-completed { background-color: #8B3B8F; color: #ffffff; }
.badge-planned { background-color: #37474F; color: #ffffff; }
#map {
    width: 100%;
    height: 100%; /* Ensure map fills its container */
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
.highlight-row {
    background-color: #E0F2FE; /* A light blue to highlight selected row */
    border-left: 4px solid #8B3B8F; /* Heather Accent color */
}

/* New responsive layout with flexbox and percentage heights */
.main-container {
    height: calc(100vh - 5rem); /* Fixed height instead of min-height - subtract header height */
    max-height: 800px; /* Reasonable maximum height */
    padding: 1rem 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.map-container, .right-panel {
    flex: 1; /* Both containers grow to fill the available space */
    overflow: hidden; /* Prevent scrolling inside these containers */
    display: flex;
    flex-direction: column;
}

.map-container {
    min-height: 400px; /* Ensure map is at least a usable size on phones */
    max-height: 600px; /* Prevent excessive height */
    position: relative;
}

.right-panel {
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.filter-container {
    position: sticky;
    top: 0;
    z-index: 20;
    background-color: #F8F9FA; /* Sky Base */
    padding: 1rem;
    border-bottom: 1px solid #DCE3E7; /* Sky Mid */
}

.table-wrapper {
    flex-grow: 1; /* Make the table wrapper fill the rest of the space */
    overflow-y: auto; /* This is where the scrollbar for the table will appear */
}

.sticky-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: #F8F9FA; /* Sky Base */
}

/* Custom font size and compact padding for the table body to reduce its size */
th, td {
    padding: 0.5rem 0.75rem; /* Reduced padding for a more compact look */
    text-align: left;
}
#walks-table-body td {
    font-size: 0.8rem; /* A bit smaller than the default text-sm */
}
.map-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background-color: rgba(255, 255, 255, 0.9);
    padding: 1rem 2rem;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    text-align: center;
}
.map-message.loading {
    color: #4b5563;
}
.map-message.error {
    color: #dc2626;
    font-weight: bold;
}
.map-message.success {
    color: #16a34a;
    font-weight: bold;
}

/* Media query for larger screens */
@media (min-width: 768px) {
    .main-container {
        flex-direction: row; /* Switch to side-by-side layout on larger screens */
        gap: 2rem;
    }
}

/* Leaflet Popup customization */
.leaflet-popup-content-wrapper {
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    padding: 0;
    background-color: #F8F9FA; /* Sky base */
}
.leaflet-popup-content {
    padding: 0;
    margin: 0;
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    line-height: 1.25;
    width: 250px;
}
.leaflet-popup-tip {
    box-shadow: none;
    background-color: #F8F9FA; /* Sky base */
}

/* This rule applies to regular links but excludes our button classes */
.leaflet-popup-content a:not(.bg-trail-green):not(.bg-youtube-red):not(.bg-mountain-medium) {
    color: #000000 !important; /* Black for regular links */
}
/* This selects the color of the x to close the pop up menu */
.leaflet-popup-close-button {
    color: black !important;
    font-weight: bold;
}
.leaflet-popup-close-button:hover {
    color: #8B3B8F !important;
    font-weight: bold;
}

/* Unified Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    appearance: none;
    border: 1px solid var(--input-border);
    background: var(--input-bg);
    color: var(--text);
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 600;
    font-size: 0.75rem;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn:focus { outline: 2px solid rgba(139,59,143,0.18); outline-offset: 2px; }

.btn.primary {
    background: var(--primary-btn-bg);
    color: var(--white);
    border-color: transparent;
}
.btn.primary:hover {
    opacity: 0.85;
    color: var(--white);
}

.btn.ghost {
    background: transparent;
    border-color: transparent;
    color: var(--accent);
}
.btn.ghost:hover {
    color: var(--heather-accent);
    text-decoration: underline;
}

/* Specific button variants */
.btn-download { background-color: var(--trail-green); }
.btn-youtube { background-color: var(--youtube-red); }
.btn-map { background-color: var(--mountain-medium); }

/* Minimal Tailwind-like fallback utilities for local testing (applied only when CDN is not loaded) */
.text-link-blue { color: #6BAED6; text-decoration: none; }
.text-link-blue:hover { text-decoration: underline; }

/* Compact table styles to mimic the Tailwind look used in the markup */
.table-wrapper table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table-wrapper thead { background-color: #F8F9FA; } /* sky-base */
.table-wrapper th { padding: 0.5rem 0.75rem; font-size: 0.75rem; color: #546E7A; text-transform: uppercase; letter-spacing: .04em; }
.table-wrapper td { padding: 0.5rem 0.75rem; vertical-align: middle; }
.table-wrapper tbody tr:hover { background-color: #E0F2FE; } /* highlight on hover similar to tailwind hover:bg-sky-light */

/* Small utility classes used in popups and table */
.text-xs { font-size: 0.75rem; }
.rounded-md { border-radius: 0.375rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }

/* Make popup button links look like proper buttons - override all other styles */
.leaflet-popup-content .bg-trail-green,
.leaflet-popup-content .bg-youtube-red,
.leaflet-popup-content .bg-mountain-medium {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	gap: 0.4rem !important;
	padding: 0.4rem 0.6rem !important;
	border-radius: 0.375rem !important;
	color: #fff !important;
	text-decoration: none !important;
	font-size: 0.75rem !important;
	font-weight: 600 !important;
	transition: all 0.2s !important;
	margin-bottom: 0.25rem !important;
	width: 100% !important;
	box-sizing: border-box !important;
	border: none !important;
	text-align: center !important;
}

/* Ensure background colors are applied with highest specificity */
.leaflet-popup-content .bg-trail-green {
	background-color: #3B7A3A !important;
}

.leaflet-popup-content .bg-youtube-red {
	background-color: #fc0303 !important;
}

.leaflet-popup-content .bg-mountain-medium {
	background-color: #546E7A !important;
}

/* Hover effects for buttons with highest specificity */
.leaflet-popup-content .bg-trail-green:hover {
	background-color: rgba(59, 122, 58, 0.8) !important;
	color: #fff !important;
	text-decoration: none !important;
}

.leaflet-popup-content .bg-youtube-red:hover {
	background-color: rgba(252, 3, 3, 0.8) !important;
	color: #fff !important;
	text-decoration: none !important;
}

.leaflet-popup-content .bg-mountain-medium:hover {
	background-color: rgba(84, 110, 122, 0.8) !important;
	color: #fff !important;
	text-decoration: none !important;
}

/* Respect existing color names used in code */
.bg-trail-green { background-color: #3B7A3A !important; }
.bg-youtube-red { background-color: #fc0303 !important; }
.bg-mountain-medium { background-color: #546E7A !important; }

/* Ensure popup content spacing is pleasant */
.leaflet-popup .text-mountain-base { color: #263238; }
.leaflet-popup .badge { display:inline-block; margin-left:0.5rem; }

/* Small responsive tweak so controls wrap nicely */
.filter-container { display:flex; flex-wrap:wrap; gap:0.5rem; align-items:center; }