:root {
    /* Legacy - To be deprecated */
    --primary-color: #2563EB;
    --secondary-color: #1E293B;
    --bg-color: #F8FAFC;

    /* M3 System Colors (Strict Compliance) */
    --md-sys-color-primary: #2563EB;
    --md-sys-color-on-primary: #FFFFFF;
    --md-sys-color-primary-container: #DBEAFE;
    --md-sys-color-on-primary-container: #1E3A8A;

    --md-sys-color-secondary: #475569;
    --md-sys-color-on-secondary: #FFFFFF;
    --md-sys-color-secondary-container: #F1F5F9;
    --md-sys-color-on-secondary-container: #0F172A;

    --md-sys-color-surface: #F8FAFC;
    --md-sys-color-on-surface: #1E293B;
    --md-sys-color-surface-variant: #E2E8F0;
    --md-sys-color-on-surface-variant: #475569;

    --md-sys-color-outline: #94A3B8;
    --md-sys-color-outline-variant: #CBD5E1;
}

/* Colors */
.text-blue-600,
.hover\:text-blue-600:hover,
.text-blue-500 {
    color: var(--primary-color) !important;
}

.bg-blue-600,
.hover\:bg-blue-700:hover,
.bg-blue-500 {
    background-color: var(--primary-color) !important;
}

.text-slate-900,
.text-slate-800 {
    color: var(--secondary-color) !important;
}

.bg-slate-900,
.hover\:bg-slate-800:hover {
    background-color: var(--secondary-color) !important;
}

.bg-slate-50 {
    background-color: var(--bg-color) !important;
}

/* Navbar Animations */
.nav-link-group {
    position: relative;
}

.nav-link-underline::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -4px;
    left: 0;
    background-color: var(--primary-color);
    transition: width 0.3s ease-in-out;
}

.nav-link-group:hover .nav-link-underline::after {
    width: 100%;
}

