import re

file_path = r'c:\laragon\www\LPG\resources\views\admin\dashboard.blade.php'
with open(file_path, 'r', encoding='utf-8') as f:
    content = f.read()

pattern = re.compile(
    r'/\* ══════════════════════════════════════════\s*MAP SECTION — Premium Analytics Design.*?</style>\s*@endsectionsharray.*?</scrip',
    re.DOTALL
)

new_css = '''/* ══════════════════════════════════════════
   MAP SECTION — Professional Design
   ══════════════════════════════════════════ */
.map-section-card {
    background: #ffffff;
    border-radius: 0.5rem;
    border: 1px solid #e2e8f0;
    overflow: hidden;
}

/* Header */
.map-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    background: #ffffff;
}

.map-section-title-group {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.map-icon-wrap {
    width: 2rem;
    height: 2rem;
    flex-shrink: 0;
    border-radius: 0.25rem;
    background: #3b82f6;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.map-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: #1e293b;
}

.map-section-subtitle {
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.125rem;
}

.map-header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.map-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.5rem;
    background: #f0fdf4;
    border: 1px solid #dcfce7;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    color: #166534;
}

.map-status-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: #22c55e;
}

.map-clear-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    color: #64748b;
    cursor: pointer;
}

.map-clear-btn:hover {
    background: #f1f5f9;
}

/* Map Layout */
.map-body {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 0;
    height: 500px;
}

@media (max-width: 1024px) {
    .map-body {
        grid-template-columns: 1fr;
        grid-template-rows: 240px 400px;
        height: auto;
    }
}

/* Sidebar */
.map-sidebar {
    display: flex;
    flex-direction: column;
    border-right: 1px solid #e2e8f0;
    background: #ffffff;
    overflow: hidden;
}

@media (max-width: 1024px) {
    .map-sidebar {
        border-right: none;
        border-bottom: 1px solid #e2e8f0;
    }
}

/* Sidebar Search Box */
.map-search-container {
    padding: 0.75rem;
    border-bottom: 1px solid #e2e8f0;
}

.map-search-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.map-search-input {
    width: 100%;
    padding: 0.5rem 0.75rem 0.5rem 2rem;
    border-radius: 0.25rem;
    border: 1px solid #e2e8f0;
    font-size: 0.75rem;
    color: #334155;
}

.map-search-icon {
    position: absolute;
    left: 0.5rem;
    color: #94a3b8;
}

/* Sidebar List Scroll */
.map-sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Zone header badges */
.map-zone-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.map-zone-label {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
}

.map-zone-label.disabled {
    opacity: 0.6;
    text-decoration: line-through;
    background: #f1f5f9 !important;
    color: #64748b !important;
    border-color: #e2e8f0 !important;
}

.map-zone-label small {
    font-weight: normal;
    color: inherit;
    margin-left: 0.25rem;
}

.map-zone-label .zone-count {
    margin-left: auto;
    font-size: 0.7rem;
    padding: 0 0.375rem;
    border-radius: 0.25rem;
}

.zone-dot {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 50%;
}

.zone-1 { background: #f0fdf4; color: #166534; border: 1px solid #dcfce7; }
.zone-1 .zone-dot { background: #22c55e; }
.zone-1 .zone-count { background: #dcfce7; }

.zone-2 { background: #eff6ff; color: #1e40af; border: 1px solid #dbeafe; }
.zone-2 .zone-dot { background: #3b82f6; }
.zone-2 .zone-count { background: #dbeafe; }

.zone-3 { background: #fff1f2; color: #9f1239; border: 1px solid #ffe4e6; }
.zone-3 .zone-dot { background: #f43f5e; }
.zone-3 .zone-count { background: #ffe4e6; }

.map-zone-items {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Customer Item Card */
.zone-customer-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    text-align: left;
    padding: 0.5rem;
    border-radius: 0.25rem;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    cursor: pointer;
}

.zone-customer-btn:hover, .zone-customer-btn.active {
    background: #f8fafc;
    border-color: #cbd5e1;
}

.zone-customer-distance {
    font-size: 0.7rem;
    width: 2rem;
    text-align: center;
    color: #475569;
}

.zone-customer-info {
    flex: 1;
    min-width: 0;
}

.zone-customer-name {
    font-size: 0.75rem;
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zone-customer-sub {
    font-size: 0.7rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.zone-empty-note {
    font-size: 0.75rem;
    color: #64748b;
    text-align: center;
    padding: 0.5rem;
}

/* Map Canvas Container */
.map-canvas-wrap {
    position: relative;
    background: #e2e8f0;
}

#customerMap {
    width: 100%;
    height: 100%;
}

/* Map Floating Control Box (Layers & Filters) */
.map-floating-controls {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.map-control-btn {
    width: 2rem;
    height: 2rem;
    border-radius: 0.25rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.map-control-btn:hover {
    background: #f1f5f9;
}

.map-control-btn.active {
    background: #e2e8f0;
}

/* Premium Floating Legend */
.map-legend {
    position: absolute;
    bottom: 1rem;
    left: 1rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 0.25rem;
    padding: 0.5rem;
}

.legend-header {
    font-size: 0.7rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 0.125rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.7rem;
    color: #334155;
    cursor: pointer;
    padding: 0.125rem 0.25rem;
}

.legend-item:hover {
    background: #f1f5f9;
}

.legend-item.disabled {
    opacity: 0.5;
    text-decoration: line-through;
}

.legend-dot {
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    display: inline-block;
}

/* Connection line */
path.connection-line {
    stroke-dasharray: 4, 4;
}
</style>
@endsection

@push('scripts')
<script src="https://cdn.jsdelivr.net/npm/chart.js"></scrip'''

if pattern.search(content):
    content = pattern.sub(new_css, content)
    with open(file_path, 'w', encoding='utf-8') as f:
        f.write(content)
    print("CSS updated successfully")
else:
    print("Pattern not found!")
