/* ---------------------------------------------------------
   SECTION: THEME & COLOR VARIABLES
   --------------------------------------------------------- */
:root {
    --bg: #0f1115;
    --card: #1e222a;
    --text: #e4e6eb;
    --border: #333a45;
    --primary: #3b82f6;
    --secondary: #272d38;
    --danger: #ef4444;
    --success: #10b981;
    --garmin: #0ea5e9;
    --dispatch: #f59e0b;
    --earth: #3b82f6;
    --link: #93c5fd;
    --foreflight: #3b82f6;
    --header-sep: rgba(255, 255, 255, 0.05);
    --stripe: rgba(255, 255, 255, 0.02); 
    --glass: rgba(15, 17, 21, 0.7);
}
[data-theme="light"] {
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #0f172a;
    --border: #e2e8f0;
    --primary: #2563eb;
    --secondary: #f1f5f9;
    --danger: #ef4444;
    --link: #2563eb;
    --header-sep: rgba(0, 0, 0, 0.05);
    --stripe: rgba(0, 0, 0, 0.02);
    --glass: rgba(255, 255, 255, 0.75);
}

/* ---------------------------------------------------------
   SECTION: CORE LAYOUT
   --------------------------------------------------------- */
body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; margin: 20px; background: var(--bg); color: var(--text); transition: background 0.3s, color 0.3s; }
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--bg); border-radius: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; border: 3px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--primary); }
.container { max-width: 1500px; margin: auto; background: var(--card); padding: 30px; border-radius: 12px; box-shadow: 0 4px 12px rgba(0,0,0,0.1); position: relative; transition: background 0.3s, box-shadow 0.3s; }
.version-subtitle { font-size: 11px; color: #90949c; margin-top: 4px; display: inline-block; font-weight: normal; cursor: pointer; text-decoration: underline; }
.contact-link, .project-link { font-size: 11px; color: #90949c; margin-left: 15px; text-decoration: underline; }
.header-row { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid var(--border); padding-bottom: 10px; margin-bottom: 20px; }
h2 { margin: 0; color: var(--primary); line-height: 1; }

.top-info-grid { display: grid; grid-template-columns: 1.5fr 1fr; gap: 20px; margin-bottom: 20px; }
.instructions { background: rgba(71, 141, 245, 0.06); padding: 16px 20px; border-radius: 8px; border-left: 5px solid var(--primary); font-size: 13px; line-height: 1.6; height: 100%; box-sizing: border-box; box-shadow: inset 0 0 0 1px rgba(71, 141, 245, 0.15); }

/* UPDATED SESSION CARD STYLE */
.session-status-card { background: rgba(39, 45, 56, 0.6); padding: 15px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.05); font-size: 12px; height: 100%; box-sizing: border-box; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: inset 0 1px 1px rgba(255,255,255,0.1); }

.status-line { margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.status-line > span:first-child { color: #90949c; font-weight: 500; }
.status-line > div > span { font-weight: 600; letter-spacing: 0.3px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #555; display: inline-block; flex-shrink: 0; }
.status-dot.loading { background: var(--dispatch); animation: dbPulse 1s infinite; }
.status-dot.ready { background: var(--success); animation: readyBreathe 3s ease-in-out infinite; }
.status-dot.error { background: var(--danger); }
@keyframes readyBreathe { 0%, 100% { opacity: 1; box-shadow: 0 0 2px rgba(40, 167, 69, 0.4); } 50% { opacity: 0.5; box-shadow: 0 0 0px rgba(40, 167, 69, 0); } }
.status-dot.danger-pulse { background: var(--danger); animation: errorPulse 0.8s infinite; }
@keyframes errorPulse { 0% { box-shadow: 0 0 0 0px rgba(251, 97, 97, 0.7); } 100% { box-shadow: 0 0 0 8px rgba(251, 97, 97, 0); } }
@keyframes dbPulse { 0% { opacity: 1; } 50% { opacity: 0.3; } 100% { opacity: 1; } }

/* ---------------------------------------------------------
   SECTION: ACTION BAR BUTTONS
   --------------------------------------------------------- */
.action-bar { 
    background: rgba(30, 34, 42, 0.7) !important; padding: 15px; border-radius: 12px; margin-bottom: 20px; 
    display: none; flex-wrap: wrap; gap: 10px; align-items: center;
    position: sticky; top: 0; z-index: 1002; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
    box-shadow: 0 8px 32px rgba(0,0,0,0.2), inset 0 1px 1px rgba(255,255,255,0.05); border-bottom: none;
}
[data-theme="light"] .action-bar { background: rgba(255, 255, 255, 0.75) !important; box-shadow: 0 8px 32px rgba(0,0,0,0.08), inset 0 1px 1px rgba(255,255,255,0.5); }

/* UPDATED: Larger Vertical divider for the Action Bar */
.action-divider {
    width: 3px;               /* Increased thickness */
    height: 42px;              /* Increased height to span more of the bar */
    background: var(--border);
    margin: 0 12px;            /* Slightly more breathing room */
    border-radius: 4px;
    align-self: center;
    opacity: 1;                /* Full opacity for better visibility */
    box-shadow: 1px 0 2px rgba(0,0,0,0.2); /* Subtle depth */
}	

/* ---------------------------------------------------------
   SECTION: DATA TABLE & ROW STYLING
   --------------------------------------------------------- */
table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 12px; table-layout: fixed; border: 1px solid var(--border); }
th, td { border: 1px solid var(--border); padding: 8px; text-align: left; vertical-align: middle; position: relative; }
thead th { background-color: var(--secondary) !important; font-weight: 600; font-size: 11px; user-select: none; line-height: 1.2; position: sticky; z-index: 1001; padding-top: 6px; padding-bottom: 6px; border-right: 1px solid var(--header-sep); box-shadow: 0 4px 6px rgba(0,0,0,0.15); border-bottom: 2px solid var(--primary) !important; }
.clickable-header { cursor: pointer; text-decoration: underline dotted; text-underline-offset: 3px; transition: background-color 0.2s ease, color 0.2s ease; }
.clickable-header:hover { background-color: var(--primary) !important; color: white; text-decoration: none; }
.clickable-header:active { background-color: #3670c9 !important; }

#wpTable tbody tr { animation: rowSlideIn 0.3s ease-out forwards; }
@keyframes rowSlideIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
#wpTable tbody tr:nth-child(even) { background-color: var(--stripe); }
#wpTable tbody tr:hover { background-color: rgba(59, 130, 246, 0.08); }

input { width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 12px; background: rgba(0,0,0,0.2); color: var(--text); box-sizing: border-box; transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1); }
[data-theme="light"] input { background: rgba(255,255,255,0.5); }
input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25); background: var(--card); }
.btn { padding: 10px 16px; border: 1px solid rgba(255,255,255,0.05); border-radius: 8px; cursor: pointer; font-weight: 600; margin-right: 5px; margin-bottom: 5px; transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1); text-align: center; color: white; display: inline-block; vertical-align: middle; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.btn:hover { filter: brightness(1.1); transform: translateY(-2px); box-shadow: 0 6px 12px rgba(0,0,0,0.2); }
.btn:active { transform: translateY(0); filter: brightness(0.95); box-shadow: none; }
.btn span { display: block; font-size: 10px; font-weight: 400; opacity: 0.9; margin-top: 2px; }
.btn-secondary { background: var(--secondary); color: var(--text); }
.btn-danger { background: var(--danger); border: 1px solid transparent; transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); }
.btn-danger:hover { background: #ff4a4a; border-color: #ff4a4a; box-shadow: 0 4px 12px rgba(251, 97, 97, 0.4); transform: translateY(-1px); }
.btn-danger:active { transform: translateY(1px); box-shadow: none; filter: brightness(0.9); }
a { color: var(--link); text-decoration: none; font-weight: 500; font-size: 10px; transition: color 0.15s ease, text-decoration 0.15s ease; }
a:hover { color: var(--primary); text-decoration: underline; }
.quick-links { display: flex; gap: 8px; align-items: center; justify-content: center; }
.ql-btn { display: flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 6px; background: rgba(71, 141, 245, 0.08); border: 1px solid transparent; transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); color: var(--link); }
.ql-btn:hover { background: var(--primary); color: white; border-color: var(--primary); transform: translateY(-1px); box-shadow: 0 2px 6px rgba(71, 141, 245, 0.3); }
.ql-btn:active { transform: translateY(0); box-shadow: none; filter: brightness(0.9); }

