/* ========================================
   METAINFO MAPPER - CLEAN CSS STRUCTURE
   ======================================== */

/* Build: #101625g */

/* ========================================
   PERFORMANCE OPTIMIZATIONS
   ======================================== */

/* Hardware Acceleration - Enable GPU rendering */
#map {
    will-change: transform;
    transform: translateZ(0);
    contain: layout style paint;
}

.help-icon {
    will-change: transform;
}

.help-popup {
    will-change: transform, opacity;
    transform: translateZ(0);
}

.help-popup-overlay {
    will-change: opacity;
    transform: translateZ(0);
}

#progress-fill {
    will-change: width;
    transform: translateZ(0);
}

/* CSS Containment for better rendering */
#sidebar {
    contain: layout style paint;
}

.token-card,
.rtk-section,
.map-intro-card,
.map-about-card {
    contain: layout style paint;
}

.help-popup {
    contain: layout style paint;
}

#stats {
    contain: layout style paint;
}

/* ========================================
   1. CSS RESET & BASE STYLES
   ======================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    overflow: hidden;
    color-scheme: dark light;
}

/* ========================================
   2. CSS VARIABLES
   ======================================== */
:root {
    --bg-primary: #0f172a;
    --bg-secondary: rgba(15, 23, 42, 0.85);
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --accent: #38bdf8;
    --accent-strong: #0ea5e9;
    --card-bg: rgba(15, 23, 42, 0.7);
    --border-soft: rgba(148, 163, 184, 0.2);
    --pill-bg: rgba(56, 189, 248, 0.18);
    --pill-text: #bae6fd;
    --warn-bg: #fcd34d;
    --warn-text: #1f2937;
}

/* ========================================
   3. THEME BACKGROUNDS
   ======================================== */
body {
    background: radial-gradient(circle at top left, rgba(56,189,248,0.12), transparent 40%),
                radial-gradient(circle at bottom right, rgba(14,165,233,0.12), transparent 45%),
                var(--bg-primary);
    color: var(--text-primary);
}

body.light-theme {
    background: radial-gradient(circle at top left, rgba(66,153,225,0.15), transparent 40%),
                radial-gradient(circle at bottom right, rgba(72,187,120,0.2), transparent 45%),
                #eef2f6;
    color: #213548;
}

/* ========================================
   4. MAIN LAYOUT
   ======================================== */
#app {
    display: flex;
    height: 100vh;
}

#map {
    flex: 1;
    position: relative;
    background: radial-gradient(circle at center, rgba(30, 64, 175, 0.22), rgba(15, 23, 42, 0.92) 65%);
}

body.light-theme #map {
    background: radial-gradient(circle at center, rgba(27, 110, 239, 0.12), rgba(239, 246, 255, 0.95) 68%);
}

/* ========================================
   5. SIDEBAR STYLES
   ======================================== */
#sidebar {
    width: 350px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-soft);
    padding: 28px 24px 60px;
    overflow-y: auto;
}

body.light-theme #sidebar {
    background: rgba(255, 255, 255, 0.9);
    border-right: 1px solid rgba(76, 110, 156, 0.12);
    color: #213548;
}

#sidebar h1 {
    font-size: 28px;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    color: #e0f2fe;
}

body.light-theme #sidebar h1 {
    color: #1f2933;
}

#sidebar h1 span {
    color: var(--accent);
}

#sidebar h3 {
    margin: 15px 0 10px;
    font-size: 16px;
    color: #f8fafc;
}

body.light-theme #sidebar h3 {
    color: #1f2933;
}

/* ========================================
   6. TYPOGRAPHY & TEXT
   ======================================== */
.tagline {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 18px;
}

body.light-theme .tagline {
    color: #425466;
}

.hint {
    font-size: 13px;
    color: #6c757d;
    margin-bottom: 10px;
}

body:not(.light-theme) .hint {
    color: rgba(226, 232, 240, 0.75);
}

/* ========================================
   7. CARDS & COMPONENTS
   ======================================== */
.token-card {
    margin: 20px 0;
    padding: 16px 18px;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.55);
    border: 1px solid rgba(148, 163, 184, 0.28);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

