/* FiberGIS Main Styles */
* { box-sizing: border-box; }

body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    font-size: 13px;
    background: #f0f0f0;
    overflow: hidden;
}

/* Top menu bar */
#menubar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 28px;
    background: #2c3e50;
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 4px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
    overflow: visible;
}

#menubar .menu-title {
    color: #00d4ff;
    font-weight: 700;
    font-size: 14px;
    padding: 0 12px;
    letter-spacing: 1px;
    white-space: nowrap;
    flex-shrink: 0;
}

/* Hide EasyUI vertical separators and dropdown arrows in menubar */
#menubar .m-btn-line,
#menubar .s-btn-line {
    display: none !important;
}
#menubar .m-btn-downarrow,
#menubar .s-btn-downarrow {
    display: none !important;
    width: 0 !important;
}
/* Remove the right margin reserved for the arrow */
#menubar .l-btn-text {
    margin-right: 0 !important;
    padding-right: 0 !important;
}

/* Ensure menu button text is always fully visible */
#menubar .easyui-menubutton,
#menubar [id^="mm"] {
    white-space: nowrap !important;
    flex-shrink: 0;
}

/* Override EasyUI hover style to match dark theme */
#menubar .l-btn-plain:hover,
#menubar .l-btn:hover {
    background: rgba(255,255,255,0.1) !important;
    border-color: transparent !important;
    color: #fff !important;
    border-radius: 4px;
}

/* ─── Native nav menu (replaces EasyUI menubutton) ──────────────────────────── */
.nav-item {
    position: relative;
    flex-shrink: 0;
}

.nav-label {
    display: inline-block;
    padding: 0 10px;
    height: 28px;
    line-height: 28px;
    color: #ccc;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    border-radius: 3px;
    transition: background 0.15s, color 0.15s;
    user-select: none;
}

.nav-label:hover,
.nav-item:hover .nav-label {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.nav-label-accent {
    color: #4fc3f7 !important;
}

/* Dropdown panel */
.nav-dropdown {
    display: none;
    position: absolute;
    top: 28px;
    left: 0;
    min-width: 210px;
    background: #1e2d3d;
    border: 1px solid #3d5166;
    border-radius: 0 4px 4px 4px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.5);
    z-index: 2000;
    padding: 4px 0;
}

.nav-item:hover .nav-dropdown {
    display: block;
}

.nav-dd-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 7px 14px;
    color: #cfd8dc;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s, color 0.12s;
}

.nav-dd-item:hover {
    background: #2c3e50;
    color: #fff;
}

.nav-dd-item i {
    width: 14px;
    text-align: center;
    color: #4fc3f7;
    flex-shrink: 0;
}

.nav-dd-hint {
    margin-left: auto;
    color: #546e7a;
    font-size: 10px;
}

.nav-dd-sep {
    height: 1px;
    background: #2c3e50;
    margin: 3px 0;
}

/* Menubar search type dropdown checkbox items */
.ms-cb-item {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px;
    color: #cfd8dc;
    font-size: 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.12s;
    user-select: none;
}
.ms-cb-item:hover {
    background: #2c3e50;
}
.ms-cb-item input[type="checkbox"] {
    accent-color: #4fc3f7;
    width: 13px;
    height: 13px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Menubar search type filter buttons */
.ms-type-btn {
    background: transparent;
    border: none;
    color: #7a9ab5;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 3px;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s, color 0.15s;
    line-height: 1.4;
}
.ms-type-btn:hover {
    background: rgba(79,195,247,0.12);
    color: #cfd8dc;
}
.ms-type-active {
    background: rgba(79,195,247,0.18) !important;
    color: #4fc3f7 !important;
    font-weight: 600;
}

/* Menubar search result item */
.ms-result-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    border-bottom: 1px solid #2c3e50;
    font-size: 12px;
    color: #cfd8dc;
    transition: background 0.12s;
}
.ms-result-item:hover {
    background: #2c3e50;
    color: #fff;
}
.ms-result-item:last-child { border-bottom: none; }
.ms-result-icon {
    color: #4fc3f7;
    width: 14px;
    text-align: center;
    flex-shrink: 0;
}
.ms-result-group {
    padding: 4px 12px 2px;
    font-size: 10px;
    color: #546e7a;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: #172535;
}
.ms-result-empty {
    padding: 12px;
    color: #546e7a;
    font-size: 12px;
    text-align: center;
}

/* Active state for toolbar buttons (e.g. ruler when measuring) */
.itool-btn-active {
    background: rgba(79, 195, 247, 0.2) !important;
    color: #4fc3f7 !important;
    border-left: 2px solid #4fc3f7 !important;
}