.delete-btn { color: var(--danger); cursor: pointer; font-weight: bold; font-size: 14px; opacity: 0.4; transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); text-align: center; user-select: none; }
.delete-btn:hover { opacity: 1; transform: scale(1.3); }
.insert-btn { color: var(--primary); cursor: pointer; font-weight: bold; font-size: 14px; opacity: 0.4; transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); text-align: center; user-select: none; }
.insert-btn:hover { opacity: 1; transform: scale(1.3); }
.drag-handle { cursor: grab; text-align: center; color: var(--primary); font-size: 16px; user-select: none; opacity: 0.6; transition: all 0.15s ease; }
.drag-handle:hover { opacity: 1; transform: scale(1.2); color: var(--link); }
.drag-handle:active { cursor: grabbing; transform: scale(1.05); opacity: 0.8; }
tr.dragging { opacity: 0.6; background-color: var(--secondary) !important; outline: 2px dashed var(--primary); outline-offset: -2px; }
tr.drag-over { border-top: 3px solid var(--primary) !important; background: rgba(71, 141, 245, 0.15); }
.row-number { text-align: center; font-family: monospace; opacity: 0.7; font-size: 11px; }

/* --- UPDATED MAP CONTAINER (Replaces Old Overlay) --- */
#mapOverlay { 
    display: none; position: fixed; top: 5%; left: 5%; width: 90%; height: 80%; 
    background: var(--card); z-index: 3000; border: 2px solid var(--primary); 
    border-radius: 12px; overflow: hidden; box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    animation: mapPopIn 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}