body.light-theme .token-card {
    background: rgba(27, 110, 239, 0.08);
    border: 1px solid rgba(27,110,239,0.18);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.token-card h3 {
    margin: 0 0 10px;
    font-size: 15px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #f8fafc;
    font-weight: 600;
}

body.light-theme .token-card h3 {
    color: #1f3c6d;
    font-weight: 600;
}

.token-card .hint {
    margin-bottom: 12px;
}

/* ========================================
   8. RTK ANALYSIS SECTION
   ======================================== */
.rtk-section {
    margin-top: 20px;
    padding: 15px;
    background: rgba(15, 23, 42, 0.8);
    border-radius: 8px;
    border: 1px solid #334155;
}

body.light-theme .rtk-section {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #e9ecef;
}

.checkbox-container {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.checkbox-container input[type="checkbox"] {
    display: none;
}

.checkmark {
    width: 18px;
    height: 18px;
    border: 2px solid #64748b;
    border-radius: 4px;
    margin-right: 10px;
    position: relative;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

body.light-theme .checkmark {
    border-color: #94a3b8;
}

.checkbox-container input[type="checkbox"]:checked + .checkmark {
    background: #3b82f6;
    border-color: #3b82f6;
}

.checkbox-container input[type="checkbox"]:checked + .checkmark::after {
    content: "✓";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-size: 12px;
    font-weight: bold;
}

.checkbox-label {
    font-weight: 500;
    color: #f8fafc;
}

body.light-theme .checkbox-label {
    color: #1f2933;
}

.rtk-section .hint {
    color: #cbd5e1;
    font-size: 12px;
    margin-top: 8px;
    line-height: 1.4;
}

body.light-theme .rtk-section .hint {
    color: #425466;
}

/* ========================================
   9. FORM ELEMENTS
   ======================================== */
input[type="text"] {
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    background: rgba(15,23,42,0.7);
    color: var(--text-primary);
    margin-bottom: 10px;
    font-size: 14px;
}

body.light-theme input[type="text"] {
    background: rgba(255,255,255,0.95);
    color: #1f2933;
    border: 1px solid rgba(148, 163, 184, 0.6);
}

#drop-zone {
    border: 1px dashed rgba(148, 163, 184, 0.35);
    border-radius: 8px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s ease, background-color 0.3s ease;
    background: rgba(15, 23, 42, 0.55);
    margin-bottom: 10px;
}

body.light-theme #drop-zone {
    background: rgba(255,255,255,0.92);
    border: 2px dashed #cbd5e0;
}

#drop-zone:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#drop-zone.dragover {
    transform: translateY(-2px);
    border-color: #48bb78;
    background: #f0fff4;
}

/* ========================================
   10. BUTTONS
   ======================================== */
button {
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: transform 0.3s ease, background-color 0.3s ease;
    margin-bottom: 8px;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.primary-btn {
    background: linear-gradient(135deg, var(--accent-strong), #22d3ee);
    color: #0f172a;
}

body.light-theme .primary-btn {
    background: #007bff;
    color: white;
}

.primary-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #0284c7, #06b6d4);
}

body.light-theme .primary-btn:hover:not(:disabled) {
    background: #0056b3;
}

.secondary-btn {
    background: #6c757d;
    color: white;
}

.secondary-btn:hover:not(:disabled) {
    background: #5a6268;
}

.success-btn {
    background: linear-gradient(135deg, #22c55e, #4ade80);
    color: #0f172a;
}

body.light-theme .success-btn {
    background: #28a745;
    color: white;
}

.success-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #16a34a, #22c55e);
}

body.light-theme .success-btn:hover:not(:disabled) {
    background: #218838;
}

.warning-btn {
    background: var(--warn-bg);
    color: var(--warn-text);
}

body.light-theme .warning-btn {
    background: #ffc107;
    color: #212529;
}

.warning-btn:hover:not(:disabled) {
    background: #f59e0b;
}

.accent-btn {
    background: linear-gradient(135deg, var(--accent-strong), #2dd4bf);
}

body.light-theme .accent-btn {
    background: linear-gradient(135deg, #1b6eef, #4fd1c5);
}

.accent-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #0284c7, #14b8a6);
}

body.light-theme .accent-btn:hover:not(:disabled) {
    background: linear-gradient(135deg, #165ecd, #38b2ac);
}

#start-session {
    background: linear-gradient(135deg, #1b6eef, #38b2ac);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

#start-session:hover:not(:disabled) {
    background: linear-gradient(135deg, #165ecd, #2c9c9b);
}

/* ========================================
   11. PILLS & BADGES
   ======================================== */
.pill-row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.pill {
    background: var(--pill-bg);
    color: var(--pill-text);
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

body.light-theme .pill {
    background: rgba(27,110,239,0.12);
    color: #1b4f91;
}

/* ========================================
   12. STATISTICS & PROGRESS
   ======================================== */
#stats-content {
    background: rgba(15, 23, 42, 0.55);
    padding: 15px;
    border-radius: 4px;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

body.light-theme #stats-content {
    background: white;
    border: 1px solid #e9ecef;
}

#stats-content p {
    margin: 5px 0;
    font-size: 14px;
}

#stats-content span {
    font-weight: bold;
    color: #38bdf8;
}

body.light-theme #stats-content span {
    color: #1b6eef;
}

#progress-bar {
    width: 100%;
    height: 20px;
    background: #e9ecef;
    border-radius: 10px;
    overflow: hidden;
    margin: 10px 0;
}

#progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4299e1, #48bb78);
    width: 0%;
    transition: width 0.3s;
}

#progress-text {
    text-align: center;
    font-size: 14px;
    color: #6c757d;
}

/* ========================================
   13. THEME TOGGLE
   ======================================== */
.theme-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 20px 0 12px;
    font-size: 13px;
    color: var(--text-secondary);
}

.theme-toggle button {
    width: auto;
    padding: 8px 14px;
    border-radius: 999px;
    background: rgba(148,163,184,0.15);
    color: var(--text-primary);
}

body.light-theme .theme-toggle button {
    background: rgba(15,23,42,0.08);
    color: #1f2933;
}

.theme-toggle svg {
    width: 18px;
    height: 18px;
    margin-right: 6px;
}

/* ========================================
   14. MAP OVERLAYS
   ======================================== */
.map-intro-card {
    position: absolute;
    top: 24px;
    right: 24px;
    max-width: 320px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.32);
    border-radius: 14px;
    padding: 18px 20px;
    color: #f8fafc;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    pointer-events: auto;
    z-index: 500;
}

body.light-theme .map-intro-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(27, 110, 239, 0.12);
    color: #1f3655;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.map-intro-card p {
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 14px;
}

.map-intro-card .pill-row {
    gap: 10px;
}

.map-intro-card .pill {
    background: rgba(59, 130, 246, 0.14);
    color: #93c5fd;
}

body.light-theme .map-intro-card .pill {
    background: rgba(27, 110, 239, 0.14);
    color: #1b4f91;
}

.map-about-card {
    position: absolute;
    top: 24px;
    left: 24px;
    max-width: 300px;
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(148, 163, 184, 0.28);
    border-radius: 14px;
    padding: 18px 20px;
    color: #f1f5ff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
    pointer-events: auto;
    z-index: 500;
}

body.light-theme .map-about-card {
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(27, 110, 239, 0.16);
    color: #1f3655;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.map-about-card h3 {
    margin: 0 0 10px;
    font-size: 15px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #bfdbfe;
}

body.light-theme .map-about-card h3 {
    color: #1b4f91;
}

.map-about-card ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.map-about-card li {
    font-size: 13px;
    line-height: 1.5;
    color: #e2f1ff;
    position: relative;
    padding-left: 18px;
}

body.light-theme .map-about-card li {
    color: #264269;
}

.map-about-card li::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 8px;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #38bdf8;
}

body.light-theme .map-about-card li::before {
    background: #1b6eef;
}

/* ========================================
   15. MODALS
   ======================================== */
.modal {
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.4);
    display: none;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: rgba(15,23,42,0.9);
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
    color: var(--text-primary);
}

body.light-theme .modal-content {
    background-color: #fefefe;
    color: #213548;
}

.modal-content.wide {
    max-width: 520px;
}

.modal-content.wide ul {
    margin: 16px 0 24px;
    padding-left: 20px;
    color: #213548;
    line-height: 1.6;
}

.modal-content.wide ul li {
    margin-bottom: 6px;
}

#privacy-modal ul li {
    color: var(--text-primary);
}

body.light-theme #privacy-modal ul li {
    color: #213548;
}