.nav-icon-bounce {
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.nav-link-group:hover .nav-icon-bounce {
    transform: translateY(-3px);
    color: var(--primary-color);
}

/* Tile Header Styling - Matches Example */
.tile-header {
    background-color: #2c4c64;
    /* Specific deep blue from example */
    color: white;
    padding: 0.875rem 1.25rem;
    border-radius: 0.5rem 0.5rem 0 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-size: 0.8125rem;
}

.tile-header svg {
    width: 1.125rem;
    height: 1.125rem;
    color: #94a3b8;
    /* slate-400 for icons as in example */
}

.tile-body {
    background-color: #ffffff;
    padding: 1.5rem;
    border-radius: 0 0 0.5rem 0.5rem;
    border: 1px solid #e2e8f0;
    border-top: none;
}

/* Utilities */
/* Hide scrollbar for Chrome, Safari and Opera */
.no-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Hide scrollbar for IE, Edge and Firefox */
.no-scrollbar {
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

/* Print Styles from Offer Detail */
@media print {
    @page {
        size: A4 landscape;
        margin: 5mm;
    }

    body {
        background: white !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* FIX: Do NOT hide body > * because it hides <main> */
    /* Instead, hide specific structural elements */
    nav,
    footer,
    .navbar,
    .cookie-banner {
        display: none !important;
    }

    /* Hide the Web View Section explicitly */
    .web-only-section {
        display: none !important;
    }

    /* Ensure structural parents are visible and full width */
    html,
    body,
    main {
        display: block !important;
        width: 100% !important;
        height: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
    }

    /* Show only our print container */
    .print-layout-container {
        display: block !important;
        position: absolute !important;
        top: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 100% !important;
        z-index: 9999 !important;
        background: white !important;
    }
}

/* Admin Dashboard - Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Admin Offer Preview Modal */
.preview-mode .view-mode button {
    display: none !important;
}

.preview-mode .edit-mode {
    display: none !important;
}

.preview-mode .view-mode {
    cursor: default !important;
}


/* MAP VISUALIZATION STYLES */

/* 1. LAYOUT & INTEGRATION */
/* Remove base padding to allow full-screen map */
/* Note: scoped to map page if possible, but main is generic. 
   Ideally we add a class to main on this page, but for now we keep it global 
   OR we rely on the fact that this CSS is loaded globally. 
   Wait, if I put 'main { padding: 0 !important; }' in styles.css, it affects ALL pages!
   I must check if this page extends base.html. Yes it does.
   So I CANNOT just make main padding 0 globally.
   The inline style in map_visualization.html was scoped to that page effectively because it was rendered with it.
   To move it to styles.css safely, I need to scope it.
   I will add a class `map-visualization-page` to the body or main in the template.
*/

body.map-visualization-page main {
    padding: 0 !important;
    overflow: hidden;
    height: calc(100vh - 80px);
    /* 80px is navbar height? check base.html */
    position: relative;
}

body.map-visualization-page footer {
    display: none !important;
}

#map {
    height: 100%;
    width: 100%;
    z-index: 1;
    background: #f8fafc;
    /* Fallback */
}

/* 2. GLASSMORPHISM SIDEBAR */
.premium-sidebar {
    position: absolute;
    top: 20px;
    left: 20px;
    width: 360px;
    max-height: calc(100% - 40px);
    background: rgba(255, 255, 255, 0.85);
    /* Semi-transparent white */
    backdrop-filter: blur(12px);
    /* Glass effect */
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    /* Soft shadow */
    z-index: 1000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.3s ease;
}

.premium-header {
    padding: 20px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.premium-title {
    font-family: 'Outfit', sans-serif;
    /* Modern Font */
    font-size: 1.2rem;
    font-weight: 700;
    color: #1e293b;
    letter-spacing: -0.5px;
}

.premium-badge {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    box-shadow: 0 2px 5px rgba(37, 99, 235, 0.3);
}

.premium-content {
    padding: 20px;
    overflow-y: auto;
    /* Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* 3. FILTERS (TAGS) */
.filter-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    font-weight: 700;
    margin-bottom: 12px;
}

.filter-tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 24px;
}

.filter-tag {
    padding: 8px 14px;
    border-radius: 10px;
    font-size: 0.85rem;
    font-weight: 500;
    color: #475569;
    background: white;
    border: 1px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 6px;
}

.filter-tag:hover {
    background: #f1f5f9;
    transform: translateY(-1px);
}

.filter-tag.active {
    background: #0f172a;
    /* Slate 900 */
    color: white;
    border-color: #0f172a;
    box-shadow: 0 4px 10px rgba(15, 23, 42, 0.2);
}

/* 4. MINI LIST */
.mini-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mini-card {
    background: white;
    padding: 12px;
    border-radius: 10px;
    border: 1px solid transparent;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mini-card:hover {
    border-color: #cbd5e1;
    transform: translateX(2px);
}

.mini-card-content h5 {
    font-size: 0.9rem;
    font-weight: 600;
    color: #334155;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
}

.mini-card-content p {
    font-size: 0.75rem;
    color: #94a3b8;
    margin: 2px 0 0 0;
}

.mini-card-arrow {
    color: #cbd5e1;
}

/* 5. FLOATING WIDGETS (Info & Chart) */
.floating-widget {
    position: absolute;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 15px;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
    z-index: 999;
    border: 1px solid rgba(255, 255, 255, 0.6);
}

.widget-chart {
    bottom: 25px;
    right: 25px;
    width: 300px;
    height: 180px;
}

.widget-info {
    top: 25px;
    right: 25px;
    min-width: 220px;
    display: none;
    /* Auto-show */
    pointer-events: none;
}

.info-title {
    font-family: 'Outfit', sans-serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 5px;
    border-bottom: 2px solid #e2e8f0;
    padding-bottom: 5px;
}

/* 6. ANIMATIONS & MAP STYLES */
@keyframes pulse-generic {
    0% {
        stroke-width: 4;
        stroke-opacity: 0.6;
    }

    50% {
        stroke-width: 7;
        stroke-opacity: 1;
    }

    100% {
        stroke-width: 4;
        stroke-opacity: 0.6;
    }
}

.route-animee {
    animation: pulse-generic 4s infinite ease-in-out;
    /* Slowed down x2 */
    stroke-linecap: round;
}

.train-animee {
    animation: pulse-generic 0.8s infinite ease-in-out;
    /* Fast */
    stroke-linecap: round;
    /* No dashes, solid line pulsing */
}

@keyframes dash {
    from {
        stroke-dashoffset: 100%;
    }

    to {
        stroke-dashoffset: 0%;
    }
}

/* 8. TRANSPORT STRIP (Ultra-Fine) */
.widget-strip {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 6px 20px;
    border-radius: 50px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 1000;
    border: 1px solid white;
    height: 48px;
    /* Hauteur fixe fine */
    max-width: 90vw;
    overflow-x: auto;
}

.strip-group {
    display: flex;
    align-items: center;
    gap: 6px;
    padding-right: 15px;
    border-right: 1px solid #e2e8f0;
}

.strip-group:last-child {
    border-right: none;
    padding-right: 0;
}

.strip-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #94a3b8;
    margin-right: 5px;
    letter-spacing: 0.5px;
}

.transport-chip {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    background: #f1f5f9;
    color: #64748b;
    border: 1px solid transparent;
    white-space: nowrap;
}

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

/* Active States */
.transport-chip.active.road {
    background: #ffedd5;
    color: #ea580c;
    border-color: #fb923c;
}

.transport-chip.active.train {
    background: #f1f5f9;
    color: #334155;
    border-color: #475569;
    background: #cbd5e1;
}

body.dark-mode .widget-strip {
    background: rgba(15, 23, 42, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
}

body.dark-mode .strip-group {
    border-color: #334155;
}

body.dark-mode .transport-chip {
    background: #1e293b;
    color: #94a3b8;
}

.print-footer-fixed {
    position: fixed;
    bottom: 5mm;
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 8px;
    color: #94a3b8;
}

.print-commerc-block {
    font-size: 10px;
    line-height: 1.4;
    color: #334155;
}


.print-main-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    height: 100%;
}

body.dark-mode .transport-chip.active.road {
    background: #7c2d12;
    color: #fdba74;
    border-color: #ea580c;
}

body.dark-mode .transport-chip.active.train {
    background: #334155;
    color: #e2e8f0;
    border-color: #94a3b8;
}

/* 7. DARK MODE & PRINT */
body.dark-mode {
    background-color: #0f172a;
    color: #f8fafc;
}

body.dark-mode .premium-sidebar,
body.dark-mode .floating-widget {
    background: rgba(30, 41, 59, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
    color: #f8fafc;
}

body.dark-mode .premium-title,
body.dark-mode .info-title,
body.dark-mode .mini-card-content h5 {
    color: #f8fafc;
}

body.dark-mode .mini-card {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .filter-tag {
    background: #334155;
    color: #cbd5e1;
    border-color: #475569;
}

body.dark-mode .filter-tag.active {
    background: #3b82f6;
    color: white;
}

@media print {
    /* Print styles for map visualization */
    /* Assuming these are generic enough or we wrap them in a print class?
       The original had @page ... which is global. 
       If we put this in styles.css, it affects all pages.
       We should check if other pages have conflicting @page rules.
       Yes, offer_print.html has @page { size: A4 landscape; ... }
       This one also has A4 landscape. So it matches.
    */
    /* Note: We might need to handle @page carefully if they differ. 
       For now, let's keep it here. */

    /* HIDE USELESS UI */
    body.map-visualization-page header,
    body.map-visualization-page footer,
    body.map-visualization-page nav,
    body.map-visualization-page .premium-header,
    body.map-visualization-page .filter-tags,
    body.map-visualization-page .filter-section-title,
    body.map-visualization-page #total-badge,
    body.map-visualization-page .floating-widget,
    body.map-visualization-page .widget-strip,
    body.map-visualization-page .leaflet-control-zoom,
    body.map-visualization-page input,
    body.map-visualization-page button,
    body.map-visualization-page .transport-chip,
    body.map-visualization-page #debug-log {
        display: none !important;
    }

    /* LAYOUT: SIDEBAR + MAP */
    body.map-visualization-page main {
        height: 100vh !important;
        display: flex !important;
        padding: 0 !important;
    }

    body.map-visualization-page .premium-sidebar {
        position: relative !important;
        width: 25% !important;
        left: auto !important;
        top: auto !important;
        height: 100% !important;
        border: none !important;
        box-shadow: none !important;
        background: white !important;
        backdrop-filter: none !important;
        overflow: visible !important;
        margin-top: 0 !important;
        padding-top: 0 !important;
    }

    body.map-visualization-page .premium-content {
        padding: 0 !important;
        overflow: visible !important;
    }

    body.map-visualization-page #map {
        position: relative !important;
        width: 75% !important;
        height: 100% !important;
        left: auto !important;
        top: auto !important;
        border-left: 1px solid #ddd;
    }

    /* COMPACT OFFER LIST */
    body.map-visualization-page .mini-list {
        display: block !important;
        max-height: none !important;
        overflow: visible !important;
        margin-top: 0 !important;
        padding-top: 5px !important;
    }

    body.map-visualization-page .mini-card {
        background: linear-gradient(to bottom, #ffffff 20%, rgba(255, 255, 255, 0) 50%) !important;
        border: 1px solid #ccc !important;
        border-radius: 4px !important;
        margin-bottom: 5px !important;
        padding: 8px !important;
        break-inside: avoid;
        box-shadow: none !important;
    }

    body.map-visualization-page .mini-card h5 {
        font-size: 10pt !important;
        margin: 0;
        color: black !important;
    }

    body.map-visualization-page .mini-card span {
        font-size: 9pt !important;
        color: #333 !important;
    }

    body.map-visualization-page .mini-card .contact-info {
        display: block !important;
        font-size: 8pt !important;
        margin-top: 4px;
        color: #555 !important;
    }

    /* VISIBLE POINTS ON MAP */
    body.map-visualization-page .leaflet-marker-icon,
    body.map-visualization-page .leaflet-marker-shadow {
        display: block !important;
    }

    body.map-visualization-page .marker-offer {
        border: 1px solid black !important;
        background: #2563eb !important;
    }
}

/* Custom Scrollbar for pinned container */
#pinned-container::-webkit-scrollbar {
    width: 6px;
}

#pinned-container::-webkit-scrollbar-thumb {
    background-color: rgba(0, 0, 0, 0.2);
    border-radius: 4px;
}

.pinned-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    width: 250px;
    position: relative;
    animation: slideInRight 0.3s ease-out;
    border-left: 4px solid #3b82f6;
    /* Default Blue */
}