@keyframes mapPopIn {
    0% { opacity: 0; transform: scale(0.97); }
    100% { opacity: 1; transform: scale(1); }
}
#mapOverlay.maximized { width: 100vw; height: 100vh; top: 0; left: 0; border: none; border-radius: 0; }
#map { width: 100%; height: 100%; background: #222; }

.numbered-marker { background: var(--primary); border: 2px solid white; border-radius: 50%; color: white; font-weight: bold; text-align: center; line-height: 20px; font-size: 10px; }

.modal-overlay { display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.65); z-index: 5999; backdrop-filter: blur(4px); }
#versionHistory { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); background: var(--card); border: 2px solid var(--primary); padding: 25px; border-radius: 12px; font-size: 12px; z-index: 6000; box-shadow: 0 15px 40px rgba(0,0,0,0.7); max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto; color: var(--text); line-height: 1.6; animation: modalPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.1); }
@keyframes modalPop { 0% { opacity: 0; transform: translate(-50%, -45%) scale(0.95); } 100% { opacity: 1; transform: translate(-50%, -50%) scale(1); } }

.file-upload-wrapper { position: relative; overflow: hidden; display: flex; width: 100%; align-items: stretch; cursor: pointer; }
.file-upload-wrapper input[type="file"] { position: absolute; left: 0; top: 0; bottom: 0; right: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%; z-index: 10; font-size: 0; color: transparent; }
.btn-upload { background: rgba(71, 141, 245, 0.15); color: #a3c7ff; border: 2px dashed var(--primary); width: 100%; display: block; margin: 0; padding: 14px 12px; transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1); position: relative; z-index: 1; font-size: 14px; }
.file-upload-wrapper:hover .btn-upload { background: var(--primary); border-style: solid; color: white; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(71, 141, 245, 0.4); }
.file-upload-wrapper:active .btn-upload { transform: translateY(1px); box-shadow: none; filter: brightness(0.9); }

.autocomplete-list { position: absolute; top: 100%; left: 0; width: 100%; background: var(--secondary); border: 1px solid var(--primary); border-radius: 6px; z-index: 2000; box-shadow: 0 8px 16px rgba(0,0,0,0.4); max-height: 180px; overflow-y: auto; display: none; }
.autocomplete-item { padding: 8px 12px; cursor: pointer; border-bottom: 1px solid var(--border); font-size: 12px; transition: background-color 0.15s ease; }
.autocomplete-item:hover { background: var(--primary) !important; color: white; }

.leg-label { background: rgba(0, 0, 0, 0.85); border: 1px solid var(--primary); color: white; padding: 4px 7px; border-radius: 4px; font-size: 10px; font-weight: bold; white-space: nowrap; pointer-events: none; box-shadow: 0 2px 6px rgba(0,0,0,0.6); backdrop-filter: blur(4px); letter-spacing: 0.5px; }

.wp-label-tooltip { background: var(--glass); color: var(--text); border: 1px solid var(--border); border-radius: 4px; font-size: 11px; font-weight: bold; padding: 2px 6px; box-shadow: 0 2px 8px rgba(0,0,0,0.5); backdrop-filter: blur(4px); }
.leaflet-tooltip-top.wp-label-tooltip::before { border-top-color: var(--border); }

/* FOOTER STYLE */
.app-footer {
    margin-top: 40px;
    padding: 15px 20px;
    background: rgba(243, 156, 18, 0.05);
    border-left: 4px solid var(--dispatch);
    border-radius: 4px;
    font-size: 11px;
    color: #90949c;
    line-height: 1.6;
    text-align: left;
}
.disclaimer-bold {
    font-weight: bold;
    color: var(--dispatch);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* --- NEW MAP COMMAND BAR --- */
.map-command-bar {
    position: absolute; bottom: 30px; left: 50%; transform: translateX(-50%);
    width: auto; background: var(--glass); border: 1px solid var(--border); border-radius: 12px;
    padding: 10px 20px; display: flex; align-items: center; gap: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.6); backdrop-filter: blur(12px); z-index: 9999 !important;
}

.cmd-group { display: flex; align-items: center; gap: 8px; position: relative; }
.cmd-divider { width: 2px; height: 24px; background: rgba(255, 255, 255, 0.1); margin: 0 6px; box-shadow: inset 1px 0 0 rgba(0, 0, 0, 0.2); }
[data-theme="light"] .cmd-divider { background: rgba(0, 0, 0, 0.1); box-shadow: inset 1px 0 0 rgba(255, 255, 255, 0.5); }

.layer-switch { display: flex; background: rgba(0,0,0,0.4); border-radius: 8px; padding: 3px; border: 1px solid var(--border); box-shadow: inset 0 2px 4px rgba(0,0,0,0.3); }
.layer-btn {
    background: transparent; 
    border: none; 
    color: #888; 
    padding: 8px 12px; 
    font-size: 11px; 
    font-weight: 600;
    cursor: pointer; 
    border-radius: 5px; 
    transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.1);
    white-space: nowrap;
    height: 32px;
    display: flex;
    align-items: center;
}
.layer-btn:hover:not(.active) { color: var(--text); background: rgba(255,255,255,0.05); }
.layer-btn.active { background: var(--primary); color: white; box-shadow: 0 2px 6px rgba(0,0,0,0.4); transform: scale(1.02); }