#privacy-modal .primary-btn {
    width: auto;
    padding: 10px 24px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

.close:hover {
    color: #000;
}

/* ========================================
   16. TABLES
   ======================================== */
#error-table-container {
    margin: 20px 0;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th,
table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

table th {
    background-color: #f2f2f2;
    font-weight: bold;
}

table tr:hover {
    background-color: #f5f5f5;
}

/* ========================================
   17. UTILITY CLASSES
   ======================================== */
hr {
    margin: 20px 0;
    border: none;
    border-top: 1px solid #dee2e6;
}

#session-section hr {
    margin-top: 24px;
}

/* ========================================
   18. LEAFLET CUSTOMIZATION
   ======================================== */
/* Leaflet popup styling - ensure readability */
.leaflet-popup-content-wrapper {
    background: rgba(15, 23, 42, 0.96);
    color: #f8fafc;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.35);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
}
.leaflet-popup-content {
    margin: 8px;
    font-size: 13px;
    color: inherit;
    background: transparent;
}
.leaflet-popup-tip {
    background: rgba(15, 23, 42, 0.96);
}
.leaflet-popup-content-wrapper .leaflet-popup-content,
.leaflet-popup-content-wrapper .leaflet-popup-content * {
    color: inherit;
}
body.light-theme .leaflet-popup-content-wrapper {
    background: #ffffff;
    color: #213548;
    border: 1px solid rgba(27, 110, 239, 0.16);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.1);
}
body.light-theme .leaflet-popup-content {
    color: #213548;
    background: transparent;
}
body.light-theme .leaflet-popup-tip {
    background: #ffffff;
}

/* Specific overrides for dark theme */
/* ========================================
   19. SPECIAL EFFECTS
   ======================================== */

/* ========================================
   20. OWNER INFO & STATUS
   ======================================== */
#owner-info { 
    font-size: 13px; 
}

#owner-info h3 { 
    font-size: 14px; 
    margin-bottom: 8px; 
}

#owner-info p, #owner-info a, #owner-info span, #owner-info strong { 
    font-size: 13px; 
}

#owner-info p { 
    margin: 6px 0; 
}

#owner-info .owner-foot { 
    margin-top: 10px; 
    opacity: 0.85; 
    font-size: 12px; 
}

body.light-theme #owner-info .owner-foot { 
    opacity: 0.9;
}

#mapbox-token-status {
    min-height: 18px;
    margin-top: 6px;
    color: rgba(226, 232, 240, 0.85);
    font-size: 12px;
}

body.light-theme #mapbox-token-status {
    color: #425466;
}

/* ========================================
   21. TOOLTIPS & POPUPS
   ======================================== */
.popup {
    position: absolute;
    background: var(--card-bg);
    color: var(--text-primary);
    padding: 8px 12px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    pointer-events: none;
    font-size: 13px;
    border: 1px solid var(--border-soft);
}

body.light-theme .popup {
    background: white;
    color: #213548;
    border: 1px solid #e5e7eb;
}

/* Help Icons and Tooltips */
.help-icon {
    display: inline-block;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #6b7280;
    color: white;
    text-align: center;
    line-height: 16px;
    font-size: 12px;
    font-weight: bold;
    cursor: help;
    margin-left: 8px;
    position: relative;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.help-icon:hover {
    background: #4b5563;
    transform: scale(1.1);
}

/* Help popup system */
.help-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(15, 23, 42, 0.98);
    color: white;
    padding: 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: normal;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.help-popup.show {
    opacity: 1;
    visibility: visible;
}

.help-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.help-popup-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.help-popup-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: transform 0.2s ease, background-color 0.2s ease;
}

.help-popup-close:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.1);
}

.help-popup-content {
    line-height: 1.5;
}

.help-popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.help-popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

body.light-theme .help-popup {
    background: rgba(255, 255, 255, 0.98);
    color: #1f2937;
    border: 1px solid #e5e7eb;
}

body.light-theme .help-popup-close {
    color: #1f2937;
}

body.light-theme .help-popup-close:hover {
    background: rgba(0, 0, 0, 0.1);
}

body.light-theme .help-popup-header {
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

/* Adjust help icon positioning in checkbox */
.checkbox-container .help-icon {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
}

.checkbox-container {
    position: relative;
    padding-right: 30px;
}