.pinned-card .close-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: transparent;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    font-size: 1.2rem;
    transition: color 0.2s;
    line-height: 1;
    padding: 0 4px;
}

.pinned-card .close-btn:hover {
    color: #ef4444;
    /* Red */
}

.pinned-card-title {
    font-weight: 700;
    font-size: 1rem;
    color: #1e293b;
    margin-bottom: 8px;
    padding-right: 20px;
    /* Space for close btn */
}

body.map-visualization-page main {
    padding: 0 !important;
    overflow: hidden;
}

.pinned-card-section {
    margin-top: 8px;
}

.pinned-card-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #64748b;
    letter-spacing: 0.05em;
    margin-bottom: 2px;
}

.pinned-card-value {
    font-size: 0.9rem;
    color: #334155;
    font-weight: 500;
}

.pinned-card-link {
    display: block;
    margin-top: 10px;
    font-size: 0.8rem;
    color: #2563eb;
    text-decoration: none;
}

.pinned-card-link:hover {
    text-decoration: underline;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* =========================================
   PDF EXPORT STYLES (Restored for WeasyPrint)
   ========================================= */
@media print {
    @page {
        size: A4 landscape;
        margin: 10mm;
    }

    .print-template-body {
        font-family: 'Inter', sans-serif;
        font-size: 11px;
        color: #334155;
        line-height: 1.4;
        background: white;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    .print-main-container {
        width: 100%;
        height: 100%;
    }

    /* 3 Column Grid for Landscape Layout */
    .print-grid-3-cols {
        display: flex;
        gap: 20px;
        width: 100%;
        height: 100%;
    }

    .print-col-4 {
        flex: 1;
        width: 32%;
        /* Fallback */
        display: flex;
        flex-direction: column;
        gap: 15px;
    }

    .print-no-break {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .print-page-break {
        page-break-after: always;
    }

    /* Typography */
    .print-h1 {
        font-size: 18px;
        font-weight: 800;
        color: #0f172a;
        margin-bottom: 5px;
        text-transform: uppercase;
        line-height: 1.2;
    }

    .print-h2 {
        font-size: 12px;
        font-weight: 600;
        color: #64748b;
        margin-bottom: 15px;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .print-h3 {
        font-size: 10px;
        font-weight: 700;
        color: #94a3b8;
        border-bottom: 1px solid #e2e8f0;
        padding-bottom: 3px;
        margin-bottom: 8px;
        text-transform: uppercase;
        letter-spacing: 1px;
    }

    /* Data Tables */
    .print-table {
        width: 100%;
        border-collapse: collapse;
        margin-bottom: 15px;
    }

    .print-table td {
        padding: 4px 0;
        border-bottom: 1px solid #f1f5f9;
        vertical-align: top;
    }

    .print-label {
        color: #64748b;
        font-weight: 500;
        width: 45%;
    }

    .print-value {
        color: #0f172a;
        font-weight: 600;
        text-align: right;
    }

    .print-text {
        text-align: justify;
        font-size: 10px;
        line-height: 1.5;
    }

    /* Footer */
    .print-footer-fixed {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        text-align: center;
        font-size: 8px;
        color: #cbd5e1;
    }

    /* Visuals & Layout Helpers */
    .print-col-visuals .h-40,
    .print-col-visuals .h-48 {
        /* Ensure images render nicely */
        break-inside: avoid;
    }

    .print-commerc-block {
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 6px;
        padding: 10px;
        font-size: 9px;
    }
}