.popover-menu {
    position: absolute; bottom: 75px; left: 50%; transform: translateX(-50%) scale(0.95);
    background: #1c1c1e; border: 1px solid var(--border); border-radius: 10px; padding: 10px;
    display: flex; flex-direction: column; gap: 6px; box-shadow: 0 5px 25px rgba(0,0,0,0.8);
    min-width: 180px; z-index: 10000 !important;
    opacity: 0; pointer-events: none; transition: opacity 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.1), transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.1);
}
.popover-menu.visible { opacity: 1; pointer-events: auto; transform: translateX(-50%) scale(1); }
.popover-label { font-size: 9px; color: #888; text-transform: uppercase; padding: 0 5px; font-weight: bold; margin-bottom: 2px; }

.toggle-btn {
    background: rgba(255,255,255,0.05); border: 1px solid var(--border); color: var(--text);
    padding: 8px 14px; font-size: 11px; border-radius: 20px; cursor: pointer; display: flex;
    align-items: center; gap: 8px; transition: 0.2s; white-space: nowrap; height: 32px; justify-content: center;
}
.toggle-btn:hover { background: rgba(255,255,255,0.1); border-color: var(--primary); }
.popover-menu .toggle-btn { width: 100%; border-radius: 8px; justify-content: flex-start; height: auto; padding: 10px 14px; }
.toggle-btn.active { background: rgba(71, 141, 245, 0.2); border-color: var(--primary); color: var(--primary); }
.indicator { width: 6px; height: 6px; border-radius: 50%; background: #444; transition: 0.3s; }
.toggle-btn.active .indicator { background: var(--primary); box-shadow: 0 0 8px var(--primary); }

.weather-active { border-color: #2d81ff !important; color: #2d81ff !important; background: rgba(45, 129, 255, 0.15) !important; }
.weather-active .indicator { background: #2d81ff; box-shadow: 0 0 6px #2d81ff; }

.action-btn { background: var(--card); border: 1px solid var(--border); color: var(--text); padding: 8px 12px; font-size: 11px; border-radius: 6px; cursor: pointer; height: 32px; display: flex; align-items: center; gap: 6px; transition: all 0.2s; }
.action-btn:hover { background: var(--secondary); border-color: var(--primary); }
.close-btn { background: var(--danger); border-color: var(--danger); color: white; }
.close-btn:hover { background: #ff4a4a; border-color: #ff4a4a; filter: brightness(1.1); color: white; }

#loader {
    position: fixed; top: 20px; right: 20px; background: rgba(0,0,0,0.8); color: white;
    padding: 8px 15px; border-radius: 20px; font-size: 11px; display: none; align-items: center;
    gap: 10px; z-index: 10001; border: 1px solid var(--border); box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.spinner { width: 12px; height: 12px; border: 2px solid #fff; border-bottom-color: transparent; border-radius: 50%; animation: rotation 1s linear infinite; }
@keyframes rotation { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