/* Status bar */
#statusbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 22px;
    background: #2c3e50;
    color: #aaa;
    font-size: 11px;
    display: flex;
    align-items: center;
    padding: 0 8px;
    z-index: 1000;
    gap: 20px;
}

#statusbar span { color: #ccc; }

/* Map container */
#map {
    position: fixed;
    top: 28px;
    left: 0;
    right: 0;
    bottom: 22px;
    z-index: 1;
}

/* EasyUI overrides */
.panel-header { background: #2c3e50 !important; }
.panel-title { color: #fff !important; font-size: 12px !important; }

/* Popup styles */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}

.popup-title {
    font-weight: 600;
    font-size: 13px;
    color: #2c3e50;
    margin-bottom: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid #eee;
}

.popup-row {
    display: flex;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 12px;
}

.popup-label { color: #555; min-width: 80px; font-weight: 500; }
.popup-value { color: #1a1a1a; font-weight: 600; }

.popup-actions {
    display: flex;
    gap: 6px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.popup-btn {
    padding: 4px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    background: #f8f8f8;
    cursor: pointer;
    font-size: 11px;
    color: #333;
    transition: background 0.15s;
}

.popup-btn:hover { background: #e8e8e8; }
.popup-btn.primary { background: #2980b9; color: #fff; border-color: #2980b9; }
.popup-btn.primary:hover { background: #1a6a9a; }
.popup-btn.danger { background: #e74c3c; color: #fff; border-color: #e74c3c; }
.popup-btn.danger:hover { background: #c0392b; }

/* State badges */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}
.badge-plan { background: #e8f4fd; color: #2980b9; }
.badge-fact { background: #e8f8e8; color: #27ae60; }

/* Floating panel */
.floating-panel {
    position: absolute;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
    z-index: 500;
    min-width: 280px;
}

.floating-panel-header {
    background: #2c3e50;
    color: #fff;
    padding: 8px 12px;
    border-radius: 8px 8px 0 0;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: move;
}

.floating-panel-close {
    cursor: pointer;
    color: #aaa;
    font-size: 16px;
    line-height: 1;
}
.floating-panel-close:hover { color: #fff; }

.floating-panel-body { padding: 12px; }

/* Form styles */
.form-row {
    margin-bottom: 10px;
}

.form-row label {
    display: block;
    font-size: 12px;
    color: #333;
    margin-bottom: 4px;
    font-weight: 600;
}

.form-row input,
.form-row select,
.form-row textarea {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 13px;
    outline: none;
    transition: border-color 0.2s;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus {
    border-color: #2980b9;
}

.btn {
    padding: 6px 14px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.2s;
}
.btn:hover { opacity: 0.85; }
.btn-primary { background: #2980b9; color: #fff; }
.btn-success { background: #27ae60; color: #fff; }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-default { background: #ecf0f1; color: #333; border: 1px solid #ccc; }

/* Toolbar */
.map-toolbar {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.toolbar-btn {
    width: 32px;
    height: 32px;
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.2);
    transition: background 0.15s;
}
.toolbar-btn:hover { background: #f0f0f0; }
.toolbar-btn.active { background: #2980b9; color: #fff; border-color: #2980b9; }

/* District selector hover */
#districtSelector:hover {
    background: #4a6278;
    border-color: #00d4ff;
    color: #fff;
}
#districtSelector option {
    background: #2c3e50;
    color: #e0e0e0;
}
#districtSelector option:checked {
    background: #2980b9;
    color: #fff;
}

/* Loading overlay */
#loadingOverlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255,255,255,0.3);
    border-top-color: #00d4ff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Leaflet marker cluster */
.marker-cluster-small { background-color: rgba(181, 226, 140, 0.6); }
.marker-cluster-small div { background-color: rgba(110, 204, 57, 0.6); }
.marker-cluster-medium { background-color: rgba(241, 211, 87, 0.6); }
.marker-cluster-medium div { background-color: rgba(240, 194, 12, 0.6); }
.marker-cluster-large { background-color: rgba(253, 156, 115, 0.6); }
.marker-cluster-large div { background-color: rgba(241, 128, 23, 0.6); }

/* ─── Right View Settings Panel ─────────────────────────────────────────────── */
.vs-check {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    color: #cfd8dc;
    font-size: 13px;
    cursor: pointer;
    border-radius: 4px;
    transition: color 0.15s;
}
.vs-check:hover { color: #fff; }
.vs-check input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: #4fc3f7;
    cursor: pointer;
    flex-shrink: 0;
}
.tile-btn {
    flex: 1;
    padding: 5px 4px;
    background: #1a2634;
    border: 1px solid #3d5166;
    border-radius: 4px;
    color: #90a4ae;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.tile-btn:hover { background: #243447; color: #e0e0e0; }
.tile-btn.active { background: #4fc3f7; color: #1a2634; border-color: #4fc3f7; font-weight: 600; }
#viewSettingsToggle:hover { background: #3d5166 !important; }
#viewSettingsToggle:hover span { color: #e0e0e0 !important; }

/* ─── Floating Insert Toolbar ────────────────────────────────────────────────── */
#insertToolbar {
    position: fixed;
    top: 80px;
    left: 8px;
    width: 52px;
    background: #2c3e50;
    border: 1px solid #3d5166;
    border-radius: 8px;
    box-shadow: 2px 2px 12px rgba(0,0,0,0.4);
    z-index: 600;
    user-select: none;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - 100px);
    scrollbar-width: none;
}
#insertToolbar::-webkit-scrollbar { display: none; }
#insertToolbar .toolbar-handle {
    background: #1a2634;
    padding: 7px 4px 5px;
    text-align: center;
    cursor: move;
    border-bottom: 1px solid #3d5166;
    color: #90a4ae;
    font-size: 9px;
    letter-spacing: 0.5px;
    line-height: 1.4;
}
#insertToolbar .toolbar-handle i {
    display: block;
    font-size: 13px;
    color: #4fc3f7;
    margin-bottom: 2px;
}
#insertToolbar .itool-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px 6px;
    cursor: pointer;
    color: #90a4ae;
    font-size: 9px;
    line-height: 1.3;
    text-align: center;
    border-bottom: 1px solid #243447;
    transition: background 0.15s, color 0.15s;
    gap: 3px;
}
#insertToolbar .itool-btn:last-child { border-bottom: none; }
#insertToolbar .itool-btn i { font-size: 16px; }
#insertToolbar .itool-btn:hover { background: #3d5166; color: #e0e0e0; }
#insertToolbar .itool-btn.active { background: #4fc3f7; color: #1a2634; }
#insertToolbar .itool-sep { height: 1px; background: #3d5166; margin: 4px 6px; }
#insertToolbar .itool-section-label {
    font-size: 8px;
    color: #546e7a;
    text-align: center;
    letter-spacing: 0.8px;
    padding: 4px 0 2px;
    text-transform: uppercase;
    line-height: 1;
}

/* ─── Print styles ──────────────────────────────────────────────────────────── */
@media print {
    /* Hide everything except the map and print legend */
    #menubar,
    #insertToolbar,
    #statusBar,
    #loadingOverlay,
    .leaflet-control-zoom,
    .leaflet-control-attribution,
    .leaflet-control-layers,
    #searchBox,
    .leaflet-popup,
    .leaflet-tooltip,
    .easyui-menu,
    #rulerPanel,
    #rulerResult,
    #m-file, #m-view, #m-insert,
    .modal-overlay,
    .notify-container {
        display: none !important;
    }

    html, body {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        width: 100% !important;
        height: 100% !important;
    }

    #map {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        z-index: 0 !important;
    }

    /* Print legend — shown only when printing */
    #printLegend {
        display: block !important;
        position: fixed;
        bottom: 12mm;
        right: 8mm;
        background: rgba(255,255,255,0.92);
        border: 1px solid #999;
        border-radius: 4px;
        padding: 8px 12px;
        font-size: 10pt;
        font-family: Arial, sans-serif;
        z-index: 9999;
        min-width: 160px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.2);
    }

    #printLegend .pl-title {
        font-weight: bold;
        font-size: 11pt;
        margin-bottom: 6px;
        border-bottom: 1px solid #ccc;
        padding-bottom: 4px;
    }

    #printLegend .pl-item {
        display: flex;
        align-items: center;
        gap: 7px;
        margin-bottom: 4px;
        font-size: 9pt;
    }

    #printLegend .pl-swatch {
        width: 28px;
        height: 4px;
        border-radius: 2px;
        flex-shrink: 0;
    }

    #printLegend .pl-dot {
        width: 10px;
        height: 10px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    #printHeader {
        display: block !important;
        position: fixed;
        top: 6mm;
        left: 8mm;
        background: rgba(255,255,255,0.92);
        border: 1px solid #999;
        border-radius: 4px;
        padding: 5px 12px;
        font-size: 10pt;
        font-family: Arial, sans-serif;
        z-index: 9999;
        color: #222;
    }

    #printHeader strong {
        font-size: 12pt;
    }
}

/* Hidden by default (only shown during print) */
#printLegend, #printHeader {
    display: none;
}